【问题标题】:drawer at bottom of screen in flutter颤动中屏幕底部的抽屉
【发布时间】:2020-09-12 20:21:53
【问题描述】:

我想要一个回忆应用程序。在这个应用程序中,您可以单击一个内存,它会在底部打开一个抽屉,如下所示:https://i.stack.imgur.com/6lWeb.png 我认为从 ui 的角度来看这是有道理的,因为从侧面打开抽屉会浪费屏幕空间,除非您在横向模式,但人的模式不是。

我已经尝试在谷歌上搜索我确实找到了:

return Scaffold(
    key: _scaffoldKey,
   endDrawer: Drawer(
    child: ListView(
      padding: EdgeInsets.zero,
      children: [
        DrawerHeader(child: Text("right drawer"))

但是在 dartpad 中这不起作用,因为未定义 endDrawer,bottomDrawer 也不起作用。

【问题讨论】:

    标签: flutter navigation-drawer


    【解决方案1】:

    showModalBottomSheet 应该适用于您正在尝试做的事情。过去它对我有用。

    这是我在过去的 To Do List 项目中使用的代码 sn-p,其中包括 showModalBottomSheet

    class TasksScreen extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return Scaffold(
            backgroundColor: Colors.lightBlueAccent,
            floatingActionButton: FloatingActionButton(
              backgroundColor: Colors.lightBlueAccent,
              child: Icon(Icons.add),
              onPressed: () {
                showModalBottomSheet(
                  context: context,
                  builder: (context) => AddTaskScreen(),
                );
    

    上面的代码 sn-p 激活模态底部工作表,在单击浮动操作按钮后从应用底部向上滑动。

    它在我的应用中的外观图片:https://i.stack.imgur.com/p41J8.jpg

    Flutter 文档: https://api.flutter.dev/flutter/material/showModalBottomSheet.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-03-20
      • 1970-01-01
      • 2020-06-23
      • 1970-01-01
      • 1970-01-01
      • 2020-09-13
      • 2017-12-04
      • 2020-06-06
      相关资源
      最近更新 更多