getExpirationDate method

  1. @override
DateTime getExpirationDate()
override

Returns the exact moment when the token expires or the start of the epoch if the expiration date could not be found.

Implementation

@override
DateTime getExpirationDate() {
  try {
    final int secSinceEpoch = decodedPayload[_payloadKeyExpire] as int;
    return DateTime.fromMillisecondsSinceEpoch(secSinceEpoch * 1000);
  } on TypeError {
    // this method shouldn't throw an exception return epoch start  as default
    return DateTime.fromMillisecondsSinceEpoch(0);
  }
}