-
-
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?
Conversation
|
Hi @malvinpratama thanks for the PR, I see you have added an additional key to specify custom directory path, but it seems to be not implemented for every function (in android and ios) i.e. Implemented for Also I was not able to run this implementation successfully on my side. Can you add some configuration details that I need to know? P.S. Marking this PR as draft. |
@OutdatedGuy Sorry I forgot to commit that. Please check again |
|
Hi @malvinpratama, the errors are now gone, but I still need help setting up melos. Can you help me with that for testing? |
Update constants.dart
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.
Pull Request Overview
This PR adds support for custom directory paths to enable melos/microfrontend architecture setups. The feature allows users to specify where output files should be generated instead of using the default android/app and ios directories.
Key changes:
- Added
custom_dir_pathandhostconfiguration keys - Updated Android and iOS platform implementations to support custom directory paths
- Changed Kotlin MainActivity template from
FlutterActivitytoFlutterFragmentActivity
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| lib/constants.dart | Added new configuration keys (_customDirPath, _host) and updated Kotlin MainActivity template to use FlutterFragmentActivity |
| lib/platforms/android.dart | Added custom directory path support to all Android file operations and introduced host parameter for AndroidManifest.xml modification |
| lib/platforms/ios.dart | Added custom directory path support to iOS display name, bundle name, and package name configuration functions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import io.flutter.embedding.android.FlutterFragmentActivity | ||
| class MainActivity : FlutterActivity() | ||
| class MainActivity : FlutterFragmentActivity() |
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 Kotlin template was changed to use FlutterFragmentActivity instead of FlutterActivity, but the Java template (lines 141-143) still uses FlutterActivity. 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:
- Updating the Java template to also use
FlutterFragmentActivity - Or explaining why the templates differ in their respective use cases
| final androidMainManifestFilePath = | ||
| (customDirPath is String && customDirPath.isNotEmpty) | ||
| ? _androidMainManifestFilePath.replaceAll( | ||
| _androidAppDirPath, customDirPath) | ||
| : _androidMainManifestFilePath; |
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.
| final iosInfoPlistFilePath = (customDirPath is String && customDirPath.isNotEmpty) | ||
| ? _iosInfoPlistFilePath.replaceFirst(_iosDirPath, customDirPath) | ||
| : _iosInfoPlistFilePath; |
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.
Inconsistency in path replacement methods: iOS uses replaceFirst while Android uses replaceAll for the same purpose (custom directory path replacement). Since directory paths like _iosDirPath ('ios') and _androidAppDirPath ('android/app') should only appear once at the beginning of the path, both should use the same method for consistency.
Consider using replaceFirst consistently across both platforms, as it's more precise and avoids potential issues if the directory name appears elsewhere in the path.
| if (androidConfig != null) _logger.w(_majorTaskDoneLine); | ||
| } | ||
| } | ||
|
|
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 new customDirPath and host parameters lack documentation. Consider adding documentation comments to explain:
- What
customDirPathis used for (custom directory path for melos/microfrontend support) - What
hostis used for (appears to set the android:host attribute in AndroidManifest.xml) - Expected format/values for each parameter
Example:
/// Sets the Android app name in the AndroidManifest.xml file.
///
/// [appName] - The display name for the Android application
/// [customDirPath] - Optional custom directory path for the android/app folder,
/// used in melos/microfrontend setups
/// [host] - Optional host value to set in the AndroidManifest.xml
void _setAndroidAppName(dynamic appName, String? customDirPath, dynamic host) {| /// 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. |
| } | ||
|
|
||
| void _setIOSDisplayName(dynamic appName) { | ||
| void _setIOSDisplayName(dynamic appName, {String? customDirPath}) { |
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 new customDirPath parameter lacks documentation. Consider adding documentation comments to explain what it's used for and expected format:
/// Sets the iOS display name in the Info.plist file.
///
/// [appName] - The display name for the iOS application
/// [customDirPath] - Optional custom directory path for the ios folder,
/// used in melos/microfrontend setups
void _setIOSDisplayName(dynamic appName, {String? customDirPath}) {
I am not good for documentation. But this PR is for support melos/microfrontend. So, we can set where the output file will generated. For now only support on android & ios