You need to enable JavaScript to run this app. Flutter 2.0下firebase_auth 1.0.1调用useEmulator报未定义错误
优惠活动
大模型
产品
解决方案
定价
更多

Flutter 2.0下firebase_auth 1.0.1调用useEmulator报未定义错误

问题与排查结论

复现场景

  • 开发环境:Flutter 2.0.0稳定版,未启用空安全
  • 引入依赖:firebase_core: ^1.0.2、firebase_auth: ^1.0.1
  • 执行代码:_auth = await FirebaseAuth.instance.useEmulator('http://localhost:9099');
  • 触发报错:the method 'useEmulator' isn't defined for the type 'FirebaseAuth'

初始疑问

查阅官方文档以及pub.dev上对应包的示例,均显示存在useEmulator方法,疑惑该方法是否在新版本中被移除且未同步更新文档,或是存在新的替代实现方案。

排查结果

  • 根因:本地运行时使用了缓存的依赖版本,未正确拉取到指定的firebase_core: ^1.0.2、firebase_auth: ^1.0.1版本
  • 验证结论:上述两个指定版本本身原生支持useEmulator方法,不存在方法被移除、文档未同步的问题。

内容的提问来源于stack exchange,提问作者Philip Kalela

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.27 10:45:03