onWin method

Future<void> onWin()

Records a win. Requests a review when the total is a multiple of _reviewEveryNWins.

Implementation

Future<void> onWin() async {
  final prefs = await ref.read(sharedPreferencesProvider.future);
  final count = (state.value ?? 0) + 1;
  await prefs.setInt(_key, count);
  state = AsyncData(count);

  if (count % _reviewEveryNWins == 0) {
    await _maybeRequestReview();
  }
}