【发布时间】:2021-02-02 09:28:08
【问题描述】:
这是我的代码,这里我触发了函数showDialog,但没有显示任何对话框。
Widget appbar(BuildContext context) {
return PreferredSize(
preferredSize: Size.fromHeight(59.0), //AppBar Height
child: AppBar(
centerTitle: true, //make icon on center
leading: Builder(
builder: (context) => IconButton(
icon: SizedBox(
height: 32,
width: 32,
child: Image.asset('resources/icon/menu.png')),
onPressed: () {
if (_scaffoldBodyKey.currentState.isDrawerOpen == false) {
_scaffoldBodyKey.currentState.openDrawer();
} else {
_scaffoldBodyKey.currentState.openEndDrawer();
}
}),
),
title: SizedBox(
height: 32, width: 32, child: Image.asset('resources/icon/icon.png')),
actions: <Widget>[
IconButton(
icon: SizedBox(
height: 25,
width: 25,
child: Image.asset('resources/icon/more.png')),
onPressed: () {
showDialog(
context: context,
builder: (ctx) => AlertDialog(
title: Text('Sfee'),
content: Text("dddsscsdcscs"),
actions: <Widget>[
Column(
children: [
FlatButton(
child: Text('Okay'),
onPressed: () {
Navigator.of(ctx).pop();
},
color: Theme.of(context).accentColor,
padding: EdgeInsets.all(6),
),
],
)
],
),
);
}),
],
),
);
【问题讨论】:
-
任何错误控制台?
-
确保提供的
context是构建方法上下文。 -
试了主体也没有作用
-
有弹窗launch.json
-
@JeffNaa 您介意关闭您的编辑器和模拟器并重新启动吗??
标签: flutter