Skip to content

Instantly share code, notes, and snippets.

@VB10
Created July 20, 2023 10:43
Show Gist options
  • Save VB10/6481818d9dbd2125904a18109a25ef9c to your computer and use it in GitHub Desktop.
Save VB10/6481818d9dbd2125904a18109a25ef9c to your computer and use it in GitHub Desktop.
decode extension
extension on String {
/// Decode your [jsonString] value with safety
Future<dynamic> safeJsonDecodeCompute() async {
try {
return await compute<String, dynamic>(
jsonDecode,
this,
);
} catch (e) {
Logger().e('Json decode error');
return null;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment