Created
July 20, 2023 10:43
-
-
Save VB10/6481818d9dbd2125904a18109a25ef9c to your computer and use it in GitHub Desktop.
decode extension
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
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