Last active
September 3, 2020 12:51
-
-
Save vlasentiy/ce5bbd1291cc2ebe0b82fb13814f1bb9 to your computer and use it in GitHub Desktop.
HookWidget
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyWidget extends HookWidget { | |
@override | |
Widget build(BuildContext context) { | |
final future = useMemoized(() { | |
// Future<String> callAsyncFetch() => Future.delayed(Duration(seconds: 3), () => "hi bro"); | |
callAsyncFetch(); // or your own async function | |
}); | |
return FutureBuilder<String>( | |
future: future, | |
builder: (context, snapshot) { | |
return Text(snapshot.hasData ? snapshot.data : 'Loading...'); | |
} | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment