FLUTTER – TypeError: Class constructor IndexedDBLocalPersistence cannot be invoked without ‘new’

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(),
      ),
    );
  }
}

Recognized by Google Cloud Collective

11

As Tahsin Emre suggested in a comment; if this error occurs when updating to Flutter 3.19.0, it can be solved by upgrading the various Firebase package versions. The problem was solved for me with the following versions in pubspec.yaml:

 dependencies:
  firebase_core: ^2.25.4
  cloud_functions: ^4.6.0
  firebase_auth: ^4.17.5
  cloud_firestore: ^4.15.5

1

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:

  1. Run flutter channel stable to make sure that you are currently using a stable channel and not a beta
  2. Run flutter upgrade to update to the latest version of the SDK, Dart SDK will update accordingly.
  3. Run flutter --version to check both your Flutter SDK version and your Dart SDK version.
  4. Make sure that your pubspec.yaml includes you Dart SDK version in the version constraints specified. (Example: if your Dart SDK version shown in the output provided from flutter --version is 2.19.4, make sure that your code looks something like this sdk: '>=2.19.0 <4.0.0' at least).
  5. In my case scenario, the issue is solved using Flutter SDK version 3.7.0 with Dart SDK version 2.19.0, however this is not the latest version, but I am confident that even with the last stable version ( Flutter SDK 3.16.5) the issue shouldn’t occur.

Hopefully this solves the issue!

Just downgrade from beta to stable.

2

There is no need to downgrade to a previous version. You can use the latest release which by the time (2024-03-15) I’m writing this answer is 3.19.0. So to solve the issue, please upgrade the Firebase package to the latest versions inside the pubspec.yaml file too:

dependencies:
  firebase_core: ^2.27.1
  cloud_functions: ^4.6.9
  firebase_auth: ^4.17.9
  cloud_firestore: ^4.15.9

I got these versions from firebase_core, cloud_functions, firebase_auth and cloud_firestore packages for Flutter. So I recommend always keeping your packages up to date.

Recognized by Google Cloud Collective

run

flutter pub upgrade --major-versions

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật