[英]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.