Skip to content

Commit

Permalink
Depending of the state of preferences, the onboarding exit may fail (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
g123k committed Jun 22, 2024
1 parent eb03ed1 commit ba8313c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class _UserPreferencesMigrationV2 extends UserPreferencesMigration {
null) {
await preferences._sharedPreferences.setInt(
UserPreferences._TAG_USER_GROUP,
Random().nextInt(10),
math.Random().nextInt(10),
);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'dart:math';
import 'dart:math' as math;

import 'package:flutter/material.dart';
import 'package:openfoodfacts/openfoodfacts.dart';
Expand Down Expand Up @@ -189,7 +189,7 @@ class UserPreferences extends ChangeNotifier {
if (result != null) {
return result;
}
result = Random().nextInt(1 << 32);
result = math.Random().nextInt(1 << 32);
await _sharedPreferences.setInt(tag, result);
return result;
}
Expand Down Expand Up @@ -251,7 +251,8 @@ class UserPreferences extends ChangeNotifier {
_sharedPreferences.getInt(_TAG_LAST_VISITED_ONBOARDING_PAGE);
return pageIndex == null
? OnboardingPage.NOT_STARTED
: OnboardingPage.values[pageIndex];
: OnboardingPage
.values[math.min(pageIndex, OnboardingPage.values.length - 1)];
}

Future<void> incrementScanCount() async {
Expand Down

0 comments on commit ba8313c

Please sign in to comment.