From 6385f44e9753e578569658b5df53308a92d1358b Mon Sep 17 00:00:00 2001 From: Alexandre Roux Date: Fri, 11 Oct 2024 23:21:43 +0200 Subject: [PATCH] [app_fs] add doc --- app_fs/analysis_options.yaml | 2 +- app_fs/lib/fs.dart | 4 ++++ app_fs/lib/src/fs.dart | 4 ++++ app_fs/lib/src/fs_io.dart | 2 ++ app_fs/lib/src/fs_stub.dart | 1 + app_fs/lib/src/fs_web.dart | 1 + 6 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app_fs/analysis_options.yaml b/app_fs/analysis_options.yaml index 6fcd113..9ec37de 100644 --- a/app_fs/analysis_options.yaml +++ b/app_fs/analysis_options.yaml @@ -1,2 +1,2 @@ # tekartik flutter recommended lints (extension over google lints and pedantic) -include: package:tekartik_lints_flutter/strict.yaml \ No newline at end of file +include: package:tekartik_lints_flutter/package.yaml \ No newline at end of file diff --git a/app_fs/lib/fs.dart b/app_fs/lib/fs.dart index 0057fb5..1348728 100644 --- a/app_fs/lib/fs.dart +++ b/app_fs/lib/fs.dart @@ -13,8 +13,10 @@ export 'package:fs_shim/fs_shim.dart'; /// For testing you can use an in memory implementation for idb_shim. FileSystem get fs => src.fs; +/// The memory file system to use for your flutter application. FileSystem fsMemory = newFileSystemMemory(); +/// path provider file system extension extension AppFileSystem on FileSystem { /// Path to a directory where the application may place data that is /// user-generated, or that cannot otherwise be recreated by your application. @@ -27,6 +29,8 @@ extension AppFileSystem on FileSystem { /// to the user. /// /// On the web, it is the data root directory + /// + /// [packageName] only used on linux and windows for now Future getApplicationDocumentsDirectory( {String? packageName}) async { if (this == fs) { diff --git a/app_fs/lib/src/fs.dart b/app_fs/lib/src/fs.dart index 3116d7b..f6f7e60 100644 --- a/app_fs/lib/src/fs.dart +++ b/app_fs/lib/src/fs.dart @@ -5,9 +5,13 @@ export 'fs_stub.dart' if (dart.library.js_interop) 'fs_web.dart' if (dart.library.io) 'fs_io.dart'; +/// Data directory const dataDirectory = 'data'; + +/// Data directory path final String dataDirectoryPath = '${context.separator}$dataDirectory'; +/// Get the application file system Directory getFsApplicationDocumentsDirectory(FileSystem fs) { return fs.directory(dataDirectoryPath); } diff --git a/app_fs/lib/src/fs_io.dart b/app_fs/lib/src/fs_io.dart index 8a60840..ad2816c 100644 --- a/app_fs/lib/src/fs_io.dart +++ b/app_fs/lib/src/fs_io.dart @@ -5,8 +5,10 @@ import 'package:fs_shim/fs_io.dart' show fileSystemIo, wrapIoDirectory; import 'package:path_provider/path_provider.dart' as plugin; import 'package:process_run/shell_run.dart'; +/// File system FileSystem get fs => fileSystemIo; +/// Future getApplicationDocumentsDirectory( {String? packageName}) async { if (io.Platform.isLinux || io.Platform.isWindows) { diff --git a/app_fs/lib/src/fs_stub.dart b/app_fs/lib/src/fs_stub.dart index b5053c6..b34fb61 100644 --- a/app_fs/lib/src/fs_stub.dart +++ b/app_fs/lib/src/fs_stub.dart @@ -6,6 +6,7 @@ FileSystem get fs => _stub('fs'); /// Get the application file system FileSystem get testFs => _stub('testFs'); +/// Get the application file system Future getApplicationDocumentsDirectory({String? packageName}) => _stub('getApplicationDocumentsDirectory'); diff --git a/app_fs/lib/src/fs_web.dart b/app_fs/lib/src/fs_web.dart index 1071950..6b10c82 100644 --- a/app_fs/lib/src/fs_web.dart +++ b/app_fs/lib/src/fs_web.dart @@ -4,6 +4,7 @@ import 'package:tekartik_app_flutter_fs/src/fs.dart'; FileSystem? _fs; +/// Get the application file system FileSystem get fs => _fs ??= newFileSystemIdb(idbFactoryNative); /// Package name ignored for indexed_db, we are already in a sandbox