0

If I follow the flutterfire docs to install the flutterfire_core library and the realtime_db library, it seems I can connect to my remote firebase database when building for Chrome, but not for macOS (M1 2021 MB Pro).

The simplest example I can give you is this (myApp is unchanged from the default flutter create):

import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_database/firebase_database.dart';
import 'firebase_options.dart';



void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );

  await FirebaseDatabase.instance.ref().update({
    "name": "Derek",
  }).then((_) {
        print("hello");
    })
    .catchError((error) {
        print("uhoh");
    });

  runApp(const MyApp());
}

This compiles with no errors on my local machine (neither macOS nor Chrome). When building for chrome, it was able to update the remote, but not when building for macOS (it just hangs, no UI is loaded, no print statements complete). (Along the way, I did update my macOS build settings to 10.15, because I was being yelled about having things set to 10.11. When I have tried this in the past, with 10.12, things didn't work either.)

What I have tried

I have also tried to clone the example here, and it "works" (with warnings) on my machine for the Chrome build but not the macOS build.

Thank you for any help you could send my way :-)

Output of flutter --version:

Framework • revision fb57da5f94 (2 weeks ago) • 2022-05-19 15:50:29 -0700
Engine • revision caaafc5604
Tools • Dart 2.17.1 • DevTools 2.12.2

Output of flutterfire -v

0.2.2+2

Edit: Added emphasis to my main problem, and removed a warning message that has since been fixed by Rodrigo's comment.

jo la
  • 1
  • 1
  • You need to add the name just as follow: [A Firebase App named "[DEFAULT]" already exists](https://stackoverflow.com/a/71644195/18141665) – Rodrigo Bustillos Jun 03 '22 at 20:33
  • Hello Rodrigo, that does help with the second error, but not with the first code not working. I am getting no error on compilation with the first code snippet I linked. Any tips? – jo la Jun 08 '22 at 20:28

1 Answers1

0

Luckily, I was able to find this other question on StackOverFlow How do I get a Flutter project running on MacOS to successfully use Firestore? . All I needed to do was add the right network entitlements to my project.

I've never done any desktop work before, never even considered this! I think they should add it to the docs somewhere tbh. Gonna submit a request for it soon.

jo la
  • 1
  • 1