我想从顶部而不是底部点击浮动操作按钮来打开底部工作表。有什么办法可以做到这一点吗?或者是否有任何其他小部件可以用于我的目的而不是底板?
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'),
)
],
),
);
});
}
isScrollControlled: true,
添加到 showModalBottomSheet。 const FractionallySizedBox(
heightFactor: 1.0,
child: Container(...),
),
您将会得到您想要的结果。