Team,
I have been initializing Firebase like this since I started by following this flutter documentation, but for some reason this throws an error in the debugger, as follows:
TypeError: Class constructor IndexedDBLocalPersistence cannot be
invoked without ‘new’
Could you please help me rectify this?
Here is the Flutter code:
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:pace/firebase_options.dart';
import 'package:pace/pages/auth_page.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(
body: AuthPage(),
),
);
}
}
2
Answers
I occurred into the same error while trying to release my app on web and after a few attempts I have eventually found a solution for it.
Here are the steps I have performed:
flutter channel stable
to make sure that you are currently using astable
channel and not abeta
flutter upgrade
to update to the latest version of the SDK, Dart SDK will update accordingly.flutter --version
to check both your Flutter SDK version and your Dart SDK version.pubspec.yaml
includes you Dart SDK version in the version constraints specified. (Example: if your Dart SDK version shown in the output provided fromflutter --version
is 2.19.4, make sure that your code looks something like thissdk: '>=2.19.0 <4.0.0'
at least).Hopefully this solves the issue!
Just downgrade from beta to stable.