Dart - CRUD file in path
20201004
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:path_provider/path_provider.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await getApplicationDocumentsDirectory().then((Directory dir) {
File file = File('${dir.path}/text.txt');
file.writeAsString('123');
void read() async {
String contents = await file.readAsString();
print(contents);
}
read();
});
}
[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: FileSystemException: Cannot open file, path = '//test.txt' (OS Error: Read-only file system, errno = 30)
Comments
Post a Comment