我想要一个回忆应用程序。在此应用中,您可以单击一个内存,然后在底部打开一个抽屉,如下所示:https://i.stack.imgur.com/6lWeb.png从ui的角度来看,这是有意义的,因为从侧面打开抽屉会浪费屏幕空间,除非您在横向模式下,但人却不是。
我尝试在我发现的Google上进行搜索:
return Scaffold(
key: _scaffoldKey,
endDrawer: Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: [
DrawerHeader(child: Text("right drawer"))
但是在dartpad中,此操作不起作用,因为未定义endDrawer,bottomDrawer也不起作用。
答案 0 :(得分:2)
showModalBottomSheet 应该可以满足您的尝试。过去对我有用。
这是我过去的待办事项列表项目中使用的代码段,其中包括 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(),
);
上面的代码段在单击浮动操作按钮后激活了模式底部面板,使其从应用程序底部向上滑动。
它在我的应用中的外观图片:https://i.stack.imgur.com/p41J8.jpg
Flutter Docs: https://api.flutter.dev/flutter/material/showModalBottomSheet.html