firebase / FirebaseUI-Flutter

Apache License 2.0
92 stars 79 forks source link

🐛 Error: A value of type 'int?' can't be returned from a function with return type 'int' because 'int?' is nullable and 'int' isn't. #239

Closed designedbymaxtaylor closed 6 months ago

designedbymaxtaylor commented 6 months ago

Is there an existing issue for this?

What plugin is this bug for?

Firebase UI Firestore

What platform(s) does this bug affect?

Android

List of dependencies used.

flutter pub deps -s list ``` Dart SDK 3.2.3 Flutter SDK 3.16.5 rostera 1.0.0+1 dependencies: - flutter 0.0.0 - characters 1.3.0 - collection 1.18.0 - material_color_utilities 0.5.0 - meta 1.10.0 - vector_math 2.1.4 - web 0.3.0 - sky_engine any - cupertino_icons 1.0.6 - percent_indicator 4.2.3 - flutter any - firebase_core 2.24.2 - firebase_core_platform_interface ^5.0.0 - firebase_core_web ^2.10.0 - flutter any - meta ^1.8.0 - cloud_firestore 4.14.0 - cloud_firestore_platform_interface ^6.1.0 - cloud_firestore_web ^3.9.0 - collection ^1.0.0 - firebase_core ^2.24.2 - firebase_core_platform_interface ^5.0.0 - flutter any - meta ^1.8.0 - firebase_ui_firestore 1.5.15 - cloud_firestore ^4.13.3 - firebase_ui_localizations ^1.9.0 - flutter any - flutter_launcher_icons 0.13.1 - args ^2.3.2 - checked_yaml ^2.0.2 - cli_util ^0.4.0 - image ^4.0.15 - json_annotation ^4.8.0 - path ^1.8.2 - yaml ^3.1.1 dev dependencies: - flutter_test 0.0.0 - flutter any - test_api 0.6.1 - matcher 0.12.16 - path 1.8.3 - fake_async 1.3.1 - clock 1.1.1 - stack_trace 1.11.1 - vector_math 2.1.4 - async 2.11.0 - boolean_selector 2.1.1 - characters 1.3.0 - collection 1.18.0 - material_color_utilities 0.5.0 - meta 1.10.0 - source_span 1.10.0 - stream_channel 2.1.2 - string_scanner 1.2.0 - term_glyph 1.2.1 - web 0.3.0 - flutter_lints 3.0.1 - lints ^3.0.0 transitive dependencies: - _flutterfire_internals 1.3.16 - collection ^1.0.0 - firebase_core ^2.24.2 - firebase_core_platform_interface ^5.0.0 - flutter any - meta ^1.8.0 - archive 3.4.10 - crypto ^3.0.3 - path ^1.8.0 - pointycastle ^3.7.3 - args 2.4.2 - async 2.11.0 - collection ^1.15.0 - meta ^1.1.7 - boolean_selector 2.1.1 - source_span ^1.8.0 - string_scanner ^1.1.0 - characters 1.3.0 - checked_yaml 2.0.3 - json_annotation ^4.3.0 - source_span ^1.8.0 - yaml ^3.0.0 - cli_util 0.4.1 - meta ^1.3.0 - path ^1.8.0 - clock 1.1.1 - cloud_firestore_platform_interface 6.1.0 - _flutterfire_internals ^1.3.16 - collection ^1.15.0 - firebase_core ^2.24.2 - flutter any - meta ^1.8.0 - plugin_platform_interface ^2.1.3 - cloud_firestore_web 3.9.0 - _flutterfire_internals ^1.3.16 - cloud_firestore_platform_interface ^6.1.0 - collection ^1.0.0 - firebase_core ^2.24.2 - firebase_core_web ^2.10.0 - flutter any - flutter_web_plugins any - js ^0.6.3 - collection 1.18.0 - convert 3.1.1 - typed_data ^1.3.0 - crypto 3.0.3 - typed_data ^1.3.0 - fake_async 1.3.1 - clock ^1.1.0 - collection ^1.15.0 - firebase_core_platform_interface 5.0.0 - collection ^1.0.0 - flutter any - flutter_test any - meta ^1.8.0 - plugin_platform_interface ^2.1.3 - firebase_core_web 2.10.0 - firebase_core_platform_interface ^5.0.0 - flutter any - flutter_web_plugins any - js ^0.6.3 - meta ^1.8.0 - firebase_ui_localizations 1.10.0 - flutter any - flutter_localizations any - path ^1.8.3 - flutter_localizations 0.0.0 - flutter any - intl 0.18.1 - characters 1.3.0 - clock 1.1.1 - collection 1.18.0 - material_color_utilities 0.5.0 - meta 1.10.0 - path 1.8.3 - vector_math 2.1.4 - web 0.3.0 - flutter_web_plugins 0.0.0 - flutter any - characters 1.3.0 - collection 1.18.0 - material_color_utilities 0.5.0 - meta 1.10.0 - vector_math 2.1.4 - web 0.3.0 - image 4.1.3 - archive ^3.4.0 - meta ^1.3.0 - xml ^6.0.1 - intl 0.18.1 - clock ^1.1.0 - meta ^1.0.2 - path ^1.8.0 - js 0.6.7 - meta ^1.7.0 - json_annotation 4.8.1 - meta ^1.4.0 - lints 3.0.0 - matcher 0.12.16 - async ^2.10.0 - meta ^1.8.0 - stack_trace ^1.10.0 - term_glyph ^1.2.0 - test_api >=0.5.0 <0.7.0 - material_color_utilities 0.5.0 - collection ^1.15.0 - meta 1.10.0 - path 1.8.3 - petitparser 6.0.2 - meta ^1.9.0 - plugin_platform_interface 2.1.8 - meta ^1.3.0 - pointycastle 3.7.3 - collection ^1.15.0 - convert ^3.0.0 - js ^0.6.3 - sky_engine 0.0.99 - source_span 1.10.0 - collection ^1.15.0 - path ^1.8.0 - term_glyph ^1.2.0 - stack_trace 1.11.1 - path ^1.8.0 - stream_channel 2.1.2 - async ^2.5.0 - string_scanner 1.2.0 - source_span ^1.8.0 - term_glyph 1.2.1 - test_api 0.6.1 - async ^2.5.0 - boolean_selector ^2.1.0 - collection ^1.15.0 - meta ^1.3.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 - typed_data 1.3.2 - collection ^1.15.0 - vector_math 2.1.4 - web 0.3.0 - xml 6.5.0 - collection ^1.18.0 - meta ^1.9.0 - petitparser ^6.0.0 - yaml 3.1.2 - collection ^1.15.0 - source_span ^1.8.0 - string_scanner ^1.1.0 ```

Steps to reproduce

firebase_core used along with cloud_firestore to access Firebase Firestore DB. Executing 'flutter run' in the terminal in VS Code with the Android VM as target.

Expected Behavior

The program to debug without throwing the error.

Actual Behavior

Debug Console outputs the following error instead of running the program:

Launching lib\main.dart on sdk gphone64 x86 64 in debug mode... ../../../../../../../AppData/Local/Pub/Cache/hosted/pub.dev/firebase_ui_firestore-1.5.15/lib/src/table_builder.dart:874:71: Error: A value of type 'int?' can't be returned from a function with return type 'int' because 'int?' is nullable and 'int' isn't. if (_aggregateSnapshot?.count != null) return _aggregateSnapshot!.count; ^ Target kernel_snapshot failed: Exception

Additional Information

I originally thought it may have been an issue with the latest 1.6 release as the Flutter pub website states the following in the scores tab:

image

However, the issue continues after forcing Flutter to use the previous release in pubspec.yaml.

danagbemava-nc commented 6 months ago

Reproducible using the plugin example app. It is not specific to android

Launching lib\main.dart on Pixel 7 in debug mode...
../../../AppData/Local/Pub/Cache/hosted/pub.dev/firebase_ui_firestore-1.6.0/lib/src/table_builder.dart:874:71: Error: A value of type 'int?' can't be returned from a function with return type 'int' because 'int?' is nullable and 'int' isn't.
    if (_aggregateSnapshot?.count != null) return _aggregateSnapshot!.count;
                                                                      ^
Target kernel_snapshot failed: Exception

FAILURE: Build failed with an exception.

* Where:
Script 'C:\Users\Deana\fvm\versions\stable\packages\flutter_tools\gradle\src\main\groovy\flutter.groovy' line: 1350

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\Users\Deana\fvm\versions\stable\bin\flutter.bat'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 6s
Exception: Gradle task assembleDebug failed with exit code 1

Exited (1).
Jassirlink commented 6 months ago

is this issue fixed?

Jassirlink commented 6 months ago

i have same issue can't run the app , any updates

mariosplen commented 6 months ago

A pull request has been created that fixes the issue.

You can temporally make it work until it is approved, by replacing the firebase_ui_firestore dependency like so:

dependencies:
  firebase_ui_firestore:
    git:
      url: https://github.com/Codelessly/firebaseui-flutter.git
      path: packages/firebase_ui_firestore
      ref: fix-239
Jassirlink commented 6 months ago

ok thanks

lesnitsky commented 6 months ago

Reverted due to accidental merge with a non-semantic commit message, but also not sure if the fix is "secure" and could cause runtime null assertion error, discussing with the flutterfire team.