微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在flutter中无法访问firestore本地模拟器套件

如何解决在flutter中无法访问firestore本地模拟器套件

我无法在 Flutter 中连接到 Firestore 模拟器。它反映在主 Firebase 控制台中。 我正在使用安卓模拟器

void initState() {
super.initState();
firestore = FirebaseFirestore.instance;
firestore.settings = Settings(
  host: '10.0.2.2:8080',sslEnabled: false,);

firestore.collection('tokens').add({'data': 16});
}

我根据文档配置了模拟器。

─────────────────────────────────────────────────────────────┐
│ ✔  All emulators ready! It is Now safe to connect your app │
│ i  View Emulator UI at http://localhost:4000                │
└─────────────────────────────────────────────────────────────┘

┌───────────┬────────────────┬─────────────────────────────────┐
│ Emulator  │ Host:Port      │ View in Emulator UI             │
├───────────┼────────────────┼─────────────────────────────────┤
│ Functions │ localhost:5001 │ http://localhost:4000/functions │
├───────────┼────────────────┼─────────────────────────────────┤
│ Firestore │ localhost:8080 │ http://localhost:4000/firestore │
└───────────┴────────────────┴─────────────────────────────────┘
  Emulator Hub running at localhost:4400
  Other reserved ports: 4500

Issues? Report them at https://github.com/firebase/firebase-tools/issues and attach the *-debug.log files.

!  It looks like you're trying to access functions.config().functions but there is no value there. You can learn more about setting up config here: https://firebase.google.com/docs/functions/local-emulator

Firebase 版本:

firebase --version 
9.11.0

firebase.json

 {
  "emulators": {
    "functions": {
      "port": 5001
    },"ui": {
      "enabled": true
    },"firestore": {
      "port": 8080
    }
  }
}

http://localhost:4000/firestore 上没有显示数据,即使更改了设置(主机),数据也会反映在主 Firebase 控制台上。

我有时会收到此错误

MissingPluginException (MissingPluginException(No implementation found) 对于方法 DocumentReference#set 在通道上 plugins.Flutter.io/firebase_firestore))

pubspec.yaml

dependencies:
  Flutter:
    sdk: Flutter
cupertino_icons: ^1.0.1
  firebase_auth: ^0.20.1
  equatable: ^1.2.6
  bloc: ^6.1.3
  Flutter_bloc: ^6.1.3
  firebase_core: ^0.7.0
  cloud_firestore: ^0.16.0
  google_sign_in: "^4.5.1"
  Flutter_rating_bar: ^4.0.0
  image_picker: ^0.6.7+17
  firebase_storage: ^7.0.0
  syncfusion_Flutter_calendar: ^18.4.42
  simple_time_range_picker: ^0.0.2
  firebase_messaging: ^8.0.0-dev.15
  cloud_functions: ^0.9.0

非常感谢您的帮助。谢谢

解决方法

您需要使用最新版本的依赖项。您可以查看最新版本 here

更新依赖项后,您必须运行:

flutter clean
flutter packages get
,

我的问题是生产数据仍在我的应用程序的缓存中。重新安装后就成功了!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?