Add download zip page

This commit is contained in:
2023-09-16 13:14:23 +08:00
parent 93a307b143
commit f2b6ad465d
13 changed files with 412 additions and 16 deletions

View File

@@ -39,4 +39,27 @@ class Path {
return _safChannel.invokeMethod(
"saveFile", [filenameWithoutExtension, dir, mimeType, bytes]);
}
Future<SAFFile> openFile(String filenameWithoutExtension, String mimeType,
{String dir = ""}) async {
final fd = await _safChannel.invokeMethod<int>(
"openFile", [filenameWithoutExtension, dir, mimeType]);
return SAFFile(fd!);
}
}
class SAFFile {
SAFFile(this._fd);
final int _fd;
bool _disposed = false;
Future<int> write(Uint8List data) async {
if (_disposed) throw Exception("File already closed");
return await Path._safChannel.invokeMethod("writeFile", [_fd, data]);
}
Future<void> dispose() async {
if (_disposed) return;
_disposed = true;
await Path._safChannel.invokeMethod("closeFile", [_fd]);
}
}