首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Tinder小部件可见性

Tinder小部件可见性
EN

Stack Overflow用户
提问于 2021-08-19 11:05:42
回答 1查看 116关注 0票数 0

我使用了swipe_cards包来实现像swipe这样的tinder,但我无法添加在左侧、右侧和顶部滑动时出现的文本小部件(不喜欢,喜欢和超级喜欢)。

代码语言:javascript
复制
class DatingAppDesign extends StatefulWidget {

  @override
  _DatingAppDesignState createState() => _DatingAppDesignState();
}

class _DatingAppDesignState extends State<DatingAppDesign> {
  List<SwipeItem> _swipeItems = [];

  late MatchEngine _matchEngine;

  GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey();

  List<String> _names = ["1", "2", "3", "4", "last"];

  List<Color> _colors = [
    Colors.red,
    Colors.blue,
    Colors.green,
    Colors.yellow,
    Colors.orange
  ];

  @override
  void initState() {
    for (int i = 0; i < _names.length; i++) {
      _swipeItems.add(SwipeItem(
          content: Content(text: _names[i], color: _colors[i]),
          likeAction: () {

          },
          nopeAction: () {

          },
          superlikeAction: () {
         
          }));
    }

    _matchEngine = MatchEngine(swipeItems: _swipeItems,);
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    double ha = MediaQuery.of(context).size.height -
        138 -
        MediaQuery.of(context).padding.top;
    return Scaffold(
      body: Container(

        height: ha,
        width: double.infinity,
        color: Colors.white,
        child: Column(
          children: [
            Container(
              decoration: BoxDecoration(
               // color: Colors.white,
                borderRadius: BorderRadius.vertical(
                  top: Radius.circular(35.0),
                ),
              ),
              width: MediaQuery.of(context).size.width*0.8,
              height: ha*0.7,
              child: Center(
                child: SwipeCards(
                  matchEngine: _matchEngine,
                  itemBuilder: (BuildContext context, int index) {
                    return Stack(children: [
                      Container(
                        alignment: Alignment.center,
                        color: _swipeItems[index].content.color,
                        child: Text(
                          _swipeItems[index].content.text,
                          style: TextStyle(fontSize: 100),
                        ),
                      ),

                      Center(child: Text("Hello World"),),
                    ],

                    );
                  },
                  onStackFinished: () {

                  },
                ),
              ),
            ),
            Container(
              height: ha * 0.3,

              child: Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: [
                   Container(
                    padding: EdgeInsets.all(1),
                    decoration: BoxDecoration(
                      boxShadow: [
                        BoxShadow(
                          color: Colors.grey,
                          //offset: Offset(0.0, 1.0), //(x,y)
                          blurRadius: 10.0,
                        ),
                      ],
                      color: Colors.white,
                      borderRadius: BorderRadius.circular(39),
                    ),
                    constraints: BoxConstraints(maxHeight: 78, minWidth: 78),
                     child: Center(
                       child: SvgPicture.asset(
                         'assets/icons/cross.svg',
                        // color: Colors.white12,
                       ),
                     ),
                  ),
                  Container(
                    padding: EdgeInsets.all(1),
                    decoration: BoxDecoration(
                      boxShadow: [
                        BoxShadow(
                          color: Colors.grey,
                         // offset: Offset(0.0, 1.0), //(x,y)
                          blurRadius: 10.0,
                        ),
                      ],
                      color: Colors.red,
                      borderRadius: BorderRadius.circular(49.5),
                    ),
                    constraints: BoxConstraints(maxHeight: 99, minWidth: 99),
                    child: Center(
                      child: SvgPicture.asset(
                        'assets/icons/heart.svg',
                       // color: Colors.white12,
                      ),
                    ),
                  ),
                  Container(
                    padding: EdgeInsets.all(1),
                    decoration: BoxDecoration(
                      boxShadow: [
                        BoxShadow(
                          color: Colors.grey,
                       //   offset: Offset(0.0, 1.0), //(x,y)
                          blurRadius: 10.0,
                        ),
                      ],
                      color: Colors.white,
                      borderRadius: BorderRadius.circular(39),
                    ),
                    constraints: BoxConstraints(maxHeight: 78, minWidth: 78),
                    child: Center(
                      child: SvgPicture.asset(
                        'assets/icons/star.svg',
                      //  color: Colors.white12,
                      ),
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
      appBar: appbar,
      bottomNavigationBar: BottomNevigationDesign(),
    );
  }
}

我使用了手势检测器,但它不起作用。我读到了swipe_cards下的所有事件都使用了pub.dev上的相同示例。我完全卡住了,请帮帮我,谢谢。

EN

回答 1

Stack Overflow用户

发布于 2021-08-19 13:17:47

根据你的评论,我认为你正在寻找flutter中的snackbar。

https://flutter.dev/docs/cookbook/design/snackbars

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68846656

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档