static TokenType? tryFromJson(String? json) { if (json == null) return null; try { return fromJson(json); } on StateError { return null; } }