Flutter:即使用户操作更改了路线,也会显示叠加层
Flutter: Display overlay even though route is changed by user action
假设我有两个视图,订单视图和订单详细信息视图。
我想在订单视图上显示一个叠加层(底部的小部分),当用户选择一个订单时,我们显示详细信息视图,但我想继续显示叠加层,我想推送路线更改所以后退按钮等工作。
这个可行吗
使用showModalBottomSheet
更多示例:modal_bottom_sheet_demo persistent_bottom_sheet_demo
考试:
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Modal bottom sheet'),
),
body: Center(
child: RaisedButton(
child: const Text('SHOW BOTTOM SHEET'),
onPressed: () {
showModalBottomSheet<void>(
context: context,
builder: (BuildContext context) {
return Container(
child: Padding(
padding: const EdgeInsets.all(32.0),
child: Text(
'This is the modal bottom sheet. Tap anywhere to dismiss.',
textAlign: TextAlign.center,
style: TextStyle(
color: Theme.of(context).accentColor, fontSize: 24.0),
),
),
);
},
);
},
),
),
);
}
假设我有两个视图,订单视图和订单详细信息视图。
我想在订单视图上显示一个叠加层(底部的小部分),当用户选择一个订单时,我们显示详细信息视图,但我想继续显示叠加层,我想推送路线更改所以后退按钮等工作。
这个可行吗
使用showModalBottomSheet
更多示例:modal_bottom_sheet_demo persistent_bottom_sheet_demo
考试:
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Modal bottom sheet'),
),
body: Center(
child: RaisedButton(
child: const Text('SHOW BOTTOM SHEET'),
onPressed: () {
showModalBottomSheet<void>(
context: context,
builder: (BuildContext context) {
return Container(
child: Padding(
padding: const EdgeInsets.all(32.0),
child: Text(
'This is the modal bottom sheet. Tap anywhere to dismiss.',
textAlign: TextAlign.center,
style: TextStyle(
color: Theme.of(context).accentColor, fontSize: 24.0),
),
),
);
},
);
},
),
),
);
}