The argument type ‘Dialog’ can’t be assigned to the parameter type ‘Widget Function(BuildContext)’

huangapple go评论74阅读模式
英文:

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(

huangapple
  • 本文由 发表于 2023年3月4日 08:04:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/75632823.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定