Created
January 25, 2021 04:18
-
-
Save marcossevilla/31bf812c9386c94d4d9a412cb02595cb to your computer and use it in GitHub Desktop.
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
/// * si usamos Riverpod | |
void main() => runApp(ProviderScope(child: MyApp())); | |
... | |
final userStateNotifierProvider = Provider<UserStateNotifier>( | |
(_) => UserStateNotifier(); | |
); | |
... | |
class MyWidget extends ConsumerWidget { | |
@override | |
Widget build(BuildContext context, ScopedReader watch) { | |
final userState = watch(userStateNotifierProvider.state); | |
return Scaffold( | |
body: Center( | |
child: Text('${userState.runtimeType}'), | |
), | |
floatingActionButton: FloatingActionButton( | |
onPressed: () { | |
context.read(userStateNotifierProvider).logIn(User()); | |
}, | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment