0

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

1 Answer 1

0

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",//<<==
),
...
Sign up to request clarification or add additional context in comments.

10 Comments

Hi I have activated firebase cli and have linked my project.
From your code it shows you haven't added yet. check updated answer
Package flutterfire_cli is currently active at version 0.2.7.
Am I missing something?
Yes follow through the link please.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.