I am new in Flutter and I am trying receive data with a Dialog. When a click in textField the error of image2 appear...
You’re trying to access a context that isn’t probably available. That happens because you’ve assigned your Dialog
to a var
and afterwards use a different context (the one from your dialog builder).
Either create your dialog directly after your return
in the builder or make it a method instead that returns a Dialog
and pass it a BuildContext
parameter.
Widget myDialog(BuildContext context) => Dialog(/*your dialog here*/);
This is also a more convenient Flutter practice. You should use methods that return widgets instead of assigning it to variables.