@@ -18,9 +18,9 @@ import 'utils.dart' show char, RawMapEntry, ensureUint8List;
18
18
import 'exceptions.dart' show InvalidCanonicalJsonException;
19
19
import 'fast_unorm.dart' show fastNfc;
20
20
21
- class CanonicalJsonDecoder extends Converter <List <int >, Object > {
21
+ class CanonicalJsonDecoder extends Converter <List <int >, Object ? > {
22
22
@override
23
- Object convert (List <int > input) {
23
+ Object ? convert (List <int > input) {
24
24
ArgumentError .checkNotNull (input, 'input' );
25
25
final data = ensureUint8List (input);
26
26
return Decoder (data).decode ();
@@ -42,7 +42,7 @@ bool _isAscii(String s) => s.split('').every((c) => char(c) < 128);
42
42
43
43
class _RawMapEntry extends RawMapEntry {
44
44
final int offset;
45
- _RawMapEntry (Uint8List key, Object value, this .offset) : super (key, value);
45
+ _RawMapEntry (Uint8List key, Object ? value, this .offset) : super (key, value);
46
46
}
47
47
48
48
class Decoder {
@@ -70,21 +70,21 @@ class Decoder {
70
70
}
71
71
}
72
72
73
- InvalidCanonicalJsonException _fail (String message, [int offset]) =>
73
+ InvalidCanonicalJsonException _fail (String message, [int ? offset]) =>
74
74
_InvalidCanonicalJsonException (_data, offset ?? _offset, message);
75
75
76
76
int get _value => _offset < _data.length ? _data[_offset] : - 1 ;
77
77
int get _peak => _offset + 1 < _data.length ? _data[_offset + 1 ] : - 1 ;
78
78
79
- Object decode () {
79
+ Object ? decode () {
80
80
final result = _readValue ();
81
81
if (_data.length != _offset) {
82
82
throw _fail ('expected end of input' );
83
83
}
84
84
return result;
85
85
}
86
86
87
- Object _readValue () {
87
+ Object ? _readValue () {
88
88
// 1-9, leading zeros are not allowed
89
89
if (char ('1' ) <= _value && _value <= char ('9' )) {
90
90
return _readInt ();
@@ -168,8 +168,8 @@ class Decoder {
168
168
}
169
169
170
170
/// Read a list, assumes _value is `[` .
171
- List <Object > _readList () {
172
- final result = < Object > [];
171
+ List <Object ? > _readList () {
172
+ final result = < Object ? > [];
173
173
assert (_value == char ('[' ));
174
174
_offset++ ;
175
175
if (_try (']' )) {
@@ -183,7 +183,7 @@ class Decoder {
183
183
}
184
184
185
185
/// Read a map, assumes value is `{` .
186
- Map <String , Object > _readMap () {
186
+ Map <String , Object ? > _readMap () {
187
187
assert (_value == char ('{' ));
188
188
_offset++ ;
189
189
if (_try ('}' )) {
@@ -207,7 +207,7 @@ class Decoder {
207
207
}
208
208
}
209
209
// Create object from entries and validate utf-8 encoding of keys.
210
- final result = < String , Object > {};
210
+ final result = < String , Object ? > {};
211
211
for (final entry in entries) {
212
212
result[_decodeString (entry.key, entry.offset)] = entry.value;
213
213
}
0 commit comments