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)


FileSystemException: Cannot open file OS Error: Is a directory



Comments

Popular posts from this blog

Flutter - "PlatformException(no_fragment_activity, local_auth plugin requires activity to be a FragmentActivity., null)"

Dart syntax - initSate,Build,deactive, Dispose