Skip to content

Instantly share code, notes, and snippets.

@rapPayne
Last active June 3, 2019 22:52
Show Gist options
  • Select an option

  • Save rapPayne/c77adb98cb8c7749a205ae04fabf13bd to your computer and use it in GitHub Desktop.

Select an option

Save rapPayne/c77adb98cb8c7749a205ae04fabf13bd to your computer and use it in GitHub Desktop.
To get a value out of an async callback, you set an external variable
class FooState extends State<FooComponent> {
String _firstName; // <-- A variable known by the whole class
Widget build(BuildContext context) {
// return a widget
}
void _myCallback(String someVar) {
_firstName = someVar; // <-- Getting a value OUT of an async callback
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment