This repository has been archived by the owner on Oct 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
switching to top-level cache util method for code cov
- Loading branch information
1 parent
a189762
commit 532afcc
Showing
7 changed files
with
49 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
// coverage:ignore-file | ||
|
||
/// The cache key for the speakers cache. | ||
const speakersCacheKey = 'speakers'; | ||
|
||
|
17 changes: 17 additions & 0 deletions
17
api/packages/fluttercon_cache/lib/src/utils/try_get_from_cache.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import 'dart:convert'; | ||
|
||
/// Attempts to fetch a value from the cache. | ||
/// If not present, the cache will call the method | ||
/// in [orElse] to fetch the data. | ||
/// [fromJson] is necessary to deserialize the value. | ||
Future<T> tryGetFromCache<T>({ | ||
required Future<String?> Function() getFromCache, | ||
required T Function(Map<String, dynamic>) fromJson, | ||
required Future<T> Function() orElse, | ||
}) async { | ||
final cached = await getFromCache(); | ||
if (cached != null) { | ||
return fromJson(jsonDecode(cached) as Map<String, dynamic>); | ||
} | ||
return orElse(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export 'try_get_from_cache.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters