Built_redux provider for Flutter.

Overview

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!

Comments
  • Migrate to dart 2

    Migrate to dart 2

    Move flutter_built_redux to support Dart 2 and a wider version of the built* generators.

    This change removes support for Dart 1.

    • Tests pass
    • My app using flutter_built_redux functions fine with these changes

    PTAL @davidmarne

    opened by VerTiGoEtrex 5
  • subscribe and cancel stream when widget tree change

    subscribe and cancel stream when widget tree change

    This changes seem to fix issue #9 by canceling subscription on Widget deactivated. Widget is resubscribe both on didChangeDependencies and didUpdateWidget.

    opened by yathit 5
  • Where should I listen to events?

    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.

    opened by ga6559 4
  • Cannot resolve class 'StreamTransformerBase' from 'MimeMultipartTransformer'

    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
    
    opened by btastic 4
  • setState() called after dispose():

    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<…>
    
    opened by yathit 4
  • Example Chat App not working

    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

    opened by BerndWessels 4
  • AnalysisException: Cannot compute LIBRARY_ELEMENT for Instance of 'AssetBasedSource'

    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)
    
    opened by long1eu 3
  • Nested State does not update the UI

    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();
                  },
                ),
    
    // ...
    
    opened by BerndWessels 2
  • Moved dependencies to build_value 5

    Moved dependencies to build_value 5

    Due to some changes in dart version in flutter developers needs to increase also build_value version to 5.

    It also fixes this: https://github.com/davidmarne/flutter_built_redux/issues/15

    opened by charafau 2
  • Update built_value to >= 4 <= 6 ?

    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

    opened by TobiasBales 2
  • example app not working

    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.

    opened by jt70 2
  • Cannot build app after migrating to Flutter 2.0.0

    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?

    https://github.com/MichaelM97/flutter_built_redux/commit/65043eaa075f475d34a5087f3b89c6b05c3d1d1e

    opened by MichaelM97 1
  • Incompatible with built_redux 8.0.0-nullsafety.0

    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
    
    opened by MichaelM97 0
  • support for flutter sdk 2.1.0.dev

    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)

    opened by 179882794 0
  • when changes state and widget, but state reuse, the new ui won't update.

    when changes state and widget, but state reuse, the new ui won't update.

    e. UserInfo extends StoreConnector<....>{ final String userId; UserInfo(this.userId); connect(){...} build(){....} }

    when refresh list of UserInfo, ui won't update. we should override the didUpdateWidget, force run the connect function, and setState

    opened by wilin52 0
  • Unsubscribe to state when not active route?

    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?

    opened by martinory 1
Releases(0.4.1)
  • 0.4.1(Jan 7, 2018)

  • 0.4.0(Jan 7, 2018)

    • Breaking changes:

      • Remove state builder generic from StoreConnector

      • Made StoreConnectorState private

    • Perform check on storeSub in didChangeDependencies to return early if a subscription to the store has already been created.

    • Raise exceptions if the store found by inheritFromWidgetOfExactType has different generics than the StoreConnector

    • Add unit tests

    Source code(tar.gz)
    Source code(zip)
  • 0.2.0(Oct 13, 2017)

    Rather than implementing StoreConnector & StoreConnectorState you now only have to have to write one object that implements connect & build. The build function also now takes the mapped state value and actions as parameters.

    abstract class MyWidgetProps implements Built<MyWidgetProps, MyWidgetPropsBuilder> {
      String get propIWantFromMyReduxState;
      MyWidgetProps._();
      factory MyWidgetProps([updates(MyWidgetPropsBuilder b)]) => _$MyWidgetProps;
    }
    
    class MyWidget extends StoreConnector<MyReduxState, MyReduxStateBuilder, MyReduxStateActions,
        MyWidgetProps, MyWidgetPropsBuilder> {
      MyWidget({Key key}) : super(key: key);
    
      @override
      MyWidgetProps connect(Store<MyReduxState, MyReduxStateBuilder, MyReduxStateActions> store) =>
          new MyWidgetProps((b) => b..propIWantFromMyReduxState = store.state.someProperty)
    
      MyWidgetState createState() => new MyWidgetState();
    }
    
    class MyWidgetState extends StoreConnectorState<MyReduxState, MyReduxStateBuilder,
        MyReduxStateActions, MyWidgetProps, MyWidgetPropsBuilder> {
    
      Widget build(BuildContext context) {
        return new Center(
          child: new Text(state.propIWantFromMyReduxState),
        );
      }
    

    would now be

    abstract class MyWidgetProps implements Built<MyWidgetProps, MyWidgetPropsBuilder> {
      String get propIWantFromMyReduxState;
      MyWidgetProps._();
      factory MyWidgetProps([updates(MyWidgetPropsBuilder b)]) => _$MyWidgetProps;
    }
    
    class MyWidget extends StoreConnector<MyReduxState, MyReduxStateBuilder, MyReduxStateActions, MyWidgetProps> {
      MyWidget({Key key}) : super(key: key);
    
      @override
      MyWidgetProps connect(MyReduxState state) =>
          new MyWidgetProps((b) => b..propIWantFromMyReduxState = state.someProperty);
    
      Widget build(BuildContext context, MyWidgetProps state, MyReduxStateActions actions) {
        return new Center(
          child: new Text(state.propIWantFromMyReduxState),
        );
      }
    
    Source code(tar.gz)
    Source code(zip)
  • 0.1.0(Sep 28, 2017)

Owner
null
Implementation of the Flux framework for Flutter

flutter_flux A Dart app architecture library with uni-directional data flow inspired by RefluxJS and Facebook's Flux. This is an experimental package

Google 374 Dec 15, 2022
An assembled flutter application framework.

Fish Redux What is Fish Redux ? Fish Redux is an assembled flutter application framework based on Redux state management. It is suitable for building

Alibaba 7.3k Jan 7, 2023
Github Search - Flutter Modular example

Desafio Github Search Projeto desenvolvido no desafio quizenal realizado pela equipe Flutterando e comunidade. Foram realizadas adaptações para implem

Flutterando 24 Nov 6, 2021
Neha Tanwar 4 Feb 2, 2022
Dusyeri provider task - Dusyeri provider task built using flutter

Düşyeri Provider Task https://github.com/alper-mf/dusyeri_provider_task/blob/7d1

null 1 May 9, 2022
Note provider - Note App using Provider state management, Sqflite and Localization for two language Arabic and English.

note_provider Sqflite with provider statemanagement Getting Started This project is a starting point for a Flutter application. A few resources to get

Mohanned Anwar 0 Jan 1, 2022
Flutter Github Following Application, Using Flutter Provider and Flutter HTTP to get data from Github API.

Flutter Github Following Application Watch it on Youtube Previous Designs Checkout my Youtube channel Installation Please remember, after cloning this

Mohammad Rahmani 110 Dec 23, 2022
Expenses tracker built with Flutter and Dart making use of Provider, Intl, Syncfusion Flutter Datepicker and more

expense_app A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if t

Atuoha Anthony 2 Dec 10, 2022
Flutter-NoteBooklyApp - Note and task list app using flutter provider.

notebookly_app Note taking and task app using firebase/provider. Getting Started This project is a starting point for a Flutter application. A few res

Walid Wazini 0 Jan 4, 2022
Flutter table with dio and provider - A flutter Application created for Portfolio Page

My LinkedIn https://www.linkedin.com/in/marcelo-augusto-a60b6821a/ Intro This is

Marcelo Augusto 1 Jan 18, 2022
Flutter boilerplate - A boilerplate project created in flutter using MobX and Provider

Boilerplate Project A boilerplate project created in flutter using MobX and Prov

Wali Khan 0 Jan 22, 2022
Note app flutter sqflite provider - A Note Taking Application written in Flutter

note_app_flutter_sqflite_provider ?? Introduce This is a note taking app made wi

Cool Kid 10 Dec 22, 2022
Coffee flutter - A coffee app Used Firestore, GetX, flutter hooks, Provider

coffee_flutter A Coffee Flutter project. Used Firestore, GetX, flutter_hooks, Pr

deargo 4 Oct 26, 2022
An open source flutter ride-hailing app for learning purpose(Provider & Bloc)

citycab An open source ride hailing app with flutter. Getting Started This project is a starting point for a Flutter application. A few resources to g

Paul Edeme'kong - Flutter Fairy 94 Jan 2, 2023
A boilerplate project created in flutter using MobX and Provider

Boilerplate Project A boilerplate project created in flutter using MobX and Provider. Boilerplate supports both web and mobile, clone the appropriate

Mohamed Ziada 1 Jan 20, 2022
Surena store application , Create by Flutter with Provider statemanagement

surena_store_application A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you

Amir Hossein(Surena) Jahangiri 2 Jul 6, 2022
Flutter State Management: Movie App with Provider, Riverpod, flutter_bloc & more

Flutter State Management: Movie App with Provider, Riverpod, flutter_bloc & more This reference project shows how to implement a (Netflix-inspired) mo

Andrea Bizzotto 427 Dec 29, 2022
A new practical project made with Flutter and some native widgets, movie API, provider state and more.

Flutter Movie App This project was created with Flutter and some native Widgets like SingleChildScrollView, Hero Animation, SliverAppBar, StreamBuilde

Paúl 4 Jul 12, 2022
To do and accomplishment app built with Flutter and Dart. Made use of Provider

Todioapp A todo and accomplishment app built with Flutter Getting Started This project is a starting point for a Flutter application. A few resources

Atuoha Anthony 2 Dec 10, 2022
A Flutter MVVM provider demo application.

Flutter MVVM + Provider Demo A Flutter MVVM provider demo application. Demo About It simply loads Posts data from API and render the posts on the scre

Shubham Chhimpa 132 Oct 17, 2022