I am very new to Dart, and coding in general. I have produced this code after watching tutorials on YouTube. For the most part, I have been able to troubleshoot most of my problems on my own, yet I cannot figure out my most recent errors. I have using firebase for authentication as soon as I write code in main.dart
Future <void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp().then((value) => Get.put(AuthController()));
runApp(const MyApp());
}
and if i run the app, I get the following error
E/flutter ( 5661): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception:
[core/not-initialized] Firebase has not been correctly initialized.
E/flutter ( 5661):
E/flutter ( 5661): Usually this means you've attempted to use a Firebase service before
calling `Firebase.initializeApp`.
E/flutter ( 5661):
E/flutter ( 5661): View the documentation for more information:
https://firebase.flutter.dev/docs/overview#initialization
E/flutter ( 5661):
E/flutter ( 5661): #0 MethodChannelFirebase.initializeApp (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:99:9)
E/flutter ( 5661): <asynchronous suspension>
E/flutter ( 5661): #1 Firebase.initializeApp
(package:firebase_core/src/firebase.dart:40:31)
E/flutter ( 5661): <asynchronous suspension>
E/flutter ( 5661): #2 main (package:definer_lms/main.dart:10:3)
E/flutter ( 5661): <asynchronous suspension>
E/flutter ( 5661):
My android/app/build.gradle has the following config:
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "getin.******.definer_lms" // edited for security purpose
minSdkVersion 23
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
.....
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation platform('com.google.firebase:firebase-bom:29.1.0')
implementation 'com.android.support:multidex:1.0.3'
}
.....
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.google.gms.google-services'
}
My android/build.gradle has the following config:
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.10'
}
can someone please find what is wrong here?