Last active
January 25, 2021 04:17
-
-
Save marcossevilla/13ea58e84f99cad37bc188fe10f7d5cd 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 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