redux_hooks 1.0.1 copy "redux_hooks: ^1.0.1" to clipboard
redux_hooks: ^1.0.1 copied to clipboard

discontinued

A redux hooks for flutter project. which will help you to dispatch and listen any action.

redux_hooks #

A Redux Hooks for flutter project.


Why this library #

I was working on one of my project on flutter And I saw that there is requirement to use useSelector and useDispatch function in my project because I was using redux as state container then I started searching library for it on pub.dev and I found a library flutter_redux_hooks so, I added in my project pubspec.yaml after this when I ran my project I get a error that my project is dependent on redux 5.0.0. so, i went on repository and saw that this library has no update from last 18 month. so I decided that I will fork this repo and I will provide update to it and will publish with different name but after cloning this repo. I was unable to run this project in editor, after spending more than 4hr I decided that I will write my own library for it and now I am here 😄 .


issues #

please report any issue on bug reports


add dependency #

 redux_hooks: ^1.0.1

Getting Started #

1) initialize redux hooks in main function #

Future<void> main() async {
  final store = Store<ApplicationState>(counterReducer,
      initialState: ApplicationState.initialState());
      // redux hooks init 
  await ReduxHooks.setStore(store);
  runApp(MyApp(
    store: store,
  ));
}

2) dispatch any action #

class Home extends StatelessWidget {
  const Home({Key? key}) : super(key: key);

  static const routeName = '/home';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      floatingActionButton: FloatingActionButton(
        onPressed: () {
            // dispaching action with useDispatch function
          ReduxHooks.useDispatch(CounterActions.increment);
        },
        child: const Icon(Icons.add),
      ),
    );
  }
}

3) Listen state with StateProvider widget #

class Home extends StatelessWidget {
  const Home({Key? key}) : super(key: key);

  static const routeName = '/home';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Redux hooks Plugin example app'),
      ),
      body: Center(
        // listenning changes with stateProvider widget
          child: StateProvider(
              provideState: ReduxHooks.useSelector,
              child: ((state) {
                return Text("${state.counter}");
              }))),
    );
  }
}

Example #

for full example please visit: - https://github.com/Adityapanther/redux-hooks/tree/main/example


Upcoming Features #

  • web support

Contributions #

I am welcoming contributor and contribution in this library


Contributor #

0
likes
130
pub points
0%
popularity

Publisher

verified publisherpresswink.com

A redux hooks for flutter project. which will help you to dispatch and listen any action.

Repository (GitHub)
View/report issues

Documentation

Documentation
API reference

License

Apache-2.0 (license)

Dependencies

flutter, redux

More

Packages that depend on redux_hooks