mirror of
https://github.com/lichess-org/mobile.git
synced 2026-05-26 13:50:52 +00:00
Decode pgn file using a byte stream
This commit is contained in:
@@ -131,8 +131,9 @@ class _BodyState extends ConsumerState<_Body> {
|
|||||||
final result = await ref.read(pickPgnFileProvider)();
|
final result = await ref.read(pickPgnFileProvider)();
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
final bytes = await result.files.single.readAsBytes();
|
final content = await const Utf8Decoder(
|
||||||
final content = utf8.decode(bytes, allowMalformed: true);
|
allowMalformed: true,
|
||||||
|
).bind(result.files.single.readAsByteStream()).join();
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ImportPgnScreen.handlePgnText(context, content);
|
ImportPgnScreen.handlePgnText(context, content);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class _FakePlatformFile extends PlatformFile {
|
|||||||
final Uint8List _fileBytes;
|
final Uint8List _fileBytes;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Uint8List> readAsBytes() async => _fileBytes;
|
Stream<Uint8List> readAsByteStream() => Stream.value(_fileBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _mockClipboard(String text) {
|
void _mockClipboard(String text) {
|
||||||
|
|||||||
Reference in New Issue
Block a user