I want to delete file in Directory
. It is created like so.
final Directory extDir = await getTemporaryDirectory(); final String dirPath = '${extDir.path}/video'; await new Directory(dirPath).create(recursive: true); final String filePath = '$dirPath/${timestamp()}.mp4';
I want to delete this specific path so that app won't heavy. How can I do this?
Does anyone have an idea?
A Directory is an object holding a path on which operations can be performed. The path to the directory can be absolute or relative. It allows access to the parent directory, since it is a FileSystemEntity.
To list all the files or folders, you have to use flutter_file_manager, path, and path_provider_ex flutter package. Add the following lines in your pubspec. yaml file to add this package in your dependency. Add read / write permissions in your android/app/src/main/AndroidManifest.
You don't need to move to the directory. You pass the path to the Directory
constructor:
import 'dart:io'; void main() { final dir = Directory(dirPath); dir.deleteSync(recursive: true); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With