Skip to content

[shared_preferences] [windows,linux] Data can be corrupted due to lack of atomic file writes #89211

Open
@krll-kov

Description

 SharedPreferences _preferences = await SharedPreferences.getInstance();

This code simply fails with an error if config file is broken. Maybe it's good to clear preferences file if it contains an error. I do not know why the preferences file breaks but since i've published my app, there were some users, who reported this issue.

Platform where i faced this issue: Windows.

Flutter version: 2.2.3 from stable channel.

I have no idea why but file becomes something like this
image

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: desktopRunning on desktopp: shared_preferencesPlugin to read and write Shared Preferencespackageflutter/packages repository. See also p: labels.platform-linuxBuilding on or for Linux specificallyplatform-windowsBuilding on or for Windows specificallyteam-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