diff --git a/packages/smooth_app/lib/data_models/preferences/migration/user_preferences_migration.dart b/packages/smooth_app/lib/data_models/preferences/migration/user_preferences_migration.dart index 08a8b8b1406..5cdb4b9766d 100644 --- a/packages/smooth_app/lib/data_models/preferences/migration/user_preferences_migration.dart +++ b/packages/smooth_app/lib/data_models/preferences/migration/user_preferences_migration.dart @@ -78,7 +78,7 @@ class _UserPreferencesMigrationV2 extends UserPreferencesMigration { null) { await preferences._sharedPreferences.setInt( UserPreferences._TAG_USER_GROUP, - Random().nextInt(10), + math.Random().nextInt(10), ); } } diff --git a/packages/smooth_app/lib/data_models/preferences/user_preferences.dart b/packages/smooth_app/lib/data_models/preferences/user_preferences.dart index 6bed2453a2d..e80cbd9be8b 100644 --- a/packages/smooth_app/lib/data_models/preferences/user_preferences.dart +++ b/packages/smooth_app/lib/data_models/preferences/user_preferences.dart @@ -1,4 +1,4 @@ -import 'dart:math'; +import 'dart:math' as math; import 'package:flutter/material.dart'; import 'package:openfoodfacts/openfoodfacts.dart'; @@ -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; } @@ -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 incrementScanCount() async {