-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
flutter/packages
#7355Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work listp: shared_preferencesPlugin to read and write Shared PreferencesPlugin to read and write Shared Preferencespackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-linuxBuilding on or for Linux specificallyBuilding on or for Linux specificallyplatform-windowsBuilding on or for Windows specificallyBuilding on or for Windows specificallyteam-ecosystemOwned by Ecosystem teamOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem teamTriaged by Ecosystem team
Description
Steps to reproduce
Use getStringList with SharedPreferencesAsync on Windowx 64.
A workaround would be to use the legacy API again :)
final prefs = await SharedPreferences.getInstance();
summaryList = prefs.getStringList(settingsKey) ?? [];Expected results
It works.
Actual results
Type Error:
type 'List<dynamic>' is not a subtype of type 'List<String>?' in type cast
Code sample
Code sample
static Future<List<Summary>> loadSummaries() async {
final prefs = SharedPreferencesAsync();
try {
final summaryList = await prefs.getStringList('summaryList') ?? [];
return summaryList.map((jsonString) {
final jsonMap = jsonDecode(jsonString);
return Summary.fromJson(jsonMap);
}).toList();
} catch (e) {
if (e is TypeError) {
debugPrint("[Summary] SummaryList is corrupted: $e");
}
return [];
}
}Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
[Paste your logs here]Flutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.24.0, on Microsoft Windows [Version 10.0.22631.3958], locale de-DE)
[✓] Windows Version (Installed version of Windows is version 10 or higher)Metadata
Metadata
Assignees
Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work listp: shared_preferencesPlugin to read and write Shared PreferencesPlugin to read and write Shared Preferencespackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-linuxBuilding on or for Linux specificallyBuilding on or for Linux specificallyplatform-windowsBuilding on or for Windows specificallyBuilding on or for Windows specificallyteam-ecosystemOwned by Ecosystem teamOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem teamTriaged by Ecosystem team