writeCache<T> method
Implementation
@override
Future<void>? writeCache<T>(String key, T? data) async {
if (data != null) {
try {
/// `.toJson()` must implements on T because jsonEncode it defaults to a function that returns the
/// result of calling `.toJson()` on the unencodable object.
await gs.write(key, jsonEncode(data));
} catch (e, s) {
if (kDebugMode) {
log("write type of ${T.runtimeType} cache error", error: e, stackTrace: s);
}
}
} else {
gs.remove(key);
}
}