txt的例子

https://blog.csdn.net/s1120080286/article/details/83239453

  1. import 'dart:io';
  2. void main(){
  3. fun1();
  4. fun2();
  5. fun3();
  6. }
  7. void fun1() {
  8. var directory = new Directory("temp1");
  9. directory.createSync();
  10. //absolute返回path为绝对路径的Directory对象
  11. print(directory.absolute.path);
  12. }
  13. void fun2() {
  14. new Directory("temp2").create().then(
  15. (dir) => print(dir.absolute.path)
  16. );
  17. }
  18. //Dart中变量的类型可以省略,包括函数
  19. fun3() async {
  20. var directory = await new Directory("temp3").create();
  21. print(directory.absolute.path);
  22. }

输出

  1. E:\DartProject\Note16\temp1
  2. E:\DartProject\Note16\temp2
  3. E:\DartProject\Note16\temp3