Remove the legacy SharedPreferences migration

This was introduced in 1.8.1 and is not needed anymore

Closes #774
This commit is contained in:
Roland Geider
2026-11-08 19:12:26 +01:00
parent 44d627c9bc
commit f2e29cf295
3 changed files with 1 additions and 27 deletions

View File

@@ -1,7 +1,6 @@
import 'dart:convert';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:shared_preferences/util/legacy_to_async_migration_util.dart';
import 'package:wger/core/search_options.dart';
import 'package:wger/features/exercises/models/exercise_filters.dart';
import 'package:wger/features/nutrition/models/ingredient.dart';
@@ -11,9 +10,7 @@ import 'package:wger/features/nutrition/models/ingredient_filters.dart';
/// leaves with the local data.
const PREFS_WORKOUT_PROGRESS = 'workoutProgressPrefs';
/// A helper class that manages preferences using SharedPreferencesAsync
/// and handles migration from the legacy SharedPreferences to
/// SharedPreferencesAsync.
/// A helper class that manages preferences using SharedPreferencesAsync.
class PreferenceHelper {
PreferenceHelper._instantiate();
@@ -25,22 +22,6 @@ class PreferenceHelper {
static PreferenceHelper get instance => _instance;
/// Migration function that ensures any legacy data stored in
/// SharedPreferences is migrated to SharedPreferencesAsync. This migration
/// only happens once, as checked by the migrationCompletedKey.
///
/// `migrationCompletedKey` is used to track if the migration has been
/// completed.
Future<void> migrationSupportFunctionForSharedPreferences() async {
const SharedPreferencesOptions sharedPreferencesOptions = SharedPreferencesOptions();
final SharedPreferences prefs = await SharedPreferences.getInstance();
await migrateLegacySharedPreferencesToSharedPreferencesAsyncIfNecessary(
legacySharedPreferencesInstance: prefs,
sharedPreferencesAsyncOptions: sharedPreferencesOptions,
migrationCompletedKey: 'migrationCompleted',
);
}
//ingredients filters
//1.vegan
Future<void> saveIngredientVeganFilter(bool value) async {

View File

@@ -123,9 +123,6 @@ void main() async {
final logger = Logger('main');
// SharedPreferences to SharedPreferencesAsync migration function
await PreferenceHelper.instance.migrationSupportFunctionForSharedPreferences();
// Seed the log level from the prefs, the phase right after a cold start is
// the interesting one; AppSettingsNotifier keeps it in sync from here on.
applyVerboseLogging(

View File

@@ -22,11 +22,9 @@ import 'package:flutter_typeahead/flutter_typeahead.dart';
import 'package:material_ui/material_ui.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart';
import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart';
import 'package:wger/core/search_options.dart';
import 'package:wger/core/shared_preferences.dart';
import 'package:wger/features/nutrition/models/ingredient.dart';
import 'package:wger/features/nutrition/providers/ingredient_repository.dart';
import 'package:wger/features/nutrition/widgets/widgets.dart';
@@ -45,9 +43,7 @@ void main() {
late MockIngredientRepository mockIngredientRepo;
setUp(() async {
SharedPreferences.setMockInitialValues(<String, Object>{});
SharedPreferencesAsyncPlatform.instance = InMemorySharedPreferencesAsync.empty();
await PreferenceHelper.instance.migrationSupportFunctionForSharedPreferences();
mockIngredientRepo = MockIngredientRepository();
when(mockIngredientRepo.getById(any)).thenAnswer((_) async => null);