Flutter & Firebase App Tutorial #8 - Provider Package

Net Ninja · 138K views · 2019 · 7:56

Open on YouTube

Software (other)tutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it as the source tutorial for wiring Firebase auth state into Flutter with StreamProvider, both when recommending it and when debugging code built from it.

Recommended by 1 people across 1 different months, 2020 to 2021.

What it is

Part 8 of Net Ninja's Flutter and Firebase series. It introduces the Provider package and sets up a StreamProvider that feeds the user's auth status into the widget tree. The video is about eight minutes and has a linked GitHub repo with the course files.

What people said

Recommends CoderUni · 2020-08 · Stack Overflow · on “How to switch between Auth screen and Home screen based on bool value?”

you would want to use a streamProvider and not changenotifierprovider. Take a look at this: [this video] . Don't forget to click on the github link in the description.

Cites Iain McHugh · 2020-07 · Stack Overflow · on “Flutter StreamProvider not updating after pushReplacement called”

I have a flutter app that implements firebase authentication. After following this [this video] tutorial my main.dart file looks like this: class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return StreamProvider<User>.value( catchError: (_, err) => null, value: AuthService().user, child: MaterialApp( home: Wrapper(), ), ); } } Where the value: AuthService().user is returned as a stream by the following get function : // auth change user stream Stream<User> get user { return _auth.onAuthStateChanged.map( (FirebaseUser user) => _userFromFirebaseUser(user), ); } User _userFromFirebaseUser(FirebaseUser user) { return user != null ? User(uid: user.uid) : null; } And

Cites Cedric · 2021-11 · Stack Overflow · on “StreamProvider: Error: Could not find the correct Provider<User> above this App Widget”

I'm using StreamProvider from the provider package for auth functionality in my flutter-firebase app, just like it is explained in this tutorial [this video] . When trying to run my app, I get an error message, with a suggestion how to do it correctly, but my code IS written in the way that is suggested. void main() { WidgetsFlutterBinding.ensureInitialized(); runApp(FirebaseWrapper()); runApp(App()); } class FirebaseWrapper extends StatelessWidget { // Create the initialization Future outside of build(): final Future<FirebaseApp> _initialization = Firebase.initializeApp(); // final Future<void> _initSharedPrefs = SharedPrefsHelper().initSharedPrefsInstance(); @override Widget build(BuildContext