From 68bb70d28d9491989e0106645ed6adaae0b4f1f9 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 1 Feb 2024 15:13:01 +0100 Subject: [PATCH] Drive-by nullability fix in BuilderInfo._decoceEnum. --- protobuf/lib/src/protobuf/builder_info.dart | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/protobuf/lib/src/protobuf/builder_info.dart b/protobuf/lib/src/protobuf/builder_info.dart index 53ea7b2ca..1ae344133 100644 --- a/protobuf/lib/src/protobuf/builder_info.dart +++ b/protobuf/lib/src/protobuf/builder_info.dart @@ -323,10 +323,13 @@ class BuilderInfo { ProtobufEnum? _decodeEnum( int tagNumber, ExtensionRegistry? registry, int rawValue) { - var f = valueOfFunc(tagNumber); - if (f == null && registry != null) { - f = registry.getExtension(qualifiedMessageName, tagNumber)!.valueOf; + final f = valueOfFunc(tagNumber); + if (f != null) { + return f(rawValue); } - return f!(rawValue); + return registry + ?.getExtension(qualifiedMessageName, tagNumber) + ?.valueOf + ?.call(rawValue); } }