简体   繁体   English

为什么 Flutterfire 在为 MacOS 编译时无法连接到 rtdb? (铬作品)

[英]Why can't Flutterfire connect to rtdb when compiling for MacOS? (Chrome works)

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).如果我按照flutterfire docs安装flutterfire_core库和realtime_db库,似乎我可以在为Chrome构建时连接到我的远程firebase数据库,但不能用于macOS(M1 2021 MB Pro)。

The simplest example I can give you is this (myApp is unchanged from the default flutter create ):我能给你的最简单的例子是这样的(myApp 与默认的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).这在我的本地机器上编译没有错误(macOS 和 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).在为 chrome 构建时,它能够更新遥控器,但在为 macOS 构建时却不能(它只是挂起,没有加载 UI,没有完成打印语句)。 (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.) (在此过程中,我确实将我的 macOS 构建设置更新到了 10.15,因为我被大喊将事情设置为 10.11。当我过去尝试过这个时,使用 10.12,事情也没有工作。)

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.我也尝试在此处克隆示例,它在我的机器上“工作”(带有警告),用于 Chrome 构建,但不适用于 macOS 构建。

Thank you for any help you could send my way :-)感谢您为我提供的任何帮助:-)

Output of flutter --version : 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 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.编辑:强调了我的主要问题,并删除了罗德里戈的评论已修复的警告消息。

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?幸运的是,我能够在 StackOverFlow 上找到另一个问题如何让 Flutter 项目在 MacOS 上运行以成功使用 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.很快就会提交申请。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flutterfire RTDB 在 android 上失败,但在 web 中工作 - flutterfire RTDB failed on android but work in web 如何解决 zsh: command not found: flutterfire in macOS? - How can i resolve zsh: command not found: flutterfire in macOS? 无法在 linux 上激活 flutterfire_cli - can't activate flutterfire_cli on linux 在我的颤振项目中运行“颤振配置”命令以连接火力基地时 - when runing 'flutterfire configure' command in my flutter project to connect firebase 为什么 Flutter 应用在​​安装“app-release.apk”时无法上网? 但它在调试模式下正常工作 - Why can't a Flutter application connect to the Internet when installing "app-release.apk"? But it works normally in debug mode 为什么我不使用来自 RTDB 的信息创建小部件? - Why aren't I creating a widget with the information from the RTDB? 如何在 Chrome 扩展中使用 FlutterFire - How to use FlutterFire in chrome extension 为什么我生成 APK 时无法连接到 API? - Why can't I connect to an API when I generate the APK? 无法使用 FireStore 为 flutterfire 创建单元测试,在初始化期间抛出,即使是最简单的测试 - Can't create unit test with FireStore for flutterfire, throws during init, even with simplest possible test 自定义 Flutterfire_UI package - 无法更改背景颜色或删除项目 - Customizing Flutterfire_UI package - Can't change background color or remove items
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM