Skip to content

Commit

Permalink
⚡ Moving Firebase initialize to bloc. So it loads faster
Browse files Browse the repository at this point in the history
  • Loading branch information
Cavitedev committed Feb 2, 2021
1 parent 563eba8 commit 9693f09
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/application/auth/auth_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:async';
import 'package:auto_route/auto_route.dart';
import 'package:bloc/bloc.dart';
import 'package:dartz/dartz.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/cupertino.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart';
Expand All @@ -25,6 +26,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
) async* {
yield* event.map(
getUser: (e) async* {
await Firebase.initializeApp();
final Option<User> user = authDao.getSignedUser();
yield user.fold(
() => const AuthState.unathenticated(),
Expand Down
2 changes: 0 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:auto_route/auto_route.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
Expand All @@ -15,7 +14,6 @@ import 'core/app_localization.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
configureInjection(Environment.prod);
await Firebase.initializeApp();
runApp(MyApp());
}

Expand Down

0 comments on commit 9693f09

Please sign in to comment.