You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter Web集成Firebase时firebase_auth_web.dart位置参数过多问题解决

Flutter Web Firebase认证模块错误修复方案

问题说明

构建对接Firebase的Flutter Web应用时,firebase_auth_web.dart文件第94行出现认证模块错误,错误提示为:调用FirebaseCoreWeb.registerService时传入了过多位置参数。

修复步骤

将原代码中传入的位置参数改为命名参数ensurePluginInitialized即可解决问题。

原错误代码

static void registerWith(Registrar registrar) {
    FirebaseCoreWeb.registerService('auth', (firebaseApp) async {
      final authDelegate = auth_interop.getAuthInstance(firebaseApp);
      // if localhost, and emulator was previously set in localStorage, use it
      if (window.location.hostname == 'localhost' && kDebugMode) {
        final String? emulatorOrigin =
            window.sessionStorage[getOriginName(firebaseApp.name)];

修改后正确代码

static void registerWith(Registrar registrar) {
    FirebaseCoreWeb.registerService('auth', ensurePluginInitialized: (firebaseApp) async {
      final authDelegate = auth_interop.getAuthInstance(firebaseApp);
      // if localhost, and emulator was previously set in localStorage, use it
      if (window.location.hostname == 'localhost' && kDebugMode) {
        final String? emulatorOrigin =
            window.sessionStorage[getOriginName(firebaseApp.name)];

内容的提问来源于stack exchange,提问作者Saúl Galindo González

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.19 02:52:03