File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,14 @@ import '../log.dart';
7
7
import '../model/localizations.dart' ;
8
8
import 'exception.dart' ;
9
9
10
+ /// A fused JSON + UTF-8 decoder.
11
+ ///
12
+ /// This object is an instance of [`_JsonUtf8Decoder`][1] which is
13
+ /// a fast-path present in VM and WASM standard library implementations.
14
+ ///
15
+ /// [1] : https://github.com/dart-lang/sdk/blob/6c7452ac1530fe6161023c9b3007764ab26cc96d/sdk/lib/_internal/vm/lib/convert_patch.dart#L55
16
+ final jsonUtf8Decoder = const Utf8Decoder ().fuse (const JsonDecoder ());
17
+
10
18
/// A value for an API request parameter, to use directly without JSON encoding.
11
19
class RawParameter {
12
20
RawParameter (this .value);
@@ -105,7 +113,7 @@ class ApiConnection {
105
113
Map <String , dynamic >? json;
106
114
try {
107
115
final bytes = await response.stream.toBytes ();
108
- json = jsonDecode (utf8. decode (bytes)) ;
116
+ json = jsonUtf8Decoder. convert (bytes) as Map < String , dynamic > ? ;
109
117
} catch (e) {
110
118
// We'll throw something below, seeing `json` is null.
111
119
}
You can’t perform that action at this time.
0 commit comments