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
相关产品推荐
相关产品推荐

