Fix that fixed32 int could be negative. (#482)
diff --git a/protobuf/CHANGELOG.md b/protobuf/CHANGELOG.md
index c5933bb..7996f2f 100644
--- a/protobuf/CHANGELOG.md
+++ b/protobuf/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 1.1.3
+
+* Fix that fixed32 int could be negative.
+
## 1.1.2
* Fix proto deserialization issue for repeated and map enum value fields
diff --git a/protobuf/lib/src/protobuf/json.dart b/protobuf/lib/src/protobuf/json.dart
index 2c48ff0..c7da43d 100644
--- a/protobuf/lib/src/protobuf/json.dart
+++ b/protobuf/lib/src/protobuf/json.dart
@@ -225,12 +225,21 @@
case PbFieldType._INT32_BIT:
case PbFieldType._SINT32_BIT:
case PbFieldType._UINT32_BIT:
- case PbFieldType._FIXED32_BIT:
case PbFieldType._SFIXED32_BIT:
if (value is int) return value;
if (value is String) return int.parse(value);
expectedType = 'int or stringified int';
break;
+ case PbFieldType._FIXED32_BIT:
+ int validatedValue;
+ if (value is int) validatedValue = value;
+ if (value is String) validatedValue = int.parse(value);
+ if (validatedValue != null && validatedValue < 0) {
+ validatedValue += 2 * (1 << 31);
+ }
+ if (validatedValue != null) return validatedValue;
+ expectedType = 'int or stringified int';
+ break;
case PbFieldType._INT64_BIT:
case PbFieldType._SINT64_BIT:
case PbFieldType._UINT64_BIT:
diff --git a/protobuf/pubspec.yaml b/protobuf/pubspec.yaml
index d7848c2..8830627 100644
--- a/protobuf/pubspec.yaml
+++ b/protobuf/pubspec.yaml
@@ -1,5 +1,5 @@
name: protobuf
-version: 1.1.2
+version: 1.1.3
description: >-
Runtime library for protocol buffers support.
Use https://pub.dev/packages/protoc_plugin to generate dart code for your '.proto' files.