Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter delete Directory file

Tags:

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?

like image 251
Daibaku Avatar asked Sep 28 '18 08:09

Daibaku


People also ask

What is directory in flutter?

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.

How do I list files in a directory in flutter?

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.


1 Answers

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); } 
like image 110
Günter Zöchbauer Avatar answered Sep 17 '22 19:09

Günter Zöchbauer