Skip to content

[shared_preferences] cast exception with get/setStringList: type 'List<Object?>' is not a subtype of type 'List?' #152607

@itismejy

Description

@itismejy

Steps to reproduce

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'List<Object?>' is not a subtype of type 'List?' in type cast

Expected results

setStringList is not working properly

Actual results

Should be a List<String>, not List<Object>

Code sample

Code sample
final SharedPreferencesWithCache prefsWithCache =
    await SharedPreferencesWithCache.create(
  cacheOptions: const SharedPreferencesWithCacheOptions(
    // When an allowlist is included, any keys that aren't included cannot be used.
    allowList: <String>{'action'},
  ),
);

await prefsWithCache!.setStringList('action', <String>['Earth', 'Moon', 'Sun']);
                            

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[Paste your output here]

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listp: shared_preferencesPlugin to read and write Shared Preferencespackageflutter/packages repository. See also p: labels.r: fixedIssue is closed as already fixed in a newer versionteam-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions