How to create a Future object for your own class. I have a simple class SimpleFile

import 'dart:io'; class SimpleFile { String OSDirSymbol; String path; String fileName; File file; SimpleFile(path, OSDirSymbol, fileName) { this.path = path; this.OSDirSymbol = OSDirSymbol; this.fileName = fileName; file = File(path + OSDirSymbol + fileName); print('${file.path}\r\n'); } writeFileAppend(String text) { file.writeAsStringSync('${text}\r\n', mode: FileMode.append); } writeFileWrite(String text) { file.writeAsStringSync('${text}\r\n', mode: FileMode.write); } readFile() { if (!file.existsSync()) { print('File not found'); return; } print('Read the file...'); print(file.readAsStringSync()); } void deleteFile() { if (!file.existsSync()) { print('File not found'); return; } print('Delete file...'); file.deleteSync(); } } 

I want to add something to the file, and after the completion of main, delete it, but nothing happens.

 import 'dart:async'; import 'dart:io'; import 'package:Dart2/simpleFile.dart'; String OSDirSymbol; String path; String fileName = 'test.txt'; void main() { path = Directory.current.path; if (Platform.isWindows) OSDirSymbol = '\\'; if (Platform.isLinux) OSDirSymbol = '/'; SimpleFile nFile = SimpleFile(path, OSDirSymbol, fileName); print('***The enD***'); } 

Future = newFile.deleteFile (); - writes that "I can not use void". Maybe I'm getting into async too early, because I'm just starting to learn, but very interesting :-) Thanks in advance for the answers and related links :-) PS Dart VM version: 2.0.0-dev.69.5 (Tue Jul 31 15:05:14 2018 +0200) on "windows_x64"

    0