small fixes for single payout and big chunck for multiple payouts

This commit is contained in:
Arseni
2026-02-05 21:58:37 +03:00
parent 8034847e46
commit b9748b8ab2
37 changed files with 1708 additions and 224 deletions

View File

@@ -0,0 +1,53 @@
import 'dart:async';
import 'package:universal_html/html.dart' as html;
class PickedCsvFile {
final String name;
final String content;
const PickedCsvFile({required this.name, required this.content});
}
abstract class CsvInputService {
Future<PickedCsvFile?> pickCsv();
}
class WebCsvInputService implements CsvInputService {
@override
Future<PickedCsvFile?> pickCsv() async {
final input = html.FileUploadInputElement()
..accept = '.csv,text/csv'
..multiple = false;
final completer = Completer<html.File?>();
input.onChange.listen((_) {
completer.complete(
input.files?.isNotEmpty == true ? input.files!.first : null,
);
});
input.click();
final file = await completer.future;
if (file == null) return null;
final reader = html.FileReader();
final readCompleter = Completer<String>();
reader.onError.listen((_) {
readCompleter.completeError(StateError('Failed to read file'));
});
reader.onLoadEnd.listen((_) {
final result = reader.result;
if (result is String) {
readCompleter.complete(result);
} else {
readCompleter.completeError(StateError('Unsupported file payload'));
}
});
reader.readAsText(file);
final content = await readCompleter.future;
return PickedCsvFile(name: file.name, content: content);
}
}