Giter VIP home page Giter VIP logo

flutter_built_redux's Introduction

Pub codecov.io

flutter_built_redux

built_redux bindings for Flutter.

By creating a Widget that extends StoreConnector you get automatic subscribing to your redux store, and you component will only call setState when the store triggers and the values you take from the store in connect change!

Examples

counter example

todo_mvc, written by Brian Egan

Why you may need flutter_built_redux

For the same reason you would want to use redux with react.

from the flutter tutorial:

In Flutter, change notifications flow “up” the widget hierarchy by way of callbacks, while current state flows “down” to the stateless widgets that do presentation.

Following this pattern requires you to send any state or state mutator callbacks that are common between your widgets down from some common ancestor.

With larger applications this is very tedious, leads to large widget constructors, and this pattern causes flutter to rerun the build function on all widgets between the ancestor that contains the state and the widget that actually cares about it. It also means your business logic and network requests live in your widget declarations.

built_redux gives you a predicable state container that can live outside your widgets and perform logic in action middleware.

flutter_built_redux lets a widget to subscribe to the pieces of the redux state tree that it cares about. It also lets lets widgets dispatch actions to mutate the redux state tree. This means widgets can access and mutate application state without the state and state mutator callbacks being passed down from its ancestors!

flutter_built_redux's People

Contributors

davidmarne avatar vertigoetrex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flutter_built_redux's Issues

Nested State does not update the UI

Hi

I have an AppState and a nested MenuState.
Actions on the AppState trigger the reducer and that then triggers the UI to update.
Actions on the nested MenuState trigger the nested reducer BUT do not trigger the UI to update.

Is this a bug or am I doing something wrong?

If there is nothing obvious in my following code, would you be so kind and provide an example with a nested action and reducer that actually triggers an update using the flutter_built_redux StoreConnection?

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel dev, v0.5.4, on Microsoft Windows [Version 10.0.17134.112], locale en-NZ)
[√] Android toolchain - develop for Android devices (Android SDK 26.0.2)
[√] Android Studio (version 3.1)
[√] IntelliJ IDEA Community Edition (version 2017.3)

store

Store<AppState, AppStateBuilder, AppActions> createStore() {
  return new Store<AppState, AppStateBuilder, AppActions>(
    appReducerBuilder.build(),
    new AppState.loading(),
    new AppActions(),
    middleware: [
      createFirebaseMiddleware(),
    ],
  );
}

middleware

final Firestore firestore = Firestore.instance;

Middleware<AppState, AppStateBuilder, AppActions> createFirebaseMiddleware() {
  return (new MiddlewareBuilder<AppState, AppStateBuilder, AppActions>()
        ..add(AppActionsNames.connectFirestoreAction, connectFirestore))
      .build();
}

connectFirestore(MiddlewareApi<AppState, AppStateBuilder, AppActions> api,
    ActionHandler next, Action<Null> action) {
  firestore
      .collection("menus/P1N09rgDMAgc5u2KrIIT/items")
      .orderBy("sortOrder")
      .snapshots()
      .listen((QuerySnapshot snapshot) {
    BuiltList<MenuItem> menuItems =
        documentsToBuiltList<MenuItem>(snapshot.documents, MenuItem.serializer);
    api.actions.menu.menuItemsLoadedSuccessAction(menuItems);
  });
  next(action);
}

app_state

part 'app_state.g.dart';

abstract class AppState implements Built<AppState, AppStateBuilder> {
  static Serializer<AppState> get serializer => _$appStateSerializer;

  factory AppState([updates(AppStateBuilder b)]) = _$AppState;

  AppState._();

  BuiltList<Shop> get shops;

  @nullable
  MenuState get menuState;

menu_state

part 'menu_state.g.dart';

abstract class MenuState implements Built<MenuState, MenuStateBuilder> {
  static Serializer<MenuState> get serializer => _$menuStateSerializer;

  factory MenuState([updates(MenuStateBuilder b)]) = _$MenuState;

  MenuState._();

  @nullable
  String get id;

  BuiltList<MenuItem> get menuItems;

  @nullable
  String get title;
}

menu_item

part 'menu_item.g.dart';

abstract class MenuItem implements Built<MenuItem, MenuItemBuilder> {
  static Serializer<MenuItem> get serializer => _$menuItemSerializer;

  factory MenuItem([updates(MenuItemBuilder b)]) = _$MenuItem;

  MenuItem._();

  @nullable
  String get currency;

  @nullable
  String get description;

  String get id;

  @nullable
  double get price;

  int get sortOrder;

  String get title;

  int get type;
}

app_actions

part 'app_actions.g.dart';

abstract class AppActions extends ReduxActions {
  ActionDispatcher<Null> connectFirestoreAction;
  ActionDispatcher<BuiltList<Shop>> shopsLoadedSuccessAction;

  factory AppActions() => new _$AppActions();

  AppActions._();

  MenuActions get menu;
}

menu_actions

part 'menu_actions.g.dart';

abstract class MenuActions extends ReduxActions {
  ActionDispatcher<BuiltList<MenuItem>> menuItemsLoadedSuccessAction;

  factory MenuActions() => new _$MenuActions();

  MenuActions._();
}

app_reducer

final appReducerBuilder = new ReducerBuilder<AppState, AppStateBuilder>()
  ..add(AppActionsNames.shopsLoadedSuccessAction, shopsLoadedSuccess)
  ..combineNested<MenuState, MenuStateBuilder>(menuReducerBuilder);

menu_reducer

final menuReducerBuilder =
    new NestedReducerBuilder<AppState, AppStateBuilder, MenuState, MenuStateBuilder>(
        (s) => s.menuState,
        (b) => b.menuState) // maps from the main state object to the nested state
      ..add(MenuActionsNames.menuItemsLoadedSuccessAction, menuItemsLoadedSuccess);

void menuItemsLoadedSuccess(MenuState state, Action<BuiltList<MenuItem>> action,
    MenuStateBuilder builder) {
  builder.menuItems.replace(action.payload);
}

menu_widget

class MenuWidget extends StatefulWidget {
  @override
  MenuWidgetState createState() => MenuWidgetState();
}

class MenuWidgetState extends State<MenuWidget>
    with SingleTickerProviderStateMixin {

// ...

  @override
  Widget build(BuildContext context) {
    return StoreConnection<AppState, AppActions, BuiltList<MenuItem>>(
        connect: (state) => state.menuState.menuItems,
        builder: (BuildContext context, BuiltList<MenuItem> menuItems,
            AppActions actions) {
          print(menuItems); // not printed when nested action triggers nested reducer :(
          return Scaffold(

// ...

            floatingActionButton: FloatingActionButton(
              child: Icon(Icons.control_point),
              onPressed: () {
                actions.connectFirestoreAction();
              },
            ),

// ...

Hot reload issue

When hot reload the app, store is null due to referencing defunct Widget.

Where should I listen to events?

I want to listen for an specific action and show a SnackBar in response to it.

store
        .actionStream(AppActionsNames.dataCorrupted)
        .listen((change) {
      Scaffold
          .of(context)
          .showSnackBar(SnackBar(content: Text('Data Corrupted')));
    });

To do that I need a reference to the store and the context.

This is my component:

class AppScreen extends StoreConnector<App, AppActions, App> {
  @override
  Counter connect(App state) => state;

  @override
  Widget build(BuildContext context, Counter state, AppActions actions) {
    return Scaffold(
      appBar: AppBar(
        title: Text('My App'),
      ),
      body: Text('Hello World')
   );
  }
}

I'm not sure where should I put the first code because:

  1. I don't have access to the store and actionStream anywhere inside de component.
  2. I have access to the context only in the build method and it may be called more than once.
  3. I must bind the listen only 1 time.

Of course I may be designing this thing just the wrong way. I couldn't find any complete example of an flutter application that uses the listen binding. Whats the best way to use it in a flutter application?

Thanks.

Question: dispatching action on widget initialization

I'd like to dispatch an action when a widget initializes. Normally, I'd put this kind of logic inside initState on a stateful Flutter widget. But, AFAIK, no such feature exists for widgets that extend StoreConnector.

The reason I'd like to do this is so I can do things like make API calls when a widget is initialized. The parallel in the React world would be calling fetch inside of componentDidMount. I think an argument could be made that a better architecture in many cases would be to put the API calls in some middleware that is triggered by a change route action, and this is probably what I'll end up doing. But, I was really interested to hear what the best practice here is. Thanks!

AnalysisException: Cannot compute LIBRARY_ELEMENT for Instance of 'AssetBasedSource'

I'm getting this when i try to run my watcher.

Future<Null> main(List<String> args) async {
  await watch(<BuildAction>[
    new BuildAction(
        new PartBuilder(<Generator>[
          const JsonSerializableGenerator(),
          const BuiltValueGenerator(),
          new BuiltReduxGenerator(),
        ]),
        'my_app',
        inputs: const <String>['lib/**/*.dart'])
  ], deleteFilesByDefault: true);
}
[SEVERE] Instance of 'PartBuilder' on my_app|lib/actions/actions.dart: 
AnalysisException: Cannot compute LIBRARY_ELEMENT for Instance of 'AssetBasedSource'
Caused by Unexpected exception while performing ResolveUnitTypeNamesTask for source built_collection|lib/src/set/built_set.dart
#0      AnalysisTask._safelyPerform (package:analyzer/task/model.dart:333:7)
#1      AnalysisTask.perform (package:analyzer/task/model.dart:220:7)
#2      AnalysisDriver.performWorkItem (package:analyzer/src/task/driver.dart:284:10)
#3      AnalysisDriver.computeResult (package:analyzer/src/task/driver.dart:109:22)
#4      AnalysisContextImpl.computeResult (package:analyzer/src/context/context.dart:730:14)
#5      AnalysisContextImpl.computeLibraryElement (package:analyzer/src/context/context.dart:697:12)
#6      ResolverImpl._performResolve.<anonymous closure>.<anonymous closure> (package:code_transformers/src/resolver_impl.dart:167:25)
#7      MappedListIterable.elementAt (dart:_internal/iterable.dart:413)
#8      ListIterable.toList (dart:_internal/iterable.dart:218)
#9      ResolverImpl._performResolve.<anonymous closure> (package:code_transformers/src/resolver_impl.dart:168:10)
#10     StackZoneSpecification._registerUnaryCallback.<anonymous closure>.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:26)
#11     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#12     StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:14)
#13     _rootRunUnary (dart:async/zone.dart:1128)
#14     _CustomZone.runUnary (dart:async/zone.dart:1012)
#15     _FutureListener.handleValue (dart:async/future_impl.dart:129)
#16     _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:636)
#17     _Future._propagateToListeners (dart:async/future_impl.dart:665)
#18     _Future._completeWithValue (dart:async/future_impl.dart:478)
#19     _Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:510)
#20     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#21     StackZoneSpecification._registerCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:119:48)
#22     _rootRun (dart:async/zone.dart:1120)
#23     _CustomZone.run (dart:async/zone.dart:1001)
#24     _CustomZone.runGuarded (dart:async/zone.dart:901)
#25     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:926)
#26     _microtaskLoop (dart:async/schedule_microtask.dart:41)
#27     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
#28     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:99)
#29     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:152)

Incompatible with built_redux 8.0.0-nullsafety.0

Because flutter_built_redux 0.6.0 depends on built_redux >=6.1.1 <8.0.0 and app depends on built_redux 8.0.0-nullsafety.0, flutter_built_redux 0.6.0 is forbidden.

Adding a dependency override fixes it, but an update would be appreciated

dependency_overrides:
  built_redux: 8.0.0-nullsafety.0

How to: store.actionStream example

Hello,
I want listen store change on event named "AppActionsNames.startLoginFlow" and it changes single variable in AppState ... bool get startedLoginFlow;
store.actionStream(AppActionsNames.startLoginFlow).listen((StoreChange<AppState, AppStateBuilder, Action<Null>> change)
When action occurs, i got an error
Action {
name: AppActions-startLoginFlow,
payload: null,
}
[VERBOSE-2:dart_error.cc(16)] Unhandled exception:
type 'StoreChange<AppState, AppStateBuilder, dynamic>' is not a subtype of type 'StoreChange<AppState, AppStateBuilder, Null>' in type cast where
Replacing Action<Null> to Null doesnt help.

Example of using the Navigator

As referenced in Workiva/built_redux/issues/92, it would be nice to have an easy to find, canonical example of how to use the navigator when working in Flutter with built_redux.

This information could either be included in documentation or incorporated into the example code.

example app not working

Hi, it seems the example/chat_app is missing the android/ios folders. If I follow the instructions I get:

C:...\flutter_built_redux\example\chat_app>flutter run
Launching lib/main.dart on Android SDK built for x86 in debug mode...
No application found for TargetPlatform.android_x86.
Is your project missing an android/AndroidManifest.xml?
Consider running "flutter create ." to create one.

support for flutter sdk 2.1.0.dev

Because jinritoutiao depends on gesture_password >=0.0.2 which requires SDK version >=1.23.0 <2.3.0, version solving failed.
Running "flutter pub upgrade" in jinritoutiao_flutter-master...
pub upgrade failed (1)

Update built_value to >= 4 <= 6 ?

When trying to upgrade flutter to the latest alpha release I was not able to find a set of dependencies that worked out for me and one of the constraint's was the pinning of built_value to 4.x

Would it be possible to upgrade the dependency?

The breaking changes apparently are

  • Prohibit use of extends in built_value classes. Classes should inherit API using implements and API+implementation using extends Object with.
  • Prohibit use of show or as when importing 'package:built_value/built_value.dart'. The generated code needs access to all symbols in the package with no import prefix.
  • Prohibit use of the mutable collection types List, Set, Map, ListMultimap and SetMultimap. Suggest built_collection equivalents instead.

Not sure if this causes any issues with flutter_built_redux.

This would be great.

Also: thank you very much for the great project

Example Chat App not working

Hi

Thanks for updating the dependencies.

I just cloned the repo and build the example chat app, but it has some problems now.

Can you please look into this, thank you.

main.dart

dart2

Question: Is the example up-to-date?

As I'm typing in my IDE (intelliJ) it doesn't seem like StoreConnector is a thing, but StoreConnection is... the examples in both your example directory and Brian Egan's example aren't quite right (or at least it seems that way).

Old dependencies

Hi

I can't use this with the newer versions of build_redux and build_value.

Are you planning to update this package anytime soon?

Thanks
Bernd

Cannot resolve class 'StreamTransformerBase' from 'MimeMultipartTransformer'

Hey, I'm just posting this here too, because I think it is more appropriate here.

When running the build.dart in the sample code I get the following error on the latest flutter dev channel

'package:mime/src/mime_multipart_transformer.dart': malformed type: line 33 pos 13: cannot resolve class 'StreamTransformerBase' from 'MimeMultipartTransformer'
    extends StreamTransformerBase<List<int>, MimeMultipart> {
            ^

Flutter doctor:

PS C:\Users\bkons\source\repos\flutter_built_redux> flutter doctor -v
[√] Flutter (Channel dev, v0.1.6, on Microsoft Windows [Version 10.0.16299.248], locale de-DE)
    • Flutter version 0.1.6 at C:\Users\bkons\source\repos\flutter
    • Framework revision 1f3eb5034f (3 days ago), 2018-02-23 18:35:40 -0800
    • Engine revision ead227f118
    • Dart version 2.0.0-dev.28.0.flutter-0b4f01f759

[√] Android toolchain - develop for Android devices (Android SDK 27.0.3)
    • Android SDK at C:\android-sdk\
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-27, build-tools 27.0.3
    • ANDROID_HOME = C:\\android-sdk
    • Java binary at: D:\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)

[√] Android Studio (version 3.0)
    • Android Studio at D:\Android Studio
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)

[√] IntelliJ IDEA Community Edition (version 2017.3)
    • Flutter plugin version 21.2.3
    • Dart plugin version 173.4548.30

[√] VS Code (version 1.20.1)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Dart Code extension version 2.9.0

[!] Connected devices
    ! No devices available

Question: Best approach for widget testing

How do people approach writing widget tests when using flutter_built_redux?

One approach is to put the StoreConnection in its own widget at the top of the tree that then instantiates a child widget (that we want to test), passing the action object and any other bits of state. We can then test the child widget directly, passing whatever state we want, and doing expectDispatched on the actions object. Other approaches include passing callbacks rather than the action object for complete separation of concerns.

The problem with this is that we're then not testing the StoreConnection and its associated connect function, which is a place where you can get a mismatch between whats in your state and whats in your widget. Instead, I could use a ReduxProvider as a parent, passing in a store with the right state, but then I'm looking for state changes, and it's more like an end-to-end test. Is there a worthwhile middle ground that lets me test the connection point without testing the whole thing?

setState() called after dispose():

 flutter doctor
[✓] Flutter (on Mac OS X 10.12.6 16G1114, locale en-SG, channel alpha)
    • Flutter at /Users/k/flutter/flutter
    • Framework revision 8f65fec5f5 (9 days ago), 2017-12-12 09:50:14 -0800
    • Engine revision edaecdc8b8
    • Tools Dart version 1.25.0-dev.11.0
    • Engine Dart version 2.0.0-edge.d8ae797298c3a6cf8dc9f4558707bd2672224d3e

[✓] Android toolchain - develop for Android devices (Android SDK 25.0.3)
    • Android SDK at /Users/k/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-25, build-tools 25.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b08)

[✓] iOS toolchain - develop for iOS devices (Xcode 9.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 9.2, Build version 9C40b
    • ios-deploy 1.9.2
    • CocoaPods version 1.2.1

[✓] Android Studio (version 3.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b08)

[✓] IntelliJ IDEA Ultimate Edition (version 2017.3.1)
    • Flutter plugin version 20.0.3
    • Dart plugin version 173.3942.31

[✓] Connected devices
    • iPhone 7 • BC8B05F8-6448-4F35-B65A-5F5717F05A9E • ios • iOS 11.2 (simulator)


Sometimes (mostly just after navigation), the following unhandled exception occur.

+34254 ms] [DEVICE LOG] 2017-12-22 10:50:32.525257+0800  localhost Runner[32991]: (Flutter) [VERBOSE-2:dart_error.cc(16)] Unhandled exception:
[        ] [DEVICE LOG] setState() called after dispose(): StoreConnectorState<AppState, AppStateBuilder, AppActions, SugarModel>#1e3f6(lifecycle state: defunct, not mounted)
[        ] [DEVICE LOG] This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback. The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree.
[        ] [DEVICE LOG] This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose().
[        ] [DEVICE LOG] #0      State.setState.<ano<…>
[  +12 ms] setState() called after dispose(): StoreConnectorState<AppState, AppStateBuilder, AppActions, SugarModel>#1e3f6(lifecycle state: defunct, not mounted)
[        ] This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback. The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree.
[        ] This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose().
[        ] #0      State.setState.<ano<…>
[        ] [DEVICE LOG] 2017-12-22 10:50:32.527363+0800  localhost Runner[32991]: (Flutter) [VERBOSE-2:dart_error.cc(16)] Unhandled exception:
[        ] [DEVICE LOG] setState() called after dispose(): StoreConnectorState<AppState, AppStateBuilder, AppActions, SugarModel>#a7a43(lifecycle state: defunct, not mounted)
[        ] [DEVICE LOG] This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback. The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree.
[        ] [DEVICE LOG] This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose().
[        ] [DEVICE LOG] #0      State.setState.<ano<…>
[        ] [DEVICE LOG] 2017-12-22 10:50:32.528295+0800  localhost Runner[32991]: (Runner) Created Activity ID: 0x80000000009cec2c, Description: Sending Updated Preferences to System CFPrefsD
[        ] setState() called after dispose(): StoreConnectorState<AppState, AppStateBuilder, AppActions, SugarModel>#a7a43(lifecycle state: defunct, not mounted)
[        ] This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback. The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree.
[        ] This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose().
[        ] #0      State.setState.<ano<…>

Unsubscribe to state when not active route?

Hi!

I changed the formulation of the problem.

When navigating to a new page, the previous page in the router stack still subscribes to the state which results in unnecessary rebuilds which affect performance.

Is there a way to only subscribe to the state if it is the active one in the router stack?

Cannot build app after migrating to Flutter 2.0.0

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.