简体   繁体   English

构建一个使用 firebase_auth 的 flutter 应用程序,它在手机上运行良好,但在我在 web 上运行时出错,说 http_parser 路径丢失

[英]Building a flutter app that uses firebase_auth which runs fine on phone but gives error while i run on web, says http_parser path missing

//CODE //代码

import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:webfirebase/firebase_options.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
  runApp(const MyApp());
}

//pubspec.yaml //pubspec.yaml

cupertino_icons: ^1.0.2
firebase_core: ^1.20.1
firebase_auth: ^3.6.3

//ERROR //错误

/C:/src/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_web-4.2.3/lib/src/interop/auth.dart:14:8: Error: Error when reading '/C:/src/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/http_parser-4.0.1/lib/http_parser.dart': The system cannot find the path specified.

import 'package:http_parser/http_parser.dart';
       ^
/C:/src/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_web-4.2.3/lib/src/interop/auth.dart:304:28: Error: The method 'parseHttpDate' isn't defined for the class 'IdTokenResult'.
 - 'IdTokenResult' is from 'package:firebase_auth_web/src/interop/auth.dart' ('/C:/src/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_web-4.2.3/lib/src/interop/auth.dart').
Try correcting the name to the name of an existing method, or defining a method named 'parseHttpDate'.
  DateTime get authTime => parseHttpDate(jsObject.authTime);
                           ^^^^^^^^^^^^^
/C:/src/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_web-4.2.3/lib/src/interop/auth.dart:311:34: Error: The method 'parseHttpDate' isn't defined for the class 'IdTokenResult'.
 - 'IdTokenResult' is from 'package:firebase_auth_web/src/interop/auth.dart' ('/C:/src/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_web-4.2.3/lib/src/interop/auth.dart').
Try correcting the name to the name of an existing method, or defining a method named 'parseHttpDate'.
  DateTime get expirationTime => parseHttpDate(jsObject.expirationTime);
                                 ^^^^^^^^^^^^^
/C:/src/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_web-4.2.3/lib/src/interop/auth.dart:314:32: Error: The method 'parseHttpDate' isn't defined for the class 'IdTokenResult'.
 - 'IdTokenResult' is from 'package:firebase_auth_web/src/interop/auth.dart' ('/C:/src/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_web-4.2.3/lib/src/interop/auth.dart').
    Try correcting the name to the name of an existing method, or defining a method 
 named 'parseHttpDate'.
  DateTime get issuedAtTime => parseHttpDate(jsObject.issuedAtTime);
                               ^^^^^^^^^^^^^
Failed to compile application.

unfortunately the firebase_auth plugin cause problems on the web.不幸的是,firebase_auth 插件导致 web 出现问题。

if you are using flutterFire Plugin add this line of code如果您使用的是 flutterFire 插件,请添加这行代码

// Disable persistence on web platforms
await FirebaseAuth.instance.setPersistence(Persistence.NONE);

or you can add the following dependency https://pub.dev/packages/firebase_auth_web或者您可以添加以下依赖项 https://pub.dev/packages/firebase_auth_web

firebase_auth_web: ^4.2.3

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 flutter 中的 firebase_auth/无效电话号码? - firebase_auth/invalid-phone-number in flutter? 如何在 flutter web 应用程序中正确添加和启用 firebase_auth? - How does one properly add and enable firebase_auth in a flutter web app? 如何在 firebase_auth 中更新 FirebaseUser 的电话号码? - How do I update a FirebaseUser's phone number in firebase_auth? Dart Flutter 顺序 firebase_auth 错误 - Dart Flutter sequential firebase_auth errors 如何使用 firebase_auth 包修复 flutter 应用程序中的 FirebaseAuth.instance.currentUser()? 它总是返回 null - How to fix FirebaseAuth.instance.currentUser() in flutter app using firebase_auth package? It is always returning null 应用程序:编译应用程序 flutter 时出现编译错误 - app:compileFlutterBuildRelease error while building app flutter OTP [firebase_auth/未知] null - OTP [firebase_auth/unknown] null Flutter web firebase auth signInWithPhoneNumber 在发布模式下显示错误“captcha-check-failed” - Flutter web firebase auth signInWithPhoneNumber showing error "captcha-check-failed" in release mode 由于 Firebase 电话身份验证的 Flutter 应用程序中出现“令牌不匹配”身份验证错误,Apple 拒绝了该应用程序 - Apple rejected the app due to "Token mismatch" authentication error in a Flutter app with Firebase Phone Authentication Flutter Web Firebase 授权用户刷新后注销 - Flutter Web Firebase Auth user is logged out after refresh
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM