代码:
void showNow() {
showGeneralDialog(
context: context,
pageBuilder: (BuildContext buildContext, Animation<double> animation, Animation<double> secondaryAnimation) {
return Container(
width: 200.0,
height: 200.0,
color: Colors.orange,
);
},
barrierDismissible: true,
barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
barrierColor: Colors.black,
transitionDuration: const Duration(milliseconds: 200),
);
}
但是此对话框占用了整个空间,而不是我使用的200.0 width
和height
。我尝试将Container
包装在Scaffold
中,但是随后barrierDismissible
和barrierColor
似乎不起作用。我也改变了他们的价值观,但没有运气。
答案 0 :(得分:0)
在包装小部件中包装容器:
void showNow() {
showGeneralDialog(
context: context,
pageBuilder: (BuildContext buildContext, Animation<double> animation,
Animation<double> secondaryAnimation) {
return Wrap(
children: <Widget>[
Container(
width: 200.0,
height: 200.0,
color: Colors.orange,
),
],
);
},
barrierDismissible: true,
barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
barrierColor: Colors.black,
transitionDuration: const Duration(milliseconds: 200),
);
}