I'm trying to display a dialog popup whenever the user clicks on a button. However, whenever I test this the dialog not displayed and an exception has been thrown in Chrome console.
Exception message:
Uncaught TypeError: Cannot read properties of null (reading 'toString')
at Object.a9 (main.dart.js:16645)
at Object.DV (main.dart.js:4402)
at main.dart.js:65305
at b7F.a (main.dart.js:20524)
at b7F.$2 (main.dart.js:49122)
at Object.l (main.dart.js:20510)
at aUl.$0 (main.dart.js:65307)
at NQ.YO (main.dart.js:80893)
at Object.eval (eval at bio (main.dart.js:13895), <anonymous>:3:55)
at je.a5X (main.dart.js:76162)
and here's my dart code:
ElevatedButton(
onPressed: () async {
showDialog(context: context, builder: (_){
return const AlertDialog(title: Text("Test"),);
});
},
child: const Text("Test")
)
I tried to put await
before showDialog
but still the problem persists.