Skip to content

FirebaseDatabaseQueryBuilder: java.lang.Long cannot be cast to java.lang.Integer with the latest firebase_database 12.1.0 #571

@atanasyordanov21

Description

@atanasyordanov21

Is there an existing issue for this?

  • I have searched the existing issues and found no duplicates.

What plugin is this bug for?

Firebase UI Database

What platform(s) does this bug affect?

Android

List of dependencies used.

flutter pub deps -s list
Dart SDK 3.10.1
Flutter SDK 3.38.3

dependencies:

  • flutter 0.0.0
    • characters 1.4.0
    • collection 1.19.1
    • material_color_utilities 0.11.1
    • meta 1.17.0
    • vector_math 2.2.0
    • sky_engine any
  • cupertino_icons 1.0.8
  • firebase_core 4.2.1
    • firebase_core_platform_interface ^6.0.2
    • firebase_core_web ^3.3.0
    • flutter any
    • meta ^1.8.0
  • firebase_database 12.1.0
    • firebase_core ^4.2.1
    • firebase_core_platform_interface ^6.0.2
    • firebase_database_platform_interface ^0.3.0
    • firebase_database_web ^0.2.7+1
    • flutter any
  • firebase_ui_database 2.0.1
    • collection ^1.18.0
    • firebase_database ^12.0.3
    • firebase_ui_localizations ^2.0.1
    • flutter any

dev dependencies:

  • flutter_lints 6.0.0
    • lints ^6.0.0

transitive dependencies:

  • _flutterfire_internals 1.3.64
    • collection ^1.0.0
    • firebase_core ^4.2.1
    • firebase_core_platform_interface ^6.0.2
    • flutter any
    • meta ^1.8.0
  • async 2.13.0
    • collection ^1.15.0
    • meta ^1.3.0
  • boolean_selector 2.1.2
    • source_span ^1.8.0
    • string_scanner ^1.1.0
  • characters 1.4.0
  • clock 1.1.2
  • collection 1.19.1
  • fake_async 1.3.3
    • clock ^1.1.0
    • collection ^1.15.0
  • firebase_core_platform_interface 6.0.2
    • collection ^1.0.0
    • flutter any
    • flutter_test any
    • meta ^1.8.0
    • plugin_platform_interface ^2.1.3
  • firebase_core_web 3.3.0
    • firebase_core_platform_interface ^6.0.2
    • flutter any
    • flutter_web_plugins any
    • meta ^1.8.0
    • web ^1.0.0
  • firebase_database_platform_interface 0.3.0
    • _flutterfire_internals ^1.3.64
    • collection ^1.14.3
    • firebase_core ^4.2.1
    • flutter any
    • meta ^1.8.0
    • plugin_platform_interface ^2.1.3
  • firebase_database_web 0.2.7+1
    • collection ^1.18.0
    • firebase_core ^4.2.1
    • firebase_core_web ^3.3.0
    • firebase_database_platform_interface ^0.3.0
    • flutter any
    • flutter_web_plugins any
  • firebase_ui_localizations 2.0.1
    • flutter any
    • flutter_localizations any
    • path ^1.8.3
  • flutter_localizations 0.0.0
    • flutter any
    • intl 0.20.2
    • path 1.9.1
  • flutter_test 0.0.0
    • flutter any
    • test_api 0.7.7
    • matcher 0.12.17
    • path 1.9.1
    • fake_async 1.3.3
    • clock 1.1.2
    • stack_trace 1.12.1
    • vector_math 2.2.0
    • leak_tracker_flutter_testing 3.0.10
    • collection 1.19.1
    • meta 1.17.0
    • stream_channel 2.1.4
  • flutter_web_plugins 0.0.0
    • flutter any
  • intl 0.20.2
    • clock ^1.1.0
    • meta ^1.3.0
    • path ^1.8.0
  • leak_tracker 11.0.2
    • clock ^1.1.1
    • collection ^1.15.0
    • meta ^1.8.0
    • path ^1.8.3
    • vm_service >=11.10.0 <16.0.0
  • leak_tracker_flutter_testing 3.0.10
    • flutter any
    • leak_tracker >=11.0.1 <12.0.0
    • leak_tracker_testing >=3.0.1 <4.0.0
    • matcher ^0.12.16
    • meta ^1.8.0
  • leak_tracker_testing 3.0.2
    • leak_tracker >=9.0.0 <12.0.0
    • matcher ^0.12.16
    • meta ^1.11.0
  • lints 6.0.0
  • matcher 0.12.17
    • async ^2.10.0
    • meta ^1.8.0
    • stack_trace ^1.10.0
    • term_glyph ^1.2.0
    • test_api >=0.5.0 <0.8.0
  • material_color_utilities 0.11.1
    • collection ^1.15.0
  • meta 1.17.0
  • path 1.9.1
  • plugin_platform_interface 2.1.8
    • meta ^1.3.0
  • sky_engine 0.0.0
  • source_span 1.10.1
    • collection ^1.15.0
    • path ^1.8.0
    • term_glyph ^1.2.0
  • stack_trace 1.12.1
    • path ^1.8.0
  • stream_channel 2.1.4
    • async ^2.5.0
  • string_scanner 1.4.1
    • source_span ^1.8.0
  • term_glyph 1.2.2
  • test_api 0.7.7
    • async ^2.5.0
    • boolean_selector ^2.1.0
    • collection ^1.15.0
    • meta ^1.14.0
    • source_span ^1.8.0
    • stack_trace ^1.10.0
    • stream_channel ^2.1.0
    • string_scanner ^1.1.0
    • term_glyph ^1.2.0
  • vector_math 2.2.0
  • vm_service 15.0.2
  • web 1.1.1

Steps to reproduce

In your example simply replace FirebaseDatabaseDataTable with:

         FirebaseDatabaseQueryBuilder(
            query: ref,
            builder: (context, snapshot, _) {
              if (snapshot.hasError) {
                print(snapshot.error);
                return Text(snapshot.error.toString());
              }
              final users = snapshot.docs;
              return ListView.builder(
                itemCount: users.length,
                itemBuilder: (context, index) {
                  final user = users[index].value as Map;
                  return ListTile(
                    title: Text(user['name'] ?? 'No Name'),
                  );
                },
              );
            },
          ),

Expected Behavior

I expect the see the data records from the database.

Actual Behavior

FirebaseDatabaseQueryBuilder doesn't display any data when the package firebase_database is the latest version 12.1.0. Instead, snapshot.hasError is true, and snapshot.error outputs the following:

PlatformException(ClassCastException, java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer, Cause: null, Stacktrace: java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
	at io.flutter.plugins.firebase.database.FirebaseDatabasePlugin.queryObserve(FirebaseDatabasePlugin.kt:942)
	at io.flutter.plugins.firebase.database.FirebaseDatabaseHostApi$Companion.setUp$lambda$19$0(GeneratedAndroidFirebaseDatabase.g.kt:863)
	at io.flutter.plugins.firebase.database.FirebaseDatabaseHostApi$Companion.$r8$lambda$J08JcxipsqVfV8tkx4fTK8rOYj4(Unknown Source:0)
	at io.flutter.plugins.firebase.database.FirebaseDatabaseHostApi$Companion$$ExternalSyntheticLambda9.onMessage(D8$$SyntheticClass:0)
	at io.flutter.plugin.common.BasicMessageChannel$IncomingMessageHandler.onMessage(BasicMessageChannel.java:261)
	at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
	at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-f

When downgrading the package firebase_database to the previous version 12.0.4, then FirebaseDatabaseQueryBuilder works as expected.

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs AttentionOP created or responded to issue and it needs attention.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions