Skip to content

fix(web): defensive readAll() to avoid Storage.forEach crash (edge-case corrupted localStorage) #1063

@eddiejdi

Description

@eddiejdi

Summary:\nThe web implementation may throw when iterating window.localStorage if a key exists but getItem(key) returns null (observed as 'Null check operator used on a null value' in consuming apps).\n\nI implemented a defensive fix in my fork (checks for null, removes corrupted entries, and falls back to JS Storage.key when needed):\n- Branch: eddiejdi:fix/web-readAll-defensive (also eddiejdi:fix/web-readAll-defensive-2)\n- Patch: https://github.com/eddiejdi/flutter_secure_storage/compare/fix/web-readAll-defensive-2\n\nSuggested change: make robust against corrupted Storage entries and add an integration test that simulates storage entries with null values.\n\nNotes: Consumers (e.g. estou-aqui app) experience WebView crashes due to this edge case. I'm happy to open a PR against develop if preferred — the patch is available in my fork and ready for review.\n

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions