-
-
Notifications
You must be signed in to change notification settings - Fork 13
Feat: Add support custom_dir_path #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
1d13985
c1ce4b9
a0e6263
3477c32
550fe1f
35602d4
a6273f7
bf6d3b8
0e5d755
b577152
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,12 +7,15 @@ void _setAndroidConfigurations(dynamic androidConfig) { | |||||||||||||||||
|
|
||||||||||||||||||
| final androidConfigMap = Map<String, dynamic>.from(androidConfig); | ||||||||||||||||||
|
|
||||||||||||||||||
| _setAndroidAppName(androidConfigMap[_appNameKey]); | ||||||||||||||||||
| _setAndroidPackageName(androidConfigMap[_packageNameKey]); | ||||||||||||||||||
| _setAndroidAppName( | ||||||||||||||||||
| androidConfigMap[_appNameKey], androidConfigMap[_customDirPath], androidConfigMap[_host]); | ||||||||||||||||||
| _setAndroidPackageName( | ||||||||||||||||||
| androidConfigMap[_packageNameKey], androidConfigMap[_customDirPath]); | ||||||||||||||||||
| _createNewMainActivity( | ||||||||||||||||||
| lang: androidConfigMap[_languageKey], | ||||||||||||||||||
| packageName: androidConfigMap[_packageNameKey], | ||||||||||||||||||
| overrideOldPackage: androidConfigMap[_overrideOldPackageKey], | ||||||||||||||||||
| customDirPath: androidConfigMap[_customDirPath], | ||||||||||||||||||
| ); | ||||||||||||||||||
| } on _PackageRenameException catch (e) { | ||||||||||||||||||
| _logger | ||||||||||||||||||
|
|
@@ -28,21 +31,34 @@ void _setAndroidConfigurations(dynamic androidConfig) { | |||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
|
||||||||||||||||||
| /// Sets the Android app name and optionally the android:host attribute in the AndroidManifest.xml file. | |
| /// | |
| /// [appName] - The display name for the Android application. Must be a non-empty String. | |
| /// [customDirPath] - Optional custom directory path for the android/app folder, used in melos/microfrontend setups. | |
| /// If provided and non-empty, replaces the default android/app directory path when locating the manifest file. | |
| /// [host] - Optional host value to set in the AndroidManifest.xml. If provided and non-empty, sets the android:host attribute. |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The path replacement logic (customDirPath is String && customDirPath.isNotEmpty) ? path.replaceAll(...) : path is duplicated multiple times throughout the Android and iOS implementations. Consider extracting this into a helper function to improve maintainability:
String _getCustomPath(String defaultPath, String? customDirPath, String defaultDir) {
return (customDirPath is String && customDirPath.isNotEmpty)
? defaultPath.replaceAll(defaultDir, customDirPath)
: defaultPath;
}This would simplify all the path calculations and make the code more maintainable.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,10 +6,11 @@ void _setIOSConfigurations(dynamic iosConfig) { | |
| if (iosConfig is! Map) throw _PackageRenameErrors.invalidIOSConfig; | ||
|
|
||
| final iosConfigMap = Map<String, dynamic>.from(iosConfig); | ||
| final customDirPath = iosConfigMap[_customDirPath]; | ||
|
|
||
| _setIOSDisplayName(iosConfigMap[_appNameKey]); | ||
| _setIOSBundleName(iosConfigMap[_bundleNameKey]); | ||
| _setIOSPackageName(iosConfigMap[_packageNameKey]); | ||
| _setIOSDisplayName(iosConfigMap[_appNameKey], customDirPath: customDirPath); | ||
| _setIOSBundleName(iosConfigMap[_bundleNameKey], customDirPath: customDirPath); | ||
| _setIOSPackageName(iosConfigMap[_packageNameKey], customDirPath: customDirPath); | ||
| } on _PackageRenameException catch (e) { | ||
| _logger | ||
| ..e('${e.message}ERR Code: ${e.code}') | ||
|
|
@@ -24,12 +25,15 @@ void _setIOSConfigurations(dynamic iosConfig) { | |
| } | ||
| } | ||
|
|
||
| void _setIOSDisplayName(dynamic appName) { | ||
| void _setIOSDisplayName(dynamic appName, {String? customDirPath}) { | ||
|
||
| try { | ||
| if (appName == null) return; | ||
| if (appName is! String) throw _PackageRenameErrors.invalidAppName; | ||
|
|
||
| final iosInfoPlistFile = File(_iosInfoPlistFilePath); | ||
| final iosInfoPlistFilePath = (customDirPath is String && customDirPath.isNotEmpty) | ||
| ? _iosInfoPlistFilePath.replaceFirst(_iosDirPath, customDirPath) | ||
| : _iosInfoPlistFilePath; | ||
|
Comment on lines
+33
to
+35
|
||
| final iosInfoPlistFile = File(iosInfoPlistFilePath); | ||
| if (!iosInfoPlistFile.existsSync()) { | ||
| throw _PackageRenameErrors.iosInfoPlistNotFound; | ||
| } | ||
|
|
@@ -57,7 +61,7 @@ void _setIOSDisplayName(dynamic appName) { | |
| } | ||
| } | ||
|
|
||
| void _setIOSBundleName(dynamic bundleName) { | ||
| void _setIOSBundleName(dynamic bundleName, {String? customDirPath}) { | ||
| try { | ||
| if (bundleName == null) return; | ||
| if (bundleName is! String) throw _PackageRenameErrors.invalidBundleName; | ||
|
|
@@ -68,7 +72,10 @@ void _setIOSBundleName(dynamic bundleName) { | |
| ); | ||
| } | ||
|
|
||
| final iosInfoPlistFile = File(_iosInfoPlistFilePath); | ||
| final iosInfoPlistFilePath = (customDirPath is String && customDirPath.isNotEmpty) | ||
| ? _iosInfoPlistFilePath.replaceFirst(_iosDirPath, customDirPath) | ||
| : _iosInfoPlistFilePath; | ||
| final iosInfoPlistFile = File(iosInfoPlistFilePath); | ||
| if (!iosInfoPlistFile.existsSync()) { | ||
| throw _PackageRenameErrors.iosInfoPlistNotFound; | ||
| } | ||
|
|
@@ -96,12 +103,15 @@ void _setIOSBundleName(dynamic bundleName) { | |
| } | ||
| } | ||
|
|
||
| void _setIOSPackageName(dynamic packageName) { | ||
| void _setIOSPackageName(dynamic packageName, {String? customDirPath}) { | ||
| try { | ||
| if (packageName == null) return; | ||
| if (packageName is! String) throw _PackageRenameErrors.invalidPackageName; | ||
|
|
||
| final iosProjectFile = File(_iosProjectFilePath); | ||
| final iosProjectFilePath = (customDirPath is String && customDirPath.isNotEmpty) | ||
| ? _iosProjectFilePath.replaceFirst(_iosDirPath, customDirPath) | ||
| : _iosProjectFilePath; | ||
| final iosProjectFile = File(iosProjectFilePath); | ||
| if (!iosProjectFile.existsSync()) { | ||
| throw _PackageRenameErrors.iosProjectFileNotFound; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Kotlin template was changed to use
FlutterFragmentActivityinstead ofFlutterActivity, but the Java template (lines 141-143) still usesFlutterActivity. This creates an inconsistency between the two templates. Both should use the same base class, or the difference should be intentional and documented.If this change is intentional and related to supporting microfrontends, consider:
FlutterFragmentActivity