So firstly, i have spend alot of time to connect the Flutter the Firebase, I’m not getting the previous errors but also i dont know if its connected or not. First the errors was in build.gradle file. That has been solved i guess. Now its showing "Skipped XX Frames: The application may be doing too much work on its main thread."
I’m providing all the necessary code. I hope it can be fixed, i’m on it for so many days.
Main.dart
import 'package:firebase_core/firebase_core.dart';
import 'package:ableeasefinale/pages/UI/parentPage.dart';
import 'package:flutter/material.dart';
import 'theme/theme.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: const ParentPage(),
theme: lightMode,
darkTheme: darkMode,
themeMode: ThemeMode.dark,
);
}
}
android/build.gradle
buildscript {
ext.kotlin_version = '1.9.20'
repositories {
google()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.4.1'
}
}
android/app/build.gradle
plugins{
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
id 'com.google.gms.google-services'
}
dependencies {
implementation platform('com.google.firebase:firebase-bom:32.7.2')
}
In the last run, debug was also showing following message: ‘Skipped XX Frames: The application may be doing too much work on its main thread.’
If someone knows a better tutorial to connect it, please provide, it will be helpful
2
Answers
You need to add FirebaseOptions in main() when initializing firebase:
better approach would be to reconfigure the firebase to your project using FlutterFire Cli, it will generate firebase_options.dart file according to your selected platform:
await Firebase.initializeApp(
options: FirebaseOptions(
apiKey: "ApiKey",
appId: "AppId",
messagingSenderId: "MessagingSenderId",
projectId: "ProjectId",
),
);
You need to add this in main()