【问题标题】:Slider in FlutterFlutter 中的滑块
【发布时间】:2022-12-18 14:20:18
【问题描述】:

我想制作与照片中相同的滑块。什么是圆形按钮。我使用了 flutter_slidable 插件,但它不起作用或者我做错了什么?

下面是我试图做的代码

       Slidable(
                  endActionPane: ActionPane(
                    motion: const DrawerMotion(),
                    children: [
                      SlidableAction(
                        onPressed: (BuildContext context) {},
                        borderRadius:
                            BorderRadius.all(Radius.circular(180)),
                        backgroundColor: const Color(0xFFFE4A49),
                        foregroundColor: Colors.white,
                        icon: Icons.delete,
                      ),
                      SlidableAction(
                        onPressed: (BuildContext context) {},
                        borderRadius: BorderRadius.circular(180),
                        backgroundColor: const Color(0xFFFE4A49),
                        foregroundColor: Colors.white,
                        icon: Icons.delete,
                      ),
                    ],
                  ),
                  child: ListTile(
                      title: Text("Text",
                          style: const TextStyle(fontSize: 18)),
                      subtitle: Text("Text2"),
                      onTap: () {
                      }));

【问题讨论】:

  • 什么不起作用?向我们展示您尝试过的代码
  • @Nitish,我补充说

标签: android flutter dart


【解决方案1】:

试试我写的这段代码,它完全按照你想要的方式工作:

Scaffold(

  backgroundColor: Color(0xffF3F3F6),
  body: Center(
    child: Slidable(
      key: const ValueKey(0),
      startActionPane: ActionPane(
        motion: const ScrollMotion(),
        children: [
          Expanded(
              child: Container(
            color: Colors.transparent,
            child: RawMaterialButton(
              onPressed: () {},
              elevation: 2.0,
              fillColor: Colors.red,
              child: Icon(
                Icons.favorite,
              ),
              padding: EdgeInsets.all(12.0),
              shape: CircleBorder(),
            ),
          )),
          Expanded(
              child: Container(
                  color: Colors.transparent,
                  child: RawMaterialButton(
                    onPressed: () {},
                    elevation: 2.0,
                    fillColor: Colors.red,
                    child: Icon(
                      Icons.favorite,
                    ),
                    padding: EdgeInsets.all(12.0),
                    shape: CircleBorder(),
                  ))),
        ],
      ),
      child: const ListTile(
        title: Text('Slide me'),
        tileColor: Colors.white,
      ),
    ),
  ),
);

【讨论】:

  • 没问题... :)
【解决方案2】:

如果您可以分享制作滑块的部分代码,我可以提供帮助。

【讨论】:

  • 它应该是评论而不是答案。
  • 我添加了我的代码
猜你喜欢
  • 2019-05-19
  • 2018-11-21
  • 2023-01-14
  • 2017-11-04
  • 2021-04-11
  • 2019-03-29
  • 1970-01-01
  • 1970-01-01
  • 2020-08-26
相关资源
最近更新 更多