Prepare for utf8.encode() to return more precise Uint8List type (flutter/engine#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 https://github.com/dart-lang/sdk/issues/52801
This commit is contained in:
Martin Kustermann
2023-06-29 19:27:49 +02:00
committed by GitHub
parent 0f55317632
commit d6f96120e9
3 changed files with 3 additions and 3 deletions

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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);
}