Decode pgn file using a byte stream

This commit is contained in:
Vincent Velociter
2026-05-26 11:53:39 +02:00
parent 106b8d07df
commit e77a72f802
2 changed files with 4 additions and 3 deletions
+3 -2
View File
@@ -131,8 +131,9 @@ class _BodyState extends ConsumerState<_Body> {
final result = await ref.read(pickPgnFileProvider)();
if (result != null) {
final bytes = await result.files.single.readAsBytes();
final content = utf8.decode(bytes, allowMalformed: true);
final content = await const Utf8Decoder(
allowMalformed: true,
).bind(result.files.single.readAsByteStream()).join();
if (mounted) {
ImportPgnScreen.handlePgnText(context, content);
}
+1 -1
View File
@@ -21,7 +21,7 @@ class _FakePlatformFile extends PlatformFile {
final Uint8List _fileBytes;
@override
Future<Uint8List> readAsBytes() async => _fileBytes;
Stream<Uint8List> readAsByteStream() => Stream.value(_fileBytes);
}
void _mockClipboard(String text) {