isAuthTokenExpired property

bool get isAuthTokenExpired

Check if the Auth token is expired

Implementation

bool get isAuthTokenExpired {
  if (authToken == null || authToken!.isEmpty) return false;

  JWT? jwt = JWT.tryDecode(authToken!);
  if (jwt == null) return false;

  return DateTime.now().isAfter(
      DateTime.fromMillisecondsSinceEpoch(0, isUtc: true)
          .add(Duration(seconds: jwt.payload['exp'])));
}