AppBar(
automaticallyImplyLeading: false, // Has no impact of true/false
title: Text('AppBar'),
)
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.
在我的代码中,leading
为 null
,但设置 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,
关于flutter - 为什么AppBar的automaticImplyLeading没有效果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65558881/