@@ -12,14 +12,11 @@ import 'byte_stream.dart';
12
12
///
13
13
/// mapToQuery({"foo": "bar", "baz": "bang"});
14
14
/// //=> "foo=bar&baz=bang"
15
- String mapToQuery (Map <String , String > map, {Encoding ? encoding}) {
16
- var pairs = < List <String >> [];
17
- map.forEach ((key, value) => pairs.add ([
18
- Uri .encodeQueryComponent (key, encoding: encoding ?? utf8),
19
- Uri .encodeQueryComponent (value, encoding: encoding ?? utf8)
20
- ]));
21
- return pairs.map ((pair) => '${pair [0 ]}=${pair [1 ]}' ).join ('&' );
22
- }
15
+ String mapToQuery (Map <String , String > map, {required Encoding encoding}) =>
16
+ map.entries
17
+ .map ((e) => '${Uri .encodeQueryComponent (e .key , encoding : encoding )}'
18
+ '=${Uri .encodeQueryComponent (e .value , encoding : encoding )}' )
19
+ .join ('&' );
23
20
24
21
/// Returns the [Encoding] that corresponds to [charset] .
25
22
///
@@ -34,8 +31,6 @@ Encoding encodingForCharset(String? charset, [Encoding fallback = latin1]) {
34
31
///
35
32
/// Throws a [FormatException] if no [Encoding] was found that corresponds to
36
33
/// [charset] .
37
- ///
38
- /// [charset] may not be null.
39
34
Encoding requiredEncodingForCharset (String charset) =>
40
35
Encoding .getByName (charset) ??
41
36
(throw FormatException ('Unsupported encoding "$charset ".' ));
@@ -53,9 +48,8 @@ bool isPlainAscii(String string) => _asciiOnly.hasMatch(string);
53
48
/// If [input] is a [TypedData] , this just returns a view on [input] .
54
49
Uint8List toUint8List (List <int > input) {
55
50
if (input is Uint8List ) return input;
56
- if (input is TypedData ) {
57
- // TODO(nweiz): remove "as" when issue 11080 is fixed.
58
- return Uint8List .view ((input as TypedData ).buffer);
51
+ if (input case TypedData data) {
52
+ return Uint8List .view (data.buffer);
59
53
}
60
54
return Uint8List .fromList (input);
61
55
}
0 commit comments