英文:
The argument type 'Dialog' can't be assigned to the parameter type 'Widget Function(BuildContext)'
问题
以下是翻译好的部分:
我试图在Dialog
中显示一个Form
小部件,如下所示:
onPressed: () async {
switch (currentScreen.toString()) {
case 'OverviewScreen':
() => showDialog(
context: context,
builder: const Dialog(child: FormBasicDetails()));
break;
}
},
但是在builder
行出现以下错误:
参数类型'
Dialog
'无法分配给参数类型'Widget Function(BuildContext)
'。
英文:
I am trying to display a Form
Widget 2ithin a Dialog
as following:
onPressed: () async {
switch (currentScreen.toString()) {
case 'OverviewScreen':
() => showDialog(
context: context,
builder: const Dialog(child: FormBasicDetails()));
break;
}
},
But I get the following error at the builder
line:
> The argument type 'Dialog' can't be assigned to the parameter type
> 'Widget Function(BuildContext)'
答案1
得分: 2
builder
提供了带有上下文的回调方法。
它将是
showDialog(
context: context,
builder: (context) => const Dialog(
英文:
builder
provides callback method with context.
It will be
showDialog(
context: context,
builder: (context) => const Dialog(
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论