Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

courses/flutter-firebase/auth-stream/ #829

Open
utterances-bot opened this issue Jun 28, 2022 · 6 comments
Open

courses/flutter-firebase/auth-stream/ #829

utterances-bot opened this issue Jun 28, 2022 · 6 comments

Comments

@utterances-bot
Copy link

Auth Stream

Listen to the current Firebase user

https://fireship.io/courses/firestore-data-modeling/basics-read-documents/

Copy link

Snippet code does not match what is shown in the video.

import 'package:quizapp/shared/shared.dart'; < Not found
LoadingScreen() < Not found
ErrorMessage < Not found

Am I missing something here?

Copy link

Hi @eikowagenknecht, you are right. The code snippet considers the LoadingScreen and the ErrorMessage being both Custom Widgets. For an actual app, that's what you will probably do it, but in the video lesson the instructor is just using Text Widgets in place of those.

Try creating 2 Custom Stateless Widgets, name them LoadingScreen and ErrorMessage and make them both return a simple Text Widget with according text. Then your Code Editor will probably suggest to import the respective files you created the Custom Widgets.

Copy link

jaedag commented Aug 18, 2022

If you are running into the error that says Null check operator used on a null value then copy this code for your main.dart file. Took me while to find this answer

import 'package:fireship_quizapp/home/home.dart';
import 'package:fireship_quizapp/routes.dart';
import 'package:fireship_quizapp/theme.dart';
import 'package:flutter/material.dart';
// Import the firebase_core plugin
import 'package:firebase_core/firebase_core.dart';
import 'services/firebase_options.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  runApp(const App());
}

/// We are using a StatefulWidget such that we only create the [\Future] once,
/// no matter how many times our widget rebuild.
/// If we used a [\StatelessWidget], in the event where [\App] is rebuilt, that
/// would re-initialize FlutterFire and make our application re-enter loading state,
/// which is undesired.
///
class App extends StatefulWidget {
  const App({Key? key}) : super(key: key);

  @override
  State<App> createState() => _AppState();
}

class _AppState extends State<App> {
  /// The future is part of the state of our widget. We should not call `initializeApp`
  /// directly inside [build].
  final Future<FirebaseApp> _initialization = Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      routes: appRoutes,
      theme: appTheme,
      home: FutureBuilder(
        // Initialize FlutterFire:
        future: _initialization,
        builder: (context, snapshot) {
          // Check for errors
          if (snapshot.hasError) {
            return const Text('error');
          }

          // Once complete, show your application
          if (snapshot.connectionState == ConnectionState.done) {
            return const HomeScreen();
          }

          // Otherwise, show something whilst waiting for initialization to complete
          return const Text('loading');
        },
      ),
    );
  }
}

Copy link

jaedag commented Aug 18, 2022

And also delete the '/' route from the appRoutes object

Copy link

shubhjagani commented Sep 6, 2022

When trying to flutter run i get this issue

Error: Required named parameter 'auth' must be provided.
_factory.delegateFor(
^

FAILURE: Build failed with an exception.

Copy link

Does Anybody get this error?

The following FirebaseException was thrown building HomeScreen(dirty):
[core/no-app] No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants