diff --git a/.gitignore b/.gitignore index a247422..511c678 100644 --- a/.gitignore +++ b/.gitignore @@ -73,3 +73,6 @@ build/ !**/ios/**/default.mode2v3 !**/ios/**/default.pbxuser !**/ios/**/default.perspectivev3 + +# FVM Version Cache +.fvm/ \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 1485ada..640237d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Changed + +- Update linting rules. +- Update dependencies — [175](https://github.com/dartoos-dev/json_cache/issues/175). + ### Fixed - minor error in README file — diff --git a/README.md b/README.md index d4b91a6..b0c625d 100644 --- a/README.md +++ b/README.md @@ -294,6 +294,7 @@ import 'package:localstorage/localstorage.dart'; await initLocalStorage(); final JsonCache jsonCache = JsonCacheMem(JsonCacheLocalStorage(localStorage)); … +``` ### JsonCacheSafeLocalStorage diff --git a/analysis_options.yaml b/analysis_options.yaml index 39a6f3b..02d1e9a 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -14,4 +14,3 @@ linter: cancel_subscriptions: true # Good packages document everything public_member_api_docs: true - package_api_docs: true diff --git a/lib/json_cache.dart b/lib/json_cache.dart index c71640f..28e77dc 100644 --- a/lib/json_cache.dart +++ b/lib/json_cache.dart @@ -1,5 +1,5 @@ /// A collection of [JsonCache] decorators. -library json_cache; +library; export 'src/json_cache.dart'; export 'src/json_cache_exception.dart'; diff --git a/lib/src/json_cache_safe_local_storage.dart b/lib/src/json_cache_safe_local_storage.dart index 777b43f..c081be6 100644 --- a/lib/src/json_cache_safe_local_storage.dart +++ b/lib/src/json_cache_safe_local_storage.dart @@ -1,6 +1,7 @@ // ignore_for_file: avoid_dynamic_calls import 'dart:collection'; +import 'dart:io'; import 'package:json_cache/json_cache.dart'; import 'package:safe_local_storage/safe_local_storage.dart'; @@ -57,3 +58,12 @@ final class JsonCacheSafeLocalStorage implements JsonCache { return await _localStorage.read() as Map; } } + +/// Adds resource release methods. +extension DisposeSafeLocalStorage on SafeLocalStorage { + /// Deletes the file with the stored data. + Future delete() async { + await write({}); + await File(path).delete(recursive: true); + } +} diff --git a/pubspec.lock b/pubspec.lock index 9f95999..06bc15b 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -45,26 +45,26 @@ packages: dependency: transitive description: name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.4.0" clock: dependency: transitive description: name: clock - sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.1.2" collection: dependency: transitive description: name: collection - sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" url: "https://pub.dev" source: hosted - version: "1.18.0" + version: "1.19.1" convert: dependency: transitive description: @@ -93,10 +93,10 @@ packages: dependency: transitive description: name: fake_async - sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" url: "https://pub.dev" source: hosted - version: "1.3.1" + version: "1.3.3" ffi: dependency: transitive description: @@ -122,26 +122,26 @@ packages: dependency: "direct main" description: name: flutter_secure_storage - sha256: "165164745e6afb5c0e3e3fcc72a012fb9e58496fb26ffb92cf22e16a821e85d0" + sha256: "9cad52d75ebc511adfae3d447d5d13da15a55a92c9410e50f67335b6d21d16ea" url: "https://pub.dev" source: hosted - version: "9.2.2" + version: "9.2.4" flutter_secure_storage_linux: dependency: transitive description: name: flutter_secure_storage_linux - sha256: "4d91bfc23047422cbcd73ac684bc169859ee766482517c22172c86596bf1464b" + sha256: be76c1d24a97d0b98f8b54bce6b481a380a6590df992d0098f868ad54dc8f688 url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.2.3" flutter_secure_storage_macos: dependency: transitive description: name: flutter_secure_storage_macos - sha256: "1693ab11121a5f925bbea0be725abfcfbbcf36c1e29e571f84a0c0f436147a81" + sha256: "6c0a2795a2d1de26ae202a0d78527d163f4acbb11cde4c75c670f3a0fc064247" url: "https://pub.dev" source: hosted - version: "3.1.2" + version: "3.1.3" flutter_secure_storage_platform_interface: dependency: transitive description: @@ -244,42 +244,42 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" + sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de" url: "https://pub.dev" source: hosted - version: "10.0.5" + version: "11.0.2" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" + sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1" url: "https://pub.dev" source: hosted - version: "3.0.5" + version: "3.0.10" leak_tracker_testing: dependency: transitive description: name: leak_tracker_testing - sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1" url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.0.2" lint: dependency: "direct dev" description: name: lint - sha256: d758a5211fce7fd3f5e316f804daefecdc34c7e53559716125e6da7388ae8565 + sha256: "3cd03646de313481336500ba02eb34d07c590535525f154aae7fda7362aa07a9" url: "https://pub.dev" source: hosted - version: "2.3.0" + version: "2.8.0" localstorage: dependency: "direct main" description: name: localstorage - sha256: "6340acefdd3a969cceb044a69cde2dc5877c5b861b2e02d0803930ed483dbe91" + sha256: e037e1db61f846e007206ef27f37d1d0cf53f9e25db5de983034803dd3356734 url: "https://pub.dev" source: hosted - version: "5.0.0" + version: "6.0.0" logging: dependency: transitive description: @@ -292,10 +292,10 @@ packages: dependency: transitive description: name: matcher - sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 url: "https://pub.dev" source: hosted - version: "0.12.16+1" + version: "0.12.17" material_color_utilities: dependency: transitive description: @@ -308,10 +308,10 @@ packages: dependency: transitive description: name: meta - sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 + sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.16.0" mime: dependency: transitive description: @@ -324,10 +324,10 @@ packages: dependency: "direct dev" description: name: mocktail - sha256: c4b5007d91ca4f67256e720cb1b6d704e79a510183a12fa551021f652577dce6 + sha256: "890df3f9688106f25755f26b1c60589a92b3ab91a22b8b224947ad041bf172d8" url: "https://pub.dev" source: hosted - version: "1.0.3" + version: "1.0.4" mutex: dependency: "direct main" description: @@ -356,26 +356,26 @@ packages: dependency: transitive description: name: path - sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" url: "https://pub.dev" source: hosted - version: "1.9.0" + version: "1.9.1" path_provider: dependency: transitive description: name: path_provider - sha256: fec0d61223fba3154d87759e3cc27fe2c8dc498f6386c6d6fc80d1afdd1bf378 + sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd" url: "https://pub.dev" source: hosted - version: "2.1.4" + version: "2.1.5" path_provider_android: dependency: transitive description: name: path_provider_android - sha256: "477184d672607c0a3bf68fbbf601805f92ef79c82b64b4d6eb318cbca4c48668" + sha256: e122c5ea805bb6773bb12ce667611265980940145be920cd09a4b0ec0285cb16 url: "https://pub.dev" source: hosted - version: "2.2.2" + version: "2.2.20" path_provider_foundation: dependency: transitive description: @@ -444,26 +444,26 @@ packages: dependency: "direct main" description: name: safe_local_storage - sha256: ede4eb6cb7d88a116b3d3bf1df70790b9e2038bc37cb19112e381217c74d9440 + sha256: e9a21b6fec7a8aa62cc2585ff4c1b127df42f3185adbd2aca66b47abe2e80236 url: "https://pub.dev" source: hosted - version: "1.0.2" + version: "2.0.1" shared_preferences: dependency: "direct main" description: name: shared_preferences - sha256: "746e5369a43170c25816cc472ee016d3a66bc13fcf430c0bc41ad7b4b2922051" + sha256: "6e8bf70b7fef813df4e9a36f658ac46d107db4b4cfe1048b477d4e453a8159f5" url: "https://pub.dev" source: hosted - version: "2.3.2" + version: "2.5.3" shared_preferences_android: dependency: transitive description: name: shared_preferences_android - sha256: a7e8467e9181cef109f601e3f65765685786c1a738a83d7fbbde377589c0d974 + sha256: "34266009473bf71d748912da4bf62d439185226c03e01e2d9687bc65bbfcb713" url: "https://pub.dev" source: hosted - version: "2.3.1" + version: "2.4.15" shared_preferences_foundation: dependency: transitive description: @@ -540,7 +540,7 @@ packages: dependency: transitive description: flutter source: sdk - version: "0.0.99" + version: "0.0.0" source_map_stack_trace: dependency: transitive description: @@ -569,18 +569,18 @@ packages: dependency: transitive description: name: stack_trace - sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" url: "https://pub.dev" source: hosted - version: "1.11.1" + version: "1.12.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.4" string_scanner: dependency: transitive description: @@ -609,26 +609,26 @@ packages: dependency: "direct dev" description: name: test - sha256: "7ee44229615f8f642b68120165ae4c2a75fe77ae2065b1e55ae4711f6cf0899e" + sha256: "65e29d831719be0591f7b3b1a32a3cda258ec98c58c7b25f7b84241bc31215bb" url: "https://pub.dev" source: hosted - version: "1.25.7" + version: "1.26.2" test_api: dependency: transitive description: name: test_api - sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" + sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00" url: "https://pub.dev" source: hosted - version: "0.7.2" + version: "0.7.6" test_core: dependency: transitive description: name: test_core - sha256: "55ea5a652e38a1dfb32943a7973f3681a60f872f8c3a05a14664ad54ef9c6696" + sha256: "80bf5a02b60af04b09e14f6fe68b921aad119493e26e490deaca5993fef1b05a" url: "https://pub.dev" source: hosted - version: "0.6.4" + version: "0.6.11" typed_data: dependency: transitive description: @@ -641,10 +641,10 @@ packages: dependency: transitive description: name: vector_math - sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b url: "https://pub.dev" source: hosted - version: "2.1.4" + version: "2.2.0" vm_service: dependency: transitive description: @@ -665,10 +665,10 @@ packages: dependency: transitive description: name: web - sha256: d43c1d6b787bf0afad444700ae7f4db8827f701bc61c255ac8d328c6f4d52062 + sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a" url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "1.1.1" web_socket_channel: dependency: transitive description: @@ -710,5 +710,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.5.0 <4.0.0" - flutter: ">=3.22.0" + dart: ">=3.9.0 <4.0.0" + flutter: ">=3.35.0" diff --git a/pubspec.yaml b/pubspec.yaml index 6a819ce..86a9c3a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,17 +11,17 @@ environment: dependencies: flutter: sdk: flutter - flutter_secure_storage: ^9.2.2 + flutter_secure_storage: ^9.2.4 hive: ^2.2.3 - localstorage: ^5.0.0 + localstorage: ^6.0.0 mutex: ^3.1.0 - safe_local_storage: ^1.0.2 - shared_preferences: ^2.3.2 + safe_local_storage: ^2.0.1 + shared_preferences: ^2.5.3 dev_dependencies: flutter_test: sdk: flutter hive_test: ^1.0.1 - lint: ^2.3.0 - mocktail: ^1.0.0 + lint: ^2.8.0 + mocktail: ^1.0.4 test: ^1.24.9 diff --git a/test/json_cache_safe_local_storage_test.dart b/test/json_cache_safe_local_storage_test.dart index d5b3123..8c3c208 100644 --- a/test/json_cache_safe_local_storage_test.dart +++ b/test/json_cache_safe_local_storage_test.dart @@ -14,7 +14,7 @@ void main() { late JsonCacheSafeLocalStorage jsonCacheSafeLocalStorage; // Profile data - const profKey = 'profile'; + const profileKey = 'profile'; const profData = { 'name': 'John Doe', 'age': 23, @@ -22,14 +22,14 @@ void main() { }; // App preferences data - const prefKey = 'preferences'; + const preferencesKey = 'preferences'; const prefData = { 'theme': 'light', 'notifications': {'enabled': true}, }; setUp( - () async { + () { tempDir = Directory.systemTemp; tempFile = File('${tempDir.path}/temp_file.json'); storage = SafeLocalStorage(tempFile.path); @@ -44,18 +44,18 @@ void main() { '"refresh", "value", "remove" with one piece of data', () async { // Insert a single piece of data into the cache - await jsonCacheSafeLocalStorage.refresh(profKey, profData); + await jsonCacheSafeLocalStorage.refresh(profileKey, profData); // Check if the data has been inserted into the cache. final profileRetrieved = - await jsonCacheSafeLocalStorage.value(profKey); + await jsonCacheSafeLocalStorage.value(profileKey); expect(profileRetrieved, equals(profData)); // Remove the single piece of data stored. - await jsonCacheSafeLocalStorage.remove(profKey); + await jsonCacheSafeLocalStorage.remove(profileKey); // No data should remain in the cache. - final cachedValue = await jsonCacheSafeLocalStorage.value(profKey); + final cachedValue = await jsonCacheSafeLocalStorage.value(profileKey); expect(cachedValue, isNull); }, ); @@ -64,27 +64,27 @@ void main() { '"refresh", "value", "remove" with multiple data', () async { // Insert multiple data into the cache - await jsonCacheSafeLocalStorage.refresh(profKey, profData); - await jsonCacheSafeLocalStorage.refresh(prefKey, prefData); + await jsonCacheSafeLocalStorage.refresh(profileKey, profData); + await jsonCacheSafeLocalStorage.refresh(preferencesKey, prefData); // Check if multiple data has been inserted into the cache. final profileRetrieved = - await jsonCacheSafeLocalStorage.value(profKey); + await jsonCacheSafeLocalStorage.value(profileKey); expect(profileRetrieved, equals(profData)); final preferencesRetrived = - await jsonCacheSafeLocalStorage.value(prefKey); + await jsonCacheSafeLocalStorage.value(preferencesKey); expect(preferencesRetrived, prefData); // Remove data from the cache. - await jsonCacheSafeLocalStorage.remove(profKey); - await jsonCacheSafeLocalStorage.remove(prefKey); + await jsonCacheSafeLocalStorage.remove(profileKey); + await jsonCacheSafeLocalStorage.remove(preferencesKey); final removedProfValue = - await jsonCacheSafeLocalStorage.value(profKey); + await jsonCacheSafeLocalStorage.value(profileKey); expect(removedProfValue, isNull); final removedPrefValue = - await jsonCacheSafeLocalStorage.value(prefKey); + await jsonCacheSafeLocalStorage.value(preferencesKey); expect(removedPrefValue, isNull); }, ); @@ -93,11 +93,12 @@ void main() { 'contains', () async { // Insert a single piece of data into the cache. - await jsonCacheSafeLocalStorage.refresh(profKey, profData); + await jsonCacheSafeLocalStorage.refresh(profileKey, profData); // Check - expect(await jsonCacheSafeLocalStorage.contains(profKey), true); - expect(await jsonCacheSafeLocalStorage.contains(prefKey), false); + expect(await jsonCacheSafeLocalStorage.contains(profileKey), true); + expect( + await jsonCacheSafeLocalStorage.contains(preferencesKey), false); // Test for keys that doesn't exist expect(await jsonCacheSafeLocalStorage.contains('generickey'), false); @@ -105,64 +106,71 @@ void main() { expect(await jsonCacheSafeLocalStorage.contains('PREFKEY'), false); // Insert a new piece of data into the cache to test more than one key stored. - await jsonCacheSafeLocalStorage.refresh(prefKey, prefData); + await jsonCacheSafeLocalStorage.refresh(preferencesKey, prefData); // Check for multiple data. - expect(await jsonCacheSafeLocalStorage.contains(profKey), true); - expect(await jsonCacheSafeLocalStorage.contains(prefKey), true); + expect(await jsonCacheSafeLocalStorage.contains(profileKey), true); + expect( + await jsonCacheSafeLocalStorage.contains(preferencesKey), true); // Remove data from the cache. - await jsonCacheSafeLocalStorage.remove(profKey); - expect(await jsonCacheSafeLocalStorage.contains(profKey), false); - expect(await jsonCacheSafeLocalStorage.contains(prefKey), true); + await jsonCacheSafeLocalStorage.remove(profileKey); + expect(await jsonCacheSafeLocalStorage.contains(profileKey), false); + expect( + await jsonCacheSafeLocalStorage.contains(preferencesKey), true); // Remove data from the cache. - await jsonCacheSafeLocalStorage.remove(prefKey); - expect(await jsonCacheSafeLocalStorage.contains(profKey), false); - expect(await jsonCacheSafeLocalStorage.contains(prefKey), false); + await jsonCacheSafeLocalStorage.remove(preferencesKey); + expect(await jsonCacheSafeLocalStorage.contains(profileKey), false); + expect( + await jsonCacheSafeLocalStorage.contains(preferencesKey), false); }, ); test('keys', () async { // update data - await jsonCacheSafeLocalStorage.refresh(profKey, profData); - await jsonCacheSafeLocalStorage.refresh(prefKey, prefData); + await jsonCacheSafeLocalStorage.refresh(profileKey, profData); + await jsonCacheSafeLocalStorage.refresh(preferencesKey, prefData); - expect(await jsonCacheSafeLocalStorage.keys(), [profKey, prefKey]); + expect( + await jsonCacheSafeLocalStorage.keys(), + [profileKey, preferencesKey], + ); }); group('method "keys"', () { setUp(() async { // update data - await jsonCacheSafeLocalStorage.refresh(profKey, profData); - await jsonCacheSafeLocalStorage.refresh(prefKey, prefData); + await jsonCacheSafeLocalStorage.refresh(profileKey, profData); + await jsonCacheSafeLocalStorage.refresh(preferencesKey, prefData); }); test('should return the inserted keys', () async { - expect(await jsonCacheSafeLocalStorage.keys(), [profKey, prefKey]); + expect(await jsonCacheSafeLocalStorage.keys(), + [profileKey, preferencesKey]); }); test('should keep the returned keys immutable', () async { final keys = await jsonCacheSafeLocalStorage.keys(); // This should not change the 'keys' variable. await jsonCacheSafeLocalStorage .refresh('info', {'This is very important information.': true}); - expect(keys, [profKey, prefKey]); + expect(keys, [profileKey, preferencesKey]); }); }); test( 'clear', () async { // Insert multiple data into the cache. - await jsonCacheSafeLocalStorage.refresh(profKey, profData); - await jsonCacheSafeLocalStorage.refresh(prefKey, prefData); + await jsonCacheSafeLocalStorage.refresh(profileKey, profData); + await jsonCacheSafeLocalStorage.refresh(preferencesKey, prefData); // Clear it. All data should be deleted with the file. await jsonCacheSafeLocalStorage.clear(); // No data should remain in the cache. - final cachedValue = await jsonCacheSafeLocalStorage.value(profKey); + final cachedValue = await jsonCacheSafeLocalStorage.value(profileKey); expect(cachedValue, isNull); // Insert a single piece of data into the cache. This refresh avoids errors on operational systems. - await jsonCacheSafeLocalStorage.refresh(profKey, profData); + await jsonCacheSafeLocalStorage.refresh(profileKey, profData); }, ); }, diff --git a/test/json_cache_try_test.dart b/test/json_cache_try_test.dart index 61303fa..a4669ed 100644 --- a/test/json_cache_try_test.dart +++ b/test/json_cache_try_test.dart @@ -7,13 +7,13 @@ class JsonCacheMock extends Mock implements JsonCache {} void main() { group('JsonCacheTry:', () { final jsonCacheMock = JsonCacheMock(); - test('should avoid JsonCacheTry as the wrapped instance', () async { + test('should avoid JsonCacheTry as the wrapped instance', () { expect( () => JsonCacheTry(JsonCacheTry(jsonCacheMock)), throwsAssertionError, ); }); - test('clear should throw "JsonCacheException"', () async { + test('clear should throw "JsonCacheException"', () { final JsonCacheTry jsonCacheTry = JsonCacheTry(jsonCacheMock); // Stub the 'clear' method. when(() => jsonCacheMock.clear()).thenThrow(Exception('Cache Failure')); @@ -21,13 +21,13 @@ void main() { verifyNever(() => jsonCacheMock.clear()); // Interact with the jsonCacheTry instance. expect( - () async => jsonCacheTry.clear(), + () => jsonCacheTry.clear(), throwsA(const TypeMatcher()), ); // Check if the interaction occurred only once. verify(() => jsonCacheMock.clear()).called(1); }); - test('contains should throw "JsonCacheException"', () async { + test('contains should throw "JsonCacheException"', () { final JsonCacheTry jsonCacheTry = JsonCacheTry(jsonCacheMock); // Stub the 'contains' method. when(() => jsonCacheMock.contains('aKey')) @@ -36,13 +36,13 @@ void main() { verifyNever(() => jsonCacheMock.contains('aKey')); // Interact with the jsonCacheTry instance. expect( - () async => jsonCacheTry.contains('aKey'), + () => jsonCacheTry.contains('aKey'), throwsA(const TypeMatcher()), ); // Check if the interaction occurred only once. verify(() => jsonCacheMock.contains('aKey')).called(1); }); - test('keys should throw "JsonCacheException"', () async { + test('keys should throw "JsonCacheException"', () { final JsonCacheTry jsonCacheTry = JsonCacheTry(jsonCacheMock); // Stub the 'contains' method. when(() => jsonCacheMock.keys()).thenThrow(Exception('Cache Failure')); @@ -50,13 +50,13 @@ void main() { verifyNever(() => jsonCacheMock.keys()); // Interact with the jsonCacheTry instance. expect( - () async => jsonCacheTry.keys(), + () => jsonCacheTry.keys(), throwsA(const TypeMatcher()), ); // Check if the interaction occurred only once. verify(() => jsonCacheMock.keys()).called(1); }); - test('refresh should throw "JsonCacheException"', () async { + test('refresh should throw "JsonCacheException"', () { final JsonCacheTry jsonCacheTry = JsonCacheTry(jsonCacheMock); // Stub the 'refresh' method. when(() => jsonCacheMock.refresh('aKey', {})) @@ -65,13 +65,13 @@ void main() { verifyNever(() => jsonCacheMock.refresh('aKey', {})); // Interact with the jsonCacheTry instance. expect( - () async => jsonCacheTry.refresh('aKey', {}), + () => jsonCacheTry.refresh('aKey', {}), throwsA(const TypeMatcher()), ); // Check if the interaction occurred only once. verify(() => jsonCacheMock.refresh('aKey', {})).called(1); }); - test('remove should throw "JsonCacheException"', () async { + test('remove should throw "JsonCacheException"', () { final JsonCacheTry jsonCacheTry = JsonCacheTry(jsonCacheMock); // Stub the 'remove' method. when(() => jsonCacheMock.remove('aKey')) @@ -80,13 +80,13 @@ void main() { verifyNever(() => jsonCacheMock.remove('aKey')); // Interact with the jsonCacheTry instance. expect( - () async => jsonCacheTry.remove('aKey'), + () => jsonCacheTry.remove('aKey'), throwsA(const TypeMatcher()), ); // Check if the interaction occurred only once. verify(() => jsonCacheMock.remove('aKey')).called(1); }); - test('value should throw "JsonCacheException"', () async { + test('value should throw "JsonCacheException"', () { final JsonCacheTry jsonCacheTry = JsonCacheTry(jsonCacheMock); // Stub the 'value' method. when(() => jsonCacheMock.value('aKey')) @@ -95,7 +95,7 @@ void main() { verifyNever(() => jsonCacheMock.value('aKey')); // Interact with the jsonCacheTry instance. expect( - () async => jsonCacheTry.value('aKey'), + () => jsonCacheTry.value('aKey'), throwsA(const TypeMatcher()), ); // Check if the interaction occurred only once.