getTokenTime static method

Duration getTokenTime(
  1. String token
)

Returns token issuing date (iat)

Implementation

static Duration getTokenTime(String token) {
  final decodedToken = decode(token)!;

  final issuedAtDate = DateTime.fromMillisecondsSinceEpoch(0)
      .add(Duration(seconds: decodedToken["iat"]));
  return DateTime.now().difference(issuedAtDate);
}