onDeleteFile method

void onDeleteFile(
  1. BuildContext context,
  2. String path,
  3. bool isDirectory
)

Implementation

void onDeleteFile(BuildContext context, String path, bool isDirectory) async {
  var document = isDirectory ? Directory(path) : File(path);
  await document
      .delete(recursive: true)
      .then(
        (value) => createSnackBar(
          context,
          message: StyleMyFile.snackBarSuccessfullyDeleted,
          backgroundColor: StyleMyFile.snackBarSuccessColor,
        ),
      )
      .catchError(
        (error) => createSnackBar(
          context,
          message: StyleMyFile.snackBarDeletingError,
          backgroundColor: StyleMyFile.snackBarErrorColor,
        ),
      )
      .whenComplete(() => controllerMayFiles.updateFilesList());
}