Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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)’

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

builder provides callback method with context.

It will be

showDialog(
  context: context,
  builder: (context) => const Dialog(
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading