是否可以使底部工作表从顶部而不是底部出现在颤振中?

问题描述 投票:0回答:1

我想从顶部而不是底部点击浮动操作按钮来打开底部工作表。有什么办法可以做到这一点吗?或者是否有任何其他小部件可以用于我的目的而不是底板?

floatingActionButtonLocation: FloatingActionButtonLocation.endTop,
  floatingActionButton: Container(
    margin: const EdgeInsets.only(top: 235),
    child: FloatingActionButton(
      onPressed: () {
        print('float clicked');
        showBottomSheet(context);
      },
      tooltip: 'Add New ToDo',
      child: const Icon(Icons.add),
    ),
  ),

Future<void> showBottomSheet(BuildContext ctx) async {
showModalBottomSheet(
    backgroundColor: Color.fromARGB(255, 225, 211, 230),
    isDismissible: true,
    context: ctx,
    builder: (ctx1) {
      return Container(
        height: 200,
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            Container(
              margin: EdgeInsets.only(top: 15, left: 15, right: 15),
              decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.circular(180),
              ),
              child: const TextField(
                decoration: InputDecoration(
                    border: InputBorder.none,
                    hintText: 'Add New Task',
                    contentPadding: EdgeInsets.all(10)),
              ),
            ),
            ElevatedButton(
              onPressed: () {},
              child: Text('Add'),
            )
          ],
        ),
      );
    });
}
flutter bottom-sheet flutter-showmodalbottomsheet
1个回答
0
投票
  1. isScrollControlled: true,
    添加到 showModalBottomSheet。
  2. 将容器包裹在 modalbottomsheet 的构建器中
     const FractionallySizedBox(
         heightFactor: 1.0,
         child: Container(...),
     ),
    

您将会得到您想要的结果。

© www.soinside.com 2019 - 2024. All rights reserved.