如何在 flutter 中设置 showModalBottomSheet 宽度
how to set showModalBottomSheet width in flutter
我有设计(如图所示)并且我正在使用 showModalBottomSheet 但是当我设置宽度时,它不会改变并保持为屏幕宽度,所以我有几个问题:
1-如何设置 showModalBottomSheet 的宽度
2-对于这种底部菜单,是否有 showModalBottomSheet 的替代方案
3-如何模糊照片中显示的背景
showModalBottomSheet<void>(
context: context,
builder: (BuildContext context) {
return Container(
height: SizeConfig.screenHeight * 0.6,
width: 30,
color: Colors.red,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const Text('Modal BottomSheet'),
ElevatedButton(
child: const Text('Close BottomSheet'),
onPressed: () => Navigator.pop(context),
)
],
),
),
);
},
);
我通过将容器放入容器中解决了这个问题。
父容器具有透明颜色,而子容器具有纯色和填充。
但我仍然不知道如何模糊背景。
这是代码:
showModalBottomSheet(
context: context,
backgroundColor: Colors.transparent,
builder: (BuildContext bc) {
return Container(
height: SizeConfig.screenHeight * 0.6,
child: Padding(
padding: EdgeInsets.only(left: SizeConfig.screenWidth * 0.4),
child: Container(
child: SingleChildScrollView(
child:
Padding(
padding: EdgeInsets.only(
top: SizeConfig.blockSizeVertical * 1.5),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
],
),
),
),
),
),
);
});
在 showModalBottomSheet 中使用约束 属性。
showModalBottomSheet(
context: context,
constraints: BoxConstraints(
maxWidth: 600,
),
builder: ...
),
我有设计(如图所示)并且我正在使用 showModalBottomSheet 但是当我设置宽度时,它不会改变并保持为屏幕宽度,所以我有几个问题:
1-如何设置 showModalBottomSheet 的宽度
2-对于这种底部菜单,是否有 showModalBottomSheet 的替代方案
3-如何模糊照片中显示的背景
showModalBottomSheet<void>(
context: context,
builder: (BuildContext context) {
return Container(
height: SizeConfig.screenHeight * 0.6,
width: 30,
color: Colors.red,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const Text('Modal BottomSheet'),
ElevatedButton(
child: const Text('Close BottomSheet'),
onPressed: () => Navigator.pop(context),
)
],
),
),
);
},
);
我通过将容器放入容器中解决了这个问题。
父容器具有透明颜色,而子容器具有纯色和填充。
但我仍然不知道如何模糊背景。
这是代码:
showModalBottomSheet(
context: context,
backgroundColor: Colors.transparent,
builder: (BuildContext bc) {
return Container(
height: SizeConfig.screenHeight * 0.6,
child: Padding(
padding: EdgeInsets.only(left: SizeConfig.screenWidth * 0.4),
child: Container(
child: SingleChildScrollView(
child:
Padding(
padding: EdgeInsets.only(
top: SizeConfig.blockSizeVertical * 1.5),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
],
),
),
),
),
),
);
});
在 showModalBottomSheet 中使用约束 属性。
showModalBottomSheet(
context: context,
constraints: BoxConstraints(
maxWidth: 600,
),
builder: ...
),