trySign method
String?
trySign(
- JWTKey key, {
- JWTAlgorithm algorithm = JWTAlgorithm.HS256,
- Duration? expiresIn,
- Duration? notBefore,
- bool noIssueAt = false,
Exactly like sign
, just return null
instead of throwing exceptions.
Implementation
String? trySign(
JWTKey key, {
JWTAlgorithm algorithm = JWTAlgorithm.HS256,
Duration? expiresIn,
Duration? notBefore,
bool noIssueAt = false,
}) {
try {
return sign(
key,
algorithm: algorithm,
expiresIn: expiresIn,
notBefore: notBefore,
noIssueAt: noIssueAt,
);
} catch (ex) {
return null;
}
}