Skip to content

Commit

Permalink
Prepare for utf8.encode() to return more precise Uint8List type (flut…
Browse files Browse the repository at this point in the history
…ter#43335)

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 authored and kjlubick committed Jul 14, 2023
1 parent 66ebf20 commit 6a1cc9e
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 6a1cc9e

Please sign in to comment.