@@ -784,23 +784,17 @@ UsageMetadata _parseUsageMetadata(Object jsonObject) {
784784}
785785
786786SafetyRating _parseSafetyRating (Object ? jsonObject) {
787- return switch (jsonObject) {
788- {
789- 'category' : final Object category,
790- 'probability' : final Object probability,
791- 'probabilityScore' : final double probabilityScore,
792- 'blocked' : final bool blocked,
793- 'severity' : final Object severity,
794- 'severityScore' : final double severityScore? ,
795- } =>
796- SafetyRating (HarmCategory ._parseValue (category),
797- HarmProbability ._parseValue (probability),
798- probabilityScore: probabilityScore,
799- isBlocked: blocked,
800- severity: HarmSeverity ._parseValue (severity),
801- severityScore: severityScore),
802- _ => throw unhandledFormat ('SafetyRating' , jsonObject),
803- };
787+ if (jsonObject is ! Map ) {
788+ throw unhandledFormat ('SafetyRating' , jsonObject);
789+ }
790+ return SafetyRating (HarmCategory ._parseValue (jsonObject['category' ]),
791+ HarmProbability ._parseValue (jsonObject['probability' ]),
792+ probabilityScore: jsonObject['probabilityScore' ] as double ? ,
793+ isBlocked: jsonObject['blocked' ] as bool ? ,
794+ severity: jsonObject['severity' ] != null
795+ ? HarmSeverity ._parseValue (jsonObject['severity' ])
796+ : null ,
797+ severityScore: jsonObject['severityScore' ] as double ? );
804798}
805799
806800CitationMetadata _parseCitationMetadata (Object ? jsonObject) {
0 commit comments