writeAsBytes method
Future<File?>
writeAsBytes(
- List<
int> bytes, { - required BuildContext context,
- dynamic mode = FileMode.write,
- bool flush = false,
Calling writeAsBytes method.
FileSaver fileSaver = FileSaver(
initialFileName:'File Name',
fileTypes: const ['txt'],
);
fileSaver.writeAsBytes(bytes, context:context);
Implementation
Future<File?> writeAsBytes(List<int> bytes,
{required BuildContext context,
mode = FileMode.write,
bool flush = false}) async {
return filebrowser(context, this).then((path) {
if (path != null) {
_successMessage(context, style);
if (File(path).existsSync()) {
return File(path)
.writeAsBytes(bytes, mode: FileMode.write, flush: flush);
} else {
return File(path).writeAsBytes(bytes, mode: mode, flush: flush);
}
} else {
return null;
}
});
}