Here is a simple example of code that navigator push for a form called. and pop for an answer. my goal is to make a pop of an object, not a string, but keeping it that simple st
Add await to receive the result from Future and return the value;
Future getFormData(BuildContext context) async {
final result = await Navigator.push(
context, MaterialPageRoute(builder: (context) => MyCustomForm()));
return Future.value(result);
}
Modify the FloatingActionButton
onPressed code to receive Future String
onPressed: () async {
final value = await getFormData(context);
setState(() {
data = value;
});
},