Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_assertParameterTypesAreCorrect throws null check error #12287

Closed
AK47-23 opened this issue Feb 5, 2024 · 1 comment · Fixed by #12427
Closed

_assertParameterTypesAreCorrect throws null check error #12287

AK47-23 opened this issue Feb 5, 2024 · 1 comment · Fixed by #12427
Assignees
Labels
platform: all Issues / PRs which are for all platforms. plugin: analytics type: bug Something isn't working

Comments

@AK47-23
Copy link

AK47-23 commented Feb 5, 2024

Bug report

Describe the bug
Firebase analytics logEvent allows paramters to be Map<String, Object?>?, but if object is null it throws the following error:

Fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: 'package:firebase_analytics/src/firebase_analytics.dart': Failed assertion: line 1468 pos 9: 'value is String || value is num': 'string' OR 'number' must be set as the value of the parameter: user_id. null found instead

Steps to reproduce

Steps to reproduce the behavior:

  1. Add a logEvent with name and parameters
  2. In parameters add a map of key and value as null

Expected behavior

If you are checking whether the value is string or num, then it shouldn't allow the object to be null right?
Paramters accept Map<String, Object>? rather than Map<String, Object?>?.

Sample project

 FirebaseAnalytics.instance.logEvent(name: "logout", parameters: {
        "user_id": user?.id,
        "user_role": user?.designation.name,
        "company_id": user?.company.id,
      });

Here there's no syntax error but breaks the flow of the app during execution

Additional context

Add any other context about the problem here.


Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand
[✓] Flutter (Channel stable, 3.16.9, on Ubuntu 22.04.3 LTS 6.5.0-15-generic, locale en_IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2023.1)
[✓] Android Studio (version 2021.2)
[✓] IntelliJ IDEA Community Edition (version 2023.1)
[✓] VS Code (version unknown)
    ✗ Unable to determine VS Code version.
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand
- firebase_analytics 10.8.3 [firebase_analytics_platform_interface firebase_analytics_web firebase_core firebase_core_platform_interface flutter]
- firebase_core 2.25.2 [firebase_core_platform_interface firebase_core_web flutter meta]

@AK47-23 AK47-23 added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Feb 5, 2024
@danagbemava-nc danagbemava-nc added the triage Issue is currently being triaged. label Feb 5, 2024
@danagbemava-nc
Copy link

danagbemava-nc commented Feb 5, 2024

Reproducible using the plugin example app.

To reproduce, modify any of the parameters for logEvent to null and call the method. It will throw an assertion error.

This is an assert in the plugin so it cuts across all the platforms. It might be better to change the type of the parameters object as pointed out above so that users of the plugin know that they can't set null values.

cc @russellwheatley

@danagbemava-nc danagbemava-nc added plugin: analytics and removed Needs Attention This issue needs maintainer attention. triage Issue is currently being triaged. labels Feb 5, 2024
@Lyokone Lyokone self-assigned this Mar 4, 2024
@Lyokone Lyokone added the platform: all Issues / PRs which are for all platforms. label Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: all Issues / PRs which are for all platforms. plugin: analytics type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants