diff --git a/CHANGELOG.md b/CHANGELOG.md index ae0f53d6b..510cb652a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +## [0.5.2] - July 11 2018 + +### Breaking change + +n/a + +#### Fixes / Enhancements + +- Fixed error when cache file is non-existent + +#### Docs + +n/a + ## [0.5.1] - June 29 2018 ### Breaking change diff --git a/README.md b/README.md index e1857275c..fe61bbb86 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ First depend on the library by adding this to your packages `pubspec.yaml`: ```yaml dependencies: - graphql_flutter: ^0.5.1 + graphql_flutter: ^0.5.2 ``` Now inside your Dart code you can import it. diff --git a/lib/src/cache/in_memory.dart b/lib/src/cache/in_memory.dart index 408cac5a4..dce71c710 100644 --- a/lib/src/cache/in_memory.dart +++ b/lib/src/cache/in_memory.dart @@ -36,19 +36,22 @@ class InMemoryCache { Future> _readFromStorage() async { try { final File file = await _localStorageFile; - Stream inputStream = file.openRead(); - final HashMap storedHashMap = new HashMap(); - inputStream - .transform(utf8.decoder) // Decode bytes to UTF8. - .transform(new LineSplitter()) // Convert stream to individual lines. - .listen((String line) { - final List keyAndValue = json.decode(line); + if (file.existsSync()) { + Stream inputStream = file.openRead(); + + inputStream + .transform(utf8.decoder) // Decode bytes to UTF8. + .transform( + new LineSplitter()) // Convert stream to individual lines. + .listen((String line) { + final List keyAndValue = json.decode(line); - storedHashMap[keyAndValue[0]] = keyAndValue[1]; - }); + storedHashMap[keyAndValue[0]] = keyAndValue[1]; + }); + } return storedHashMap; } on FileSystemException { diff --git a/pubspec.yaml b/pubspec.yaml index d1aac8083..c52448aea 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: graphql_flutter description: A GraphQL client for Flutter. -version: 0.5.1 +version: 0.5.2 authors: - Eus Dima - Zino Hofmann