首页 > 解决方案 > Flutter:即使用户操作更改了路线,也显示覆盖

问题描述

考虑我有两个视图,订单视图和订单详细信息视图。

我想在订单视图上显示一个叠加层(底部的小部分),当用户选择一个订单时,我们会显示详细信息视图,但我想继续显示叠加层,我想推送路线更改所以返回按钮等工作。

这是可行的吗

标签: flutterflutter-layout

解决方案


使用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),
                    ),
                  ),
                );
              },
            );
          },
        ),
      ),
    );
  }

推荐阅读