【问题标题】:Flutter - appbar button border/backgroundFlutter - 应用栏按钮边框/背景
【发布时间】:2022-01-18 22:36:35
【问题描述】:

如何使我的应用栏按钮(通知按钮,我不知道,菜单?)看起来像这样? 我的意思是,我怎样才能复制这个border背景。也许我应该使用其他东西而不是出现?

现在我正在使用这个:

class _CustomAppBarState extends State<CustomAppBar> {
  @override
  Widget build(BuildContext context) {
    return AppBar(
      backgroundColor: Colors.transparent,
      elevation: 0,
      leading: IconButton(
        icon: Icon(
          Icons.menu,
          color: Color(0xff736f71),
        ),
        onPressed: () {},
      ),
      actions: [
        IconButton(
          icon: Icon(Icons.add),
          color: Color(0xff736f71),
          onPressed: () {},
        ),
      ],
    );
  }
}```

【问题讨论】:

    标签: flutter dart button flutter-layout flutter-appbar


    【解决方案1】:

    您可以在正文中添加类似这样的内容,而不是制作应用栏

    Container(
        margin: const EdgeInsets.only(top: 30),
        decoration: BoxDecoration(
            color: Colors.white24,
            border: Border.all(color: Colors.white30),
            borderRadius: BorderRadius.circular(30)),
        padding: const EdgeInsets.symmetric(horizontal: 25, vertical: 20),
        child: Column(
          children: [
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: const [
                Icon(
                  Icons.menu,
                  color: Colors.white,
                ),
                Icon(
                  Icons.add,
                  color: Colors.white,
                ),
              ],
            ),
          ],
        ),
      )
    

    输出

    【讨论】:

    • 谢谢,但我不是这个意思。我说的是按钮周围的边框,那个圆角的正方形。
    【解决方案2】:

    只需在脚手架内使用extendBodyBehindAppBar: true,

    【讨论】:

      猜你喜欢
      • 2021-05-25
      • 2011-12-07
      • 1970-01-01
      • 1970-01-01
      • 2017-03-06
      • 2012-03-06
      • 2014-10-20
      • 1970-01-01
      • 2021-10-02
      相关资源
      最近更新 更多