Skip to content

Instantly share code, notes, and snippets.

@mono0926
Created February 22, 2022 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mono0926/eb11a979f604529162e626a904111aaa to your computer and use it in GitHub Desktop.
Save mono0926/eb11a979f604529162e626a904111aaa to your computer and use it in GitHub Desktop.
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'count_state.dart';
final countProvider = StateNotifierProvider<CountController, CountState>(
(ref) => CountController(ref.read),
);
class CountController extends StateNotifier<CountState> {
CountController(this._read) : super(const CountState());
final Reader _read;
void increment() {
state = state.copyWith(
count: state.count + 1,
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment