Search code examples
flutterdialogwidgetvariable-assignment

The argument type 'Dialog' can't be assigned to the parameter type '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)'


Solution

  • builder provides callback method with context.

    It will be

    showDialog(
      context: context,
      builder: (context) => const Dialog(