Skip to content

Commit 144612d

Browse files
authored
Fix preferences (#90)
* fix overwrite of sharedInAppBrowser of type String into type bool * update version
1 parent 09463cf commit 144612d

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

lib/riverpod/preferences_provider.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,11 @@ class UserPreferencessNotifier extends StateNotifier<Preferences> {
140140
if (newValue != state.amazonCountryCode) {
141141
final SharedPreferences preferences = ref.read(preferencesProvider);
142142
if (newValue == null) {
143-
await preferences.remove(sharedInAppBrowser);
143+
await preferences.remove(sharedAmazonCountryCode);
144144
} else {
145-
await preferences.setString(sharedInAppBrowser, newValue);
145+
await preferences.setString(sharedAmazonCountryCode, newValue);
146146
}
147147
state = state.copyWith(amazonCountryCode: newValue);
148148
}
149149
}
150-
151150
}

lib/utils/migration.dart

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import 'package:amiibo_network/utils/preferences_constants.dart';
2+
import 'package:shared_preferences/shared_preferences.dart';
3+
4+
Future<void> sharedPreferencesMigration(SharedPreferences preferences) async {
5+
/// Fix migration error: type 'String' is not a subtype of type 'bool?'
6+
/// in type cast. Error thrown PreferencesProvider.
7+
final sharedInAppBrowserObject = preferences.get(sharedInAppBrowser);
8+
if (sharedInAppBrowserObject is String?) {
9+
await preferences.remove(sharedInAppBrowser);
10+
}
11+
}

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ description: An Amiibo collection app designed to allow you to keep track of
1212
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
1313
# Read more about iOS versioning at
1414
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
15-
version: 2.2.23+94
15+
version: 2.2.24+95
1616

1717
environment:
1818
sdk: ">=3.5.0 <4.0.0"

0 commit comments

Comments
 (0)