Line data Source code
1 : import 'package:flutter/widgets.dart';
2 :
3 : import 'package:flutter_redux/flutter_redux.dart';
4 :
5 : import '../../types/red_fire_state.dart';
6 : import '../../types/redux_action.dart';
7 :
8 : extension BuildContextExtension on BuildContext {
9 0 : dynamic dispatch<T extends RedFireState>(ReduxAction action) {
10 0 : return StoreProvider.of<T>(this, listen: false).dispatch(action);
11 : }
12 :
13 0 : dynamic dispatchAndListen<T extends RedFireState>(ReduxAction action) {
14 0 : return StoreProvider.of<T>(this).dispatch(action);
15 : }
16 :
17 0 : RedFireState getAppState<T extends RedFireState>() {
18 0 : return StoreProvider.of<T>(this).state;
19 : }
20 : }
|