Reputation: 1
Hi guys first time here on stack overflow.
I am currently building an app using flutter with firebase as the backend.
My target platforms are Windows and android
The android app builds fine
The windows app throws :
ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(channel-error, Unable to establish connection on channel., null, null)
this only happens when I use :
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
I have also tried :
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: const FirebaseOptions(
apiKey: "myapi",
appId: "appid",
messagingSenderId: "senderid",
projectId: "projectid",
storageBucket: "buckedid",
databaseURL: 'databaseurl',
));
As stated this works fine on android but not windows
I have the latest dependencies for Firebase
I have tried flutter pub outdated and it returns no Firebase dependencies
I have tried flutter pub upgrade
I have tried flutter clear
Upvotes: 0
Views: 589
Reputation: 1427
Hey if you are using the the latest versions of firebase you'd want to follow through the newest way of initializing firebase with firebase CLI. See this https://firebase.flutter.dev/docs/cli starting off by activating firebase cli
have something like this
// Import the generated file
import 'firebase_options.dart'; //this provides the current platform options via the currentPlatform getter from the DefaultFirebaseOptions class
...
await Firebase.initializeApp(
options: const FirebaseOptions(
apiKey: "API KEY",//<<==
appId: "ID",//<<==
messagingSenderId: "IF ANY",//<<==
projectId: "Project ID",//<<==
),
...
Upvotes: 0