diff --git a/example/lib/app.dart b/example/lib/app.dart index c0eeff2..ee41d0e 100644 --- a/example/lib/app.dart +++ b/example/lib/app.dart @@ -56,6 +56,11 @@ class App extends StatelessWidget { home: const SolidLogin( image: AssetImage('assets/images/app_image.jpg'), logo: AssetImage('assets/images/app_icon.jpg'), + customFolderPathList: [ + 'customDir1', + 'customDir2', + 'customDir2/customDir3', + ], child: appScaffold, ), ); diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 3335988..d429019 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -12,7 +12,11 @@ dependencies: sdk: flutter markdown_tooltip: 0.0.10 shared_preferences: ^2.5.4 - solidpod: ^0.9.0 + # solidpod: ^0.9.0 + solidpod: + git: + url: https://github.com/anusii/solidpod.git + ref: av/522_custom_folder_structure_at_initialisation_stage solidui: path: .. window_manager: ^0.5.1 diff --git a/lib/src/widgets/solid_login.dart b/lib/src/widgets/solid_login.dart index 69d0eeb..7b9e353 100644 --- a/lib/src/widgets/solid_login.dart +++ b/lib/src/widgets/solid_login.dart @@ -38,6 +38,7 @@ import 'package:solidpod/solidpod.dart' getAppNameVersion, generateDefaultFolders, generateDefaultFiles, + generateCustomFolders, setAppDirName; import 'package:url_launcher/url_launcher.dart'; @@ -81,6 +82,7 @@ class SolidLogin extends StatefulWidget { this.changeKeyButtonStyle = const ChangeKeyButtonStyle(), this.themeConfig = const SolidLoginTheme(), this.snackbarConfig = const SnackbarConfig(), + this.customFolderPathList = const [], super.key, }); @@ -154,6 +156,17 @@ class SolidLogin extends StatefulWidget { final SnackbarConfig snackbarConfig; + /// Custom list of folders to be created inside the data folder. + /// Following are few examples. + /// - Custom folder 'myDir1' will be created as '/data/myDir1' + /// - Custom folder 'data' will be created as '/data/data' + /// If multi-level folder structure is needed you need to provide + /// upper level folders first in the list. For instance, to create + /// 'myDir1/myDir2/myDir3', add three values to the list as follows + /// in that order. + /// 'myDir1', 'myDir1/myDir2', 'myDir1/myDir2/myDir3' + final List customFolderPathList; + @override State createState() => _SolidLoginState(); } @@ -266,6 +279,8 @@ class _SolidLoginState extends State with WidgetsBindingObserver { final folders = await generateDefaultFolders(); final files = await generateDefaultFiles(); + final customFolders = generateCustomFolders(widget.customFolderPathList); + // Check if widget is still mounted after async operations and before setState. // This prevents "setState() called after dispose()" errors that can occur // if the widget was disposed while async operations were running. @@ -273,7 +288,7 @@ class _SolidLoginState extends State with WidgetsBindingObserver { if (!mounted) return; setState(() { - defaultFolders = folders; + defaultFolders = folders + customFolders; defaultFiles = files; }); diff --git a/pubspec.yaml b/pubspec.yaml index df23298..254803d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -28,7 +28,11 @@ dependencies: path: ^1.9.1 rdflib: ^0.2.12 shared_preferences: ^2.5.4 - solidpod: ^0.9.0 + # solidpod: ^0.9.0 + solidpod: + git: + url: https://github.com/anusii/solidpod.git + ref: av/522_custom_folder_structure_at_initialisation_stage url_launcher: ^6.3.2 version_widget: ^1.0.6