【问题标题】:Flutter bottom sheet invisible because of bottom navigation bar由于底部导航栏,颤动底部工作表不可见
【发布时间】:2019-02-20 08:10:44
【问题描述】:

我正在尝试显示底部表格并让用户选择。我确实喜欢这样

showModalBottomSheet(
  context: context,
  builder: (builder) {
   return Column(
     mainAxisSize: MainAxisSize.min,
      children: <Widget>[
       new ListTile(
        leading: new Icon(Icons.image),
        title: new Text('From gallary'),
       ),
       new ListTile(
        leading: new Icon(Icons.camera_alt),
        title: new Text('Take video'),
       ),
      ],
    );
   });

但是由于底部导航栏,它几乎不可见。 看起来像这样。 我想实现从底部导航栏顶部边缘向上的最小高度底部工作表。我怎样才能做到这一点?

【问题讨论】:

    标签: flutter


    【解决方案1】:

    showModalBottomSheet 具有useRootNavigator,默认为false。文档说:

    useRootNavigator 参数确保根导航器用于 设置为 true 时显示 [BottomSheet]。这在这种情况下很有用 模态 [BottomSheet] 需要显示在所有其他内容之上 但调用者在另一个 [Navigator] 中。

    我认为这可以解决您的问题。

    【讨论】:

      【解决方案2】:

      尝试用ListView 包裹孩子而不是Column,并确保shrinkWrap: true

      showModalBottomSheet(
          context: context,
          builder: (builder) {
            return ListView(
              shrinkWrap: true,
              children: <Widget>[
                new ListTile(
                  leading: new Icon(Icons.image),
                  title: new Text('From gallary'),
                ),
                new ListTile(
                  leading: new Icon(Icons.camera_alt),
                  title: new Text('Take video'),
                ),
              ],
            );
          });
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-04-02
        • 2020-03-07
        • 1970-01-01
        • 2020-08-19
        • 2019-06-19
        • 2019-12-21
        • 1970-01-01
        相关资源
        最近更新 更多