freddon
发表于2019-08-13
阅读 2209 |
评论 0
默认showModalBottomSheet底部弹窗,点击以外的蒙层会造成弹窗关闭,于是采用showBottomSheet来实现。
默认的showModalBottomSheet是这样:
```
showModalBottomSheet(
builder:(BuildContext rootContext) =>
StatefulBuilder(builder: (context, dialogSetState) {
var height = MediaQuery.of(rootContext).viewInsets.bottom;
setDialogState = dialogSetState;
dialogVisible = true;
return Material(
color: UIColor.whiteBgColor,
child: SingleChildScrollView(
child: new AnimatedPadding(
padding: EdgeInsets.only(
bottom: keyboardIsVisible
? height
: kToolbarHeight), //MediaQuery.of(context).viewInsets, //边距(必要)
duration:
const Duration(milliseconds: 100), //时常 (必要)
child:
dialogContentView(rootContext, dialogSetState)),
));
}),
elevation: 10)
```
替换成showBottomSheet之后,报错:
```
flutter: ══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════
flutter: The following assertion was thrown while handling a gesture:
flutter: No Scaffold widget found.
flutter: Flutter