android - 后退按钮不适用于 SafeArea 视图
问题描述
嘿,我在下面的屏幕上使用SafeArea
和BackButton
。此处的后退按钮不适用于 SafeArea。
有谁知道如何解决这个问题?
class _ProfileScreenState extends State<ProfileScreen> {
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new SafeArea(
child: Scaffold(
body: new Column(
children: <Widget>[
new Stack(
children: <Widget>[
Stack(
children: <Widget>[
new Row(
children: <Widget>[
new Expanded(
child: new Image.asset('assets/images/profile.jpg',
fit: BoxFit.fill, height: 250),
),
],
),
new Container(
alignment: Alignment.topLeft,
margin: EdgeInsets.only(top: 220, left: 22),
child: new Text("Eilly",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 15)),
)
],
),
new Container(
alignment: Alignment.topLeft,
child: new BackButton(
color: Colors.white,
),
),
],
)
],
),
)),
);
}
}
解决方案
从你的构建函数中删除MaterialApp
就可以了!仅用于MaterialApp
根页面。用于Scaffold
路由页面,它会自动在 AppBar 中创建返回按钮。
appBar: PreferredSize(child: AppBar(
elevation: 0.0,
),
preferredSize: Size.fromHeight(0.0)
)
推荐阅读
- javascript - Three.js 附加组件导入期间的错误
- powerbi - 如何通过 Power BI 中的实时连接预过滤数据?
- javascript - 使用 Jquery 从 XML 数据创建对象数组
- docker - 从 dockerfile 构建 BigBlueButton
- arrays - 该函数未打印数组的值
- css - 响应式菜单的可访问性
- java - Junit 错误:CannotStubVoidMethodWithReturnValue - 一起运行时测试失败,但单独通过
- python - 如何在 PySimpleGUI 中的 InputText 中按下 Enter 时引发事件
- python - Pygame:我怎样才能让我的动画更流畅?
- javascript - ajax成功后异步重新加载页面