parseJwt function
Implementation
Map<String, dynamic> parseJwt(String token) {
if (token == ""){
throw Exception('token is empty');
}
final parts = token.split('.');
if (parts.length != 3) {
throw Exception('invalid token');
}
final payload = _decodeBase64(parts[1]);
final payloadMap = json.decode(payload);
if (payloadMap is! Map<String, dynamic>) {
throw Exception('invalid payload');
}
return payloadMap;
}