Skip to content

Test widget problem after upgrade Dart 2.12 #224

Closed
@mdmota

Description

@mdmota

I'm having problems testing the widget to registerFactory using mockito and getIt.
This code worked before the flutter/dart migration.

My Code Test:
` var mockAnalytics = MockFBAnalytics();

GetIt.instance.registerFactory<AnalyticsService>(() => mockAnalytics);

when(mockAnalytics.getAnalytics()).thenReturn(FirebaseAnalytics());`

Error when running:
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following _TypeError was thrown running a test:
type 'Null' is not a subtype of type 'FirebaseAnalytics'

Ref: https://flutterprojects.blog/2021/05/17/widget-testing-with-mockito/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions