Last active
August 5, 2021 11:34
-
-
Save oligazar/779a0e66567f187aa45a47a575ab64f3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
parseJson() { | |
try { | |
return Login.fromJson(json.decode(result.body)); | |
} on FormatException catch (e) { // catching an exception according to it's type | |
return Future.error(InvalidDataError(e.message)); | |
} on ParseException { | |
return Future.error(InvalidDataError()); | |
} catch (_) { | |
return Future.error(InvalidDataError()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment