简体   繁体   English

如何将两个 IconButtons 放在同一列(AppBar 和 Body)中?

[英]How to put two IconButtons in the same Column (AppBar and Body)?

Is there any way how to have an IconButton in the AppBar and an IconButton in the Body the same column width?有什么方法可以让 AppBar 中的 IconButton 和 Body 中的 IconButton 具有相同的列宽? The splash radius should be default.飞溅半径应为默认值。 Please have a look on a screenshot at the following link for an overview.请查看以下链接中的屏幕截图以获取概述。

https://i.stack.imgur.com/O0CiM.png https://i.stack.imgur.com/O0CiM.png

I'm not sure if this is the solution that you are looking for, because your question is not clear 100%.我不确定这是否是您正在寻找的解决方案,因为您的问题不是 100% 清楚。

By default IconButton are aligned to the AppBar actions.默认情况下 IconButton 与 AppBar 动作对齐。 You can check it on this sample:您可以在此示例上检查它:

https://dartpad.dev/?id=0199904cac2a477c420efe473ed21319 https://dartpad.dev/?id=0199904cac2a477c420efe473ed21319

The result is this:结果是这样的:

在此处输入图像描述

You can use SilverAppbar medium or large depend on you.您可以使用 SilverAppbar 中型或大型取决于您。 This widget is new in flutter 3.3 so just update SDK to using it.这个小部件在 flutter 3.3 中是新的,所以只需更新 SDK 即可使用它。 In MaterialApp you need to specify:在 MaterialApp 中,您需要指定:

theme: ThemeData(useMaterial3: true)

And then in Scaffold body:然后在脚手架体内:

return Scaffold(
  body: CustomScrollView(
    slivers: [
      SliverAppBar.medium(
        title: const Text('Your tittle of page'),
        actions: [
          IconButton(onPressed: () {}, icon: const Icon(Icons.abc)),
          IconButton(
              onPressed: () {}, icon: const Icon(Icons.abc_outlined)),
        ],
      ),
      SliverToBoxAdapter(
        child: Text('Content of page'),
      ),
    ],
  ),
);

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

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