Answers for "flutter delete file if exists"

1

flutter delete file

Future<String> get _localPath async {
    final directory = await getApplicationDocumentsDirectory();

    return directory.path;
  }

  Future<File> get _localFile async {
    final path = await _localPath;
    print('path ${path}');
    return File('$path/counter.txt');
  }

  Future<int> deleteFile() async {
        try {
          final file = await _localFile;

          await file.delete();
        } catch (e) {
          return 0;
        }
      }
Posted by: Guest on June-30-2020

Code answers related to "flutter delete file if exists"

Code answers related to "Dart"

Browse Popular Code Answers by Language