Skip to content

Cannot build app after migrating to Flutter 2.0.0 #45

Open
@MichaelM97

Description

@MichaelM97

I'm getting the following build error after upgrading to Flutter 2.0.0

../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_built_redux-0.6.0/lib/flutter_built_redux.dart:95:17: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the class 'BuildContext'.

  • 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('../../flutter/packages/flutter/lib/src/widgets/framework.dart').
    Try correcting the name to the name of an existing method, or defining a method named 'inheritFromWidgetOfExactType'.
    context.inheritFromWidgetOfExactType(ReduxProvider);

To get this package working at all I'm using the following dependency override in my app

dependency_overrides:
  built_redux: 8.0.0-nullsafety.0

I was able to fix this and make my app build by updating LN#95 in flutter_built_redux.dart from

final ReduxProvider reduxProvider = context.inheritFromWidgetOfExactType(ReduxProvider);

to

final ReduxProvider reduxProvider = context.dependOnInheritedWidgetOfExactType<ReduxProvider>();

I can raise this as a PR if desired, but the plugin needs a lot more updating to build using Flutter 2.0 so I'm guessing this fix can just be included whenever you come to update this plugin?

MichaelM97@65043ea

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions