First of all, this is the error that I encountered:
/C:/Users/AppData/Local/Pub/Cache/hosted/pub.dev/firebase_auth_web-5.2.2/lib/firebase_auth_web.dart:92:45: Error: The argument type ‘Future Function()’ can’t be assigned to the parameter type ‘Future Function(App)?’.
- ‘Future’ is from ‘dart:async’.
- ‘App’ is from ‘package:firebase_core_web/src/interop/app.dart’ (‘/C:/Users/Grace%20Computer/AppData/Local/Pub/Cache/hosted/pub.dev/firebase_core_web-2.2.2/lib/src/interop/app.dart’).
app.dart:1
FirebaseCoreWeb.registerService(‘auth’, () async {
^
Failed to compile application.
I am trying to run a flutter login application on web. I have pasted the required creditentials as on the web>index.html file. The main.dart file looks like this:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: const FirebaseOptions(
apiKey: "AIzaSyDZvxw2LXy05hLkcH_fpPWWa5RzwVlbQro",
projectId: "messageapp-acf7a",
messagingSenderId: "72207922701",
appId: "1:72207922701:web:d84fe3144a7f2de5dd4744"
),
);
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: SignupPage(),
);
}
}
The relevant parts of pubspec.yaml file is this:
name: frontend_msngr
description: A new Flutter project.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: '>=2.19.2 <3.0.0'
dependencies:
flutter:
sdk: flutter
chat_bubbles:
firebase_core:
cupertino_icons: ^1.0.2
firebase_auth:
firebase_auth_web:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
flutter:
uses-material-design: true```
Since,the file that got the error is lib/firebase_auth_web.dart , I don't know how I passed incorrect parameters (as suggested by the error).
I tried changing the versions a bitbut it didn't work for me.
3
Answers
This I have used in the past and worked well
Snippit of the pubsec file
Run
You need to upgrade your version of
firebase_auth
to the last one (4.3.0 mars 2023) in yourpubspec.yaml
. I had to downgradeintl
to the version0.17.0
to fit with the dependence withfirebase_auth 4.3.0
. And after just runflutter pub get
.flutter pub upgrade --major-versions
didn’t upgrade the packages for me but just notice me that there is new versions for some of my packages.