isNotExpired method

bool isNotExpired({
  1. int timeBufferInSeconds = 0,
})

Returns true if the token is still valid.

Uses getExpirationDate to get the token validation time.

You could use timeBufferInSeconds to add a safety zone in seconds. This is useful for network request since this is not instant and a token could be invalidated between the expired check and the check on the server side. The default value is 0 seconds.

Implementation

bool isNotExpired({int timeBufferInSeconds = 0}) {
  return (DateTime.now().difference(getExpirationDate())).inSeconds <
      timeBufferInSeconds;
}