void main() async {
WidgetsFlutterBinding.ensureInitialized();
if (kIsWeb) {
await Firebase.initializeApp(
options: const FirebaseOptions(
apiKey: "",
appId: "",
messagingSenderId: "",
projectId: "",
storageBucket: "",
),
);
} else {
await Firebase.initializeApp();
}
runApp(const MyApp());
}
Exception has occurred.
PlatformException (PlatformException(channel-error, Unable to establish connection on channel., null, null))
2
Answers
You should add your Firebase project to your Flutter App.
Here is the link how to do that https://firebase.google.com/docs/flutter/setup?platform=web.
After adding it properly, Firebase generates a config file then your code will be
Hope this helps.
In addition to above answer that’s because
is deprecated so becareful (Most of the content is using the old way).