0

I'm trying to connect firebase to my flutter app. All the features are working fine, when running as a web app. But when I'm trying to run the mobile app, the app isn't running and showing an error message as below in the terminal.

E/flutter ( 4635): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: Null check operator used on a null value
E/flutter ( 4635): #0      MethodChannel.binaryMessenger
package:flutter/…/services/platform_channel.dart:142
E/flutter ( 4635): #1      MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:148
E/flutter ( 4635): #2      MethodChannel.invokeMethod
package:flutter/…/services/platform_channel.dart:331
E/flutter ( 4635): #3      MethodChannel.invokeListMethod
package:flutter/…/services/platform_channel.dart:344

Below are the dependencies, I'm using:

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  firebase_core: "0.5.1"
  firebase_auth: "0.18.2"
  cloud_firestore: "0.14.2"

Below is my main.dart file

Future<void> main() async {
  await Firebase.initializeApp();
  runApp(new MaterialApp(
    home: Login(),
  ));
}

While running Flutter channel:

PS C:\Users\hp\Documents\firebase\blog_app> flutter channel
Flutter channels:
  master
  dev
  beta
* stable
Thiluxan
  • 177
  • 4
  • 13

1 Answers1

0

change your pubspec.yaml as follows.

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  firebase_core: ^1.3.0
  firebase_auth: ^1.4.1
  cloud_firestore: ^2.2.2

and run flutter put get in terminal

Then run flutter channel stable, flutter upgrade and flutter clean in terminal

Lakmal Fernando
  • 1,420
  • 6
  • 14