isAccessTokenExpired method

bool isAccessTokenExpired(
  1. Duration margin
)

Checks if the access token is expired by comparing the current time with the expiration time. It accepts a margin to account for an early refresh.

Implementation

bool isAccessTokenExpired(Duration margin) {
  return DateTime.now().difference(expiration!).abs().compareTo(margin) > 0;
}