occasionally this error is generated when initializing CacheManager with JsonCacheInfoRepository
Fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: FormatException: Unexpected end of input (at character 1)
^
at .jsonDecode(dart:convert)
at JsonCacheInfoRepository._readFile(json_cache_info_repository.dart:143)
at JsonCacheInfoRepository.open(json_cache_info_repository.dart:40)
at new CacheStore.<fn>(cache_store.dart:34)
This happens when the {databaseName}.json file is created but empty and jsonString = ""
JsonCacheInfoRepository.dart: _readFile()
final json = jsonDecode(jsonString) as List<dynamic>;
A possible solution would be to check that the file is not empty before decoding the json
if (await file.exists() && await file.length() > 0) {
try {
final jsonString = await file.readAsString();
final json = jsonDecode(jsonString) as List<dynamic>;
note: I don't know why the json file is empty and not with an empty list []
Expected behavior
no error
Configuration
Doctor summary (to see all details, run flutter doctor -v):
[β] Flutter (Channel stable, 3.16.1, on Microsoft Windows [VersiΒ’n 10.0.22631.3296], locale es-CL)
[β] Windows Version (Installed version of Windows is version 10 or higher)
[β] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[β] Chrome - develop for the web
[β] Visual Studio - develop Windows apps (Visual Studio Build Tools 2022 17.8.2)
[β] Android Studio (version 2022.3)
[β] VS Code (version 1.87.2)
[β] Connected device (4 available)
[β] Network resources
π Bug Report
occasionally this error is generated when initializing CacheManager with JsonCacheInfoRepository
This happens when the {databaseName}.json file is created but empty and jsonString = ""
A possible solution would be to check that the file is not empty before decoding the json
Expected behavior
no error
Configuration
Doctor summary (to see all details, run flutter doctor -v): [β] Flutter (Channel stable, 3.16.1, on Microsoft Windows [VersiΒ’n 10.0.22631.3296], locale es-CL) [β] Windows Version (Installed version of Windows is version 10 or higher) [β] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [β] Chrome - develop for the web [β] Visual Studio - develop Windows apps (Visual Studio Build Tools 2022 17.8.2) [β] Android Studio (version 2022.3) [β] VS Code (version 1.87.2) [β] Connected device (4 available) [β] Network resources
β’ No issues found!
Version: 3.3.1
Platform: