tenhobi / flashcards

FIT CTU · BI-SP1 · BI-SP2 · B172 · B181 – software team project
MIT License
35 stars 8 forks source link

Improve auth user data access #85

Closed tenhobi closed 6 years ago

tenhobi commented 6 years ago

Current solution

    return FutureBuilder<FirebaseUser>(
      future: AppData.of(context).authBloc.user,
      builder: (BuildContext context, AsyncSnapshot<FirebaseUser> snapshot) {});

might not be the best one. The task is to find better solution, maybe somehow add this functionality inside AppData?

tenhobi commented 6 years ago

Explore InheritedWidget on http://fluttersamples.com/.

tenhobi commented 6 years ago

@Kenny11CZ @stasidom @vojtechdalecky @michaldrabina now if you wanna access state or blocs, you will do something like

class CustomDrawer extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final container = StateContainer.of(context); // initialization

    return Drawer(
      child: Column(
        children: <Widget>[
          UserAccountsDrawerHeader(
            accountName: Text(container.authenticationBloc.user.displayName), // usage
            accountEmail: Text(container.authenticationBloc.user.email), // usage

The same ruleas apply to other methods which returns Widget.