Add the following dependency to your pubspec.yaml
file:
dependencies:
control: <version>
/// Counter state for [CounterController]
typedef CounterState = ({int count, bool idle});
/// Counter controller
final class CounterController extends StateController<CounterState>
with SequentialControllerHandler {
CounterController({CounterState? initialState})
: super(initialState: initialState ?? (idle: true, count: 0));
void add(int value) => handle(() async {
setState((idle: false, count: state.count));
await Future<void>.delayed(const Duration(milliseconds: 1500));
setState((idle: true, count: state.count + value));
});
void subtract(int value) => handle(() async {
setState((idle: false, count: state.count));
await Future<void>.delayed(const Duration(milliseconds: 1500));
setState((idle: true, count: state.count - value));
});
}
Refer to the Changelog to get all release notes.
If you want to support the development of our library, there are several ways you can do it:
We appreciate any form of support, whether it's a financial donation or just a star on GitHub. It helps us to continue developing and improving our library. Thank you for your support!