Skip to content

Instantly share code, notes, and snippets.

@marcossevilla
Created January 25, 2021 04:18
Show Gist options
  • Save marcossevilla/31bf812c9386c94d4d9a412cb02595cb to your computer and use it in GitHub Desktop.
Save marcossevilla/31bf812c9386c94d4d9a412cb02595cb to your computer and use it in GitHub Desktop.
/// * 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