Skip to content

Commit b1ca066

Browse files
committed
Prepare for utf8.decode() to return more precise Uint8List type
To avoid analyzer warnings when `utf8.encode()` will return the more precise `Uint8List` type, we use `const Utf8Encoder().convert()` which already returns `Uint8List` See dart-lang/sdk#52801
1 parent a0ea9a3 commit b1ca066

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

packages/image_picker/image_picker_for_web/example/integration_test/image_picker_for_web_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import 'package:integration_test/integration_test.dart';
1313

1414
const String expectedStringContents = 'Hello, world!';
1515
const String otherStringContents = 'Hello again, world!';
16-
final Uint8List bytes = utf8.encode(expectedStringContents) as Uint8List;
17-
final Uint8List otherBytes = utf8.encode(otherStringContents) as Uint8List;
16+
final Uint8List bytes = const Utf8Encoder().convert(expectedStringContents);
17+
final Uint8List otherBytes = const Utf8Encoder().convert(otherStringContents);
1818
final Map<String, dynamic> options = <String, dynamic>{
1919
'type': 'text/plain',
2020
'lastModified': DateTime.utc(2017, 12, 13).millisecondsSinceEpoch,

packages/rfw/lib/src/dart/binary.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ class _BlobEncoder {
521521
}
522522

523523
void _writeString(String value) {
524-
final Uint8List buffer = utf8.encode(value) as Uint8List;
524+
final Uint8List buffer = const Utf8Encoder().convert(value);
525525
_writeInt64(buffer.length);
526526
bytes.add(buffer);
527527
}

0 commit comments

Comments
 (0)