[Bug] JwtDecoder.isExpired(token) is throwing exception when there is no expiry
Closed this issue · 1 comments
flutter: NoSuchMethodError: The method 'toInt' was called on null.
flutter: Receiver: null
flutter: Tried calling: toInt()
I am also experiencing a similar exception when the expiry is a date format represented by a (not int-parsable) string (for example: "2021-08-16-06T15:58:44.381608893Z"). Version 1.0.4 has the breaking changes that cause this toInt
call to occur unsafely. My only available workaround is to force using exactly version 1.0.3 of the package (so it can't upgrade to 1.0.4 or anything higher) with jwt_decoder: 1.0.3
in my pubspec.yaml. Any version beyond that causes this exception for all tokens used in my system.
A possible code update for the package that could resolve this would be to more safely try to parse the expiry into an int (either by catching any parsing exception, or pre-checking for null or empty or non-numeric characters before attempting toInt
), and fall back to what was done in 1.0.3 (or doing something else reasonable) regarding expiry when it isn't able to be parsed to int.