flutter - 为什么AppBar的automaticImplyLeading没有效果?

标签 flutter flutter-layout

AppBar(
  automaticallyImplyLeading: false, // Has no impact of true/false
  title: Text('AppBar'),
)

Docs mention :

automaticallyImplyLeading: If true and leading is null, automatically try to deduce what the leading widget should be. If false and leading is null, leading space is given to title.

在我的代码中,leadingnull,但设置 automaticallyImplyLeading 属性对标题没有影响。但文档说的是别的东西。

最佳答案

automaticallyImplyLeading: false 用于从第二个屏幕删除后退按钮(当用户从​​第一个屏幕导航到第二个屏幕时出现这种情况,这是 flutter 默认行为)。显示后退按钮/前导小部件 flutter 会占用 AppBar 左侧的一些空间。

如果为 false 并且前导为空,则为标题提供前导空格。

根据上面的说法,如果为 false,则将前导小部件/后退按钮的默认空间赋予应用栏的标题小部件。

appBar: AppBar(
        automaticallyImplyLeading: false, // Remove back button
        title: const Text('This is simple Text of App Bar for second screen'),
      ),

使用automaticallyImplyLeading:false,

enter image description here

关于flutter - 为什么AppBar的automaticImplyLeading没有效果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65558881/

相关文章:

flutter - 如何在 streambuilder 中设置状态

dart - 在底部工作表中点击项目时显示 snackbar

构建运行器的 flutter 生成器问题

text - 如何在给定宽度的小部件中移动文本

flutter - 如何在有状态或无状态小部件之外访问 BuildContext?

android - Flutter AlertDialog Navigator 弹出黑屏问题

dart - Flutter/GraphQL - 以自定义类型作为参数的突变

flutter - 将GridView构建器中的行高度更改为固定高度

ios - 如何在列表底部显示一个按钮?

Flutter 通过拖动调整 TextField 的大小