Skip to content

Instantly share code, notes, and snippets.

@marcossevilla
Last active January 25, 2021 04:17
Show Gist options
  • Save marcossevilla/13ea58e84f99cad37bc188fe10f7d5cd to your computer and use it in GitHub Desktop.
Save marcossevilla/13ea58e84f99cad37bc188fe10f7d5cd to your computer and use it in GitHub Desktop.
/// * si usamos Provider
void main() => runApp(
StateNotifierProvider<UserStateNotifier, UserState>(
create: (_) => UserStateNotifier(),
child: MyApp(),
),
);
...
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final userState = context.watch<UserStateNotifier>();
return Scaffold(
body: Center(
child: Text('${userState.runtimeType}'),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
context.read<UserStateNotifier>().logIn(User());
},
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment