Repository: flutter
Issue: [shared_preferences] On Web, exception on initialization when a stored value is not valid JSON
Labels: platform-web,p: shared_preferences,package,P2,team-web,triaged-web

### Steps to reproduce

Create a web project.
In my case, use secure_storage to store some value. It is stored as plain text.

### Expected results

The value that cannot be decoded should be ignored.

### Actual results

When trying to initialize from this local storage:

![image](https://github.com/user-attachments/assets/96383c92-d5cf-4e91-b255-c9edc9f21a04)

I get this exception:
```
[2024-10-11 11:01:16.394 | Catcher 2 | INFO] ---------- ERROR ----------
[2024-10-11 11:01:16.396 | Catcher 2 | INFO] FormatException: SyntaxError: Unexpected token 'k', "k6IlhTmQIL"... is not valid JSON
[2024-10-11 11:01:16.396 | Catcher 2 | INFO]
[2024-10-11 11:01:16.397 | Catcher 2 | INFO] ------- STACK TRACE -------
[2024-10-11 11:01:16.737 | Catcher 2 | INFO] dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 296:3  throw_
[2024-10-11 11:01:16.737 | Catcher 2 | INFO] dart-sdk/lib/_internal/js_dev_runtime/patch/convert_patch.dart 36:5          _parseJson
[2024-10-11 11:01:16.738 | Catcher 2 | INFO] dart-sdk/lib/convert/json.dart 610:36                                        convert
[2024-10-11 11:01:16.738 | Catcher 2 | INFO] dart-sdk/lib/convert/json.dart 216:41                                        decode
[2024-10-11 11:01:16.738 | Catcher 2 | INFO] packages/shared_preferences_web/shared_preferences_web.dart 262:37           _decodeValue
[2024-10-11 11:01:16.739 | Catcher 2 | INFO] packages/shared_preferences_web/shared_preferences_web.dart 135:22           _readAllFromLocalStorage
[2024-10-11 11:01:16.739 | Catcher 2 | INFO] dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54           runBody
[2024-10-11 11:01:16.739 | Catcher 2 | INFO] dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5           _async
[2024-10-11 11:01:16.739 | Catcher 2 | INFO] packages/shared_preferences_web/shared_preferences_web.dart 129:55           [_readAllFromLocalStorage]
[2024-10-11 11:01:16.740 | Catcher 2 | INFO] packages/shared_preferences_web/shared_preferences_web.dart 126:12           getPreferences
[2024-10-11 11:01:16.740 | Catcher 2 | INFO] dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54           runBody
[2024-10-11 11:01:16.740 | Catcher 2 | INFO] dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5           _async
[2024-10-11 11:01:16.740 | Catcher 2 | INFO] packages/shared_preferences_web/shared_preferences_web.dart 122:45           getPreferences
[2024-10-11 11:01:16.741 | Catcher 2 | INFO] packages/shared_preferences/src/shared_preferences_async.dart 55:22          getAll
[2024-10-11 11:01:16.741 | Catcher 2 | INFO] dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54           runBody
[2024-10-11 11:01:16.741 | Catcher 2 | INFO] dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5           _async
[2024-10-11 11:01:16.742 | Catcher 2 | INFO] packages/shared_preferences/src/shared_preferences_async.dart 52:38          getAll
[2024-10-11 11:01:16.742 | Catcher 2 | INFO] packages/shared_preferences/src/shared_preferences_async.dart 225:32         reloadCache
[2024-10-11 11:01:16.742 | Catcher 2 | INFO] dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54           runBody
[2024-10-11 11:01:16.743 | Catcher 2 | INFO] dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5           _async
[2024-10-11 11:01:16.743 | Catcher 2 | INFO] packages/shared_preferences/src/shared_preferences_async.dart 222:27         reloadCache
[2024-10-11 11:01:16.743 | Catcher 2 | INFO] packages/shared_preferences/src/shared_preferences_async.dart 200:22         create
[2024-10-11 11:01:16.744 | Catcher 2 | INFO] dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54           runBody
[2024-10-11 11:01:16.744 | Catcher 2 | INFO] dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5           _async
[2024-10-11 11:01:16.744 | Catcher 2 | INFO] packages/shared_preferences/src/shared_preferences_async.dart 187:51         create
```

### Code sample

<details open><summary>Code sample</summary>

```dart
final sharedPreferences = await SharedPreferencesWithCache.create(
      cacheOptions: const SharedPreferencesWithCacheOptions());
```

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>

[Upload media here]

</details>


### Logs

<details open><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[√] Flutter (Channel stable, 3.24.3, on Microsoft Windows [version 10.0.22631.4169], locale fr-FR)
    • Flutter version 3.24.3 on channel stable at c:\Vrac\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2663184aa7 (4 weeks ago), 2024-09-11 16:27:48 -0500
    • Engine revision 36335019a8
    • Dart version 3.5.3
    • DevTools version 2.37.3

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at C:\Users\gdurand\AppData\Local\Android\Sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0--11609105)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.11.5)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.11.35327.3
    • Windows 10 SDK version 10.0.22621.0

[√] Android Studio (version 2024.1)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.10+0--11609105)

[√] IntelliJ IDEA Community Edition (version 2020.3)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.1.1
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart

[√] VS Code (version 1.94.1)
    • VS Code at C:\Users\gdurand\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.98.0

[√] Connected device (4 available)
    • SM G930U (mobile) • b86bd847 • android-arm64  • Android 8.0.0 (API 26)
    • Windows (desktop) • windows  • windows-x64    • Microsoft Windows [version 10.0.22631.4169]
    • Chrome (web)      • chrome   • web-javascript • Google Chrome 129.0.6668.90
    • Edge (web)        • edge     • web-javascript • Microsoft Edge 129.0.2792.65

[√] Network resources
    • All expected network resources are available.

• No issues found!
```

</details>