我试图展示一个类似卡片的教程,该卡片在底部弹出,用户可以按按钮或向下拖动将其关闭。当我使用
showModalBottomSheet
并将属性 useRootNavigator
设置为 true
时,它会覆盖我设置的底部导航栏。但是当我使用 showBottomSheet 时,它没有 useRootNavigator
属性,并且它也呈现在内部导航器外部的底部栏导航器上方。
我的用例要求我显示背景而不覆盖它,这就是
showModalBottomSheet
所做的。
showModalBottomSheet(
context: context,
builder: (context) => ... ,
useRootNavigator: true,
);
showBottomSheet(
context: context,
builder: (context) => ... ,
);
像下面一样使用 showBottomSheet...希望它有帮助
showBottomSheet(
context: context,
builder: (context) {
return Container(); // Replace with your actual bottom sheet widget
},
).closed.whenComplete(() {
Navigator.of(context).maybePop();
});