Skip to content

Unnecessary local storage #4

@TiaanBothma

Description

@TiaanBothma

Instead of saving that the user is logged in with Shared Preferences, you can check Firebase Auth directly if the user is logged in/signed up. It is not better or worse. I personally just think its a bit better and cooler to directly check the Firebase Auth. Here is the code if you want to implement it:

StreamBuilder(
          stream: FirebaseAuth.instance.authStateChanges(),
          builder: (context, snapshot) {
            if (snapshot.connectionState == ConnectionState.waiting) {
              return Center(
                child: CircularProgressIndicator(),
              );
            } else if (snapshot.hasData) {
              return NavBar();
            } else if (snapshot.hasError) {
              return Center(
                child: Text('Something has gone Wrong'),
              );
            } else {
              return logInPage(context);
            }
          },
        ),

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions