简体   繁体   English

如何在 Flutter 的应用栏右上角创建一个带有图标的按钮

[英]How can I create a button with an icon on the top right under the appbar on Flutter

I want to create a button under the appbar (navbar) with a button not too big just normal size but I couldn't.我想在应用栏(导航栏)下创建一个按钮,按钮不是太大,只是正常大小,但我不能。 It needs to be on top right and icon will be on the right like "Categories(List Icon)"它需要在右上角,图标将在右侧,如“类别(列表图标)”

在此处输入图像描述

I don't know how exactly you want it to be.我不知道你到底想要它怎么样。 As mentioned you can use endDrawer or else, like in the screenshot, you can do something like this,如前所述,您可以使用endDrawer或其他方式,如屏幕截图所示,您可以这样做,

Scaffold(
      appBar: AppBar(title: Text('Category Demo')),
      body: Column(children: [
        Row(mainAxisAlignment: MainAxisAlignment.end,
          children: [
          Container(
            width: 130.0,
            child: FlatButton(
              onPressed: () {
                Navigator.push(context,
                    MaterialPageRoute(builder: (context) => Categories()));
              },
              child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text("Categories"),
                    Icon(Icons.menu),
                  ]
               ),
            ),
          )
        ])
      ]),
    );

Output: Output:

在此处输入图像描述

Hope that works!希望有用!

You can try endDrawer in Scaffold from this example: https://api.flutter.dev/flutter/material/Scaffold/endDrawer.html您可以从这个例子中尝试脚手架中的 endDrawer: https://api.flutter.dev/flutter/material/Scaffold/endDrawer.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM