Created
February 22, 2022 23:19
-
-
Save mono0926/eb11a979f604529162e626a904111aaa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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