Home:ALL Converter>Firebase not connecting

Firebase not connecting

Ask Time:2022-11-28T02:37:26         Author:edgam85

Json Formatter

I asked in a previous question and about setting up Firebase (FlutterFire) to connect with Flutter app. Despite following all instructions, still not having any joy. Main.Dart is as follow-

import 'package:flutter/material.dart';
import 'package:footballcrazyquiz/routes.dart';
import 'package:footballcrazyquiz/theme.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:provider/provider.dart';
import 'package:footballcrazyquiz/shared/shared.dart';
import 'package:footballcrazyquiz/services/services.dart';
import 'firebase_options.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );
  runApp(const App());
}

class App extends StatefulWidget {
  const App({super.key});

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

class _AppState extends State<App> {
  final Future<FirebaseApp> _initialization = Firebase.initializeApp();

  @override
  Widget build(BuildContext context) {
    return FutureBuilder(
      // Initialize FlutterFire:
      future: _initialization,
      builder: (context, snapshot) {
        // Check for errors
        if (snapshot.hasError) {
          
        }

        // Once complete, show your application
        if (snapshot.connectionState == ConnectionState.done) {
         return StreamProvider(
            create: (_) => FirestoreService().streamReport(),
            catchError: (_, err) => Report(),
            initialData: Report(),
            child: MaterialApp(
              debugShowCheckedModeBanner: true,
              routes: appRoutes,
              theme: appTheme
            ),
          );
        }

        // Otherwise, show something whilst waiting for initialization to complete
        return const MaterialApp(home: LoadingScreen());
      },
    );
  }
}

So far, I have installed Firebase CLI, Been able to logged in and configure FlutterFire in the project. I think I have initialize it as well. When doing Flutter Run, the app loads (using IOS Simulator). However the database (cloud firestore) and Firebase is not connecting to the app. Any help or suggestions will be greatly appreciated. Thank you.

Author:edgam85,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/74592764/firebase-not-connecting
yy