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/

相关文章:

dart - 如何解决文本中的 "A RenderFlex overflowed by 143 pixels on the right."错误?

Flutter 平台 channel 调用的两个方向?

flutter : Target file "lib/main.dart" not found

android - Flutter 应用在​​ Release模式下显示灰屏,但在 Debug模式下工作正常 'DiagnosticsProperty<void>' 实例

image - 如何在我的 flutter 应用程序中从 bing web search apiv7 获取图像

dart - Flutter tween 基本动画在 `FutureBuilder` 内部不起作用

flutter - 如何在弹出窗口 flutter 中创建按钮列表

android - Flutter Gridview 不更新来自 firebase 的值

flutter - 如何在 flutter 中制作更粗的下划线文本

flutter - 如何根据子文本的长度设置容器的宽度? flutter