Skip to content

Commit

Permalink
Prepare for utf8.encode() to return more precise Uint8List type (#43335)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mkustermann committed Jun 29, 2023
1 parent 3749980 commit e711a61
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/web_ui/test/canvaskit/fragment_program_test.dart
Expand Up @@ -186,7 +186,7 @@ void testMain() {
});

test('FragmentProgram can be created from JSON IPLR bundle', () {
final Uint8List data = utf8.encode(kJsonIPLR) as Uint8List;
final Uint8List data = const Utf8Encoder().convert(kJsonIPLR);
final CkFragmentProgram program = CkFragmentProgram.fromBytes('test', data);

expect(program.effect, isNotNull);
Expand Down
2 changes: 1 addition & 1 deletion lib/web_ui/test/engine/channel_buffers_test.dart
Expand Up @@ -23,7 +23,7 @@ void main() {
}

ByteData _makeByteData(String str) {
final Uint8List list = utf8.encode(str) as Uint8List;
final Uint8List list = const Utf8Encoder().convert(str);
final ByteBuffer buffer = list.buffer;
return ByteData.view(buffer);
}
Expand Down
2 changes: 1 addition & 1 deletion testing/dart/channel_buffers_test.dart
Expand Up @@ -12,7 +12,7 @@ import 'dart:ui' as ui;
import 'package:litetest/litetest.dart';

ByteData _makeByteData(String str) {
final Uint8List list = utf8.encode(str) as Uint8List;
final Uint8List list = const Utf8Encoder().convert(str);
final ByteBuffer buffer = list.buffer;
return ByteData.view(buffer);
}
Expand Down

0 comments on commit e711a61

Please sign in to comment.