Home > Blockchain >  Building a flutter app that uses firebase_auth which runs fine on phone but gives error while i run
Building a flutter app that uses firebase_auth which runs fine on phone but gives error while i run

Time:08-19

//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

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.

CodePudding user response:

unfortunately the firebase_auth plugin cause problems on the web.

if you are using flutterFire Plugin add this line of code

// 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

firebase_auth_web: ^4.2.3
  • Related