Skip to content

Commit

Permalink
Couple of null exceptions fixes and adding await for a review method
Browse files Browse the repository at this point in the history
  • Loading branch information
mkieres committed Oct 17, 2021
1 parent 4c990ee commit 441be35
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions board_games_companion/lib/services/rate_and_review_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ class RateAndReviewService {
static const Duration _requiredAppUsedForDuration = Duration(days: 14);
static const Duration _remindMeLaterDuration = Duration(days: 7);
static const Duration _requiredAppLaunchedForDuration = Duration(seconds: 30);
static const int _requiredNumberOfEventsLogged = 300;
static const int _requiredNumberOfSignificantActions = 300;

bool showRateAndReviewDialog = false;

Future<void> increaseNumberOfSignificantActions() async {
int numberOfLoggedEvents = _preferencesService.getNumberOfSignificantActions();
if (numberOfLoggedEvents < _requiredNumberOfEventsLogged) {
int numberOfSignificantActions = _preferencesService.getNumberOfSignificantActions();
if (numberOfSignificantActions < _requiredNumberOfSignificantActions) {
await _preferencesService.setNumberOfSignificantActions(
numberOfLoggedEvents += 1,
numberOfSignificantActions += 1,
);
}

Expand All @@ -36,7 +36,7 @@ class RateAndReviewService {
return;
}

InAppReview.instance.requestReview();
await InAppReview.instance.requestReview();
await _preferencesService.setRateAndReviewDialogSeen();
}

Expand Down Expand Up @@ -72,7 +72,7 @@ class RateAndReviewService {
firstTimeLaunchDate.add(_requiredAppUsedForDuration).isBefore(nowUtc) &&
appLaunchDate.add(_requiredAppLaunchedForDuration).isBefore(nowUtc) &&
(remindMeLaterDate == null || remindMeLaterDate.isBefore(nowUtc)) &&
numberOfSignificantActions >= _requiredNumberOfEventsLogged;
numberOfSignificantActions >= _requiredNumberOfSignificantActions;
} catch (e, stack) {
FirebaseCrashlytics.instance.recordError(e, stack);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class BoardGameDetailsStore with ChangeNotifier {
);

if (boardGameExpansionDetails != null &&
boardGameExpansionDetails.isExpansion! &&
(boardGameExpansionDetails.isExpansion ?? false) &&
boardGameExpansionDetails.isOwned) {
boardGameExpansion.isInCollection = true;
}
Expand Down
8 changes: 4 additions & 4 deletions board_games_companion/lib/stores/playthroughs_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class PlaythroughsStore with ChangeNotifier {
final AnalyticsService _analyticsService;

BoardGameDetails? _selectedBoardGame;
List<Playthrough>? _playthroughs;
List<Playthrough> _playthroughs = <Playthrough>[];

BoardGameDetails? get selectedBoardGame => _selectedBoardGame;

Expand All @@ -41,7 +41,7 @@ class PlaythroughsStore with ChangeNotifier {
FirebaseCrashlytics.instance.recordError(e, stack);
}

return _playthroughs ?? <Playthrough>[];
return _playthroughs;
}

Future<Playthrough> createPlaythrough(
Expand All @@ -59,7 +59,7 @@ class PlaythroughsStore with ChangeNotifier {
duration,
);

_playthroughs!.add(newPlaythrough!);
_playthroughs.add(newPlaythrough!);
notifyListeners();

await _analyticsService.logEvent(
Expand Down Expand Up @@ -96,7 +96,7 @@ class PlaythroughsStore with ChangeNotifier {
try {
final deleteSucceeded = await _playthroughService.deletePlaythrough(playthroughId);
if (deleteSucceeded) {
_playthroughs!.removeWhere((p) => p.id == playthroughId);
_playthroughs.removeWhere((p) => p.id == playthroughId);
notifyListeners();
}

Expand Down

0 comments on commit 441be35

Please sign in to comment.