Skip to content

Conversation

@malvinpratama
Copy link

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

- Add support for custom_dir_path on melos
@OutdatedGuy
Copy link
Owner

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 _setAndroidAppName and _setAndroidPackageName but not for _createNewMainActivity in android.

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 OutdatedGuy marked this pull request as draft August 29, 2025 10:15
@malvinpratama
Copy link
Author

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 _setAndroidAppName and _setAndroidPackageName but not for _createNewMainActivity in android.

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

@OutdatedGuy
Copy link
Owner

Hi @malvinpratama, the errors are now gone, but I still need help setting up melos. Can you help me with that for testing?

Copy link
Contributor

Copilot AI left a 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_path and host configuration keys
  • Updated Android and iOS platform implementations to support custom directory paths
  • Changed Kotlin MainActivity template from FlutterActivity to FlutterFragmentActivity

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.

Comment on lines +133 to +135
import io.flutter.embedding.android.FlutterFragmentActivity
class MainActivity : FlutterActivity()
class MainActivity : FlutterFragmentActivity()
Copy link

Copilot AI Nov 12, 2025

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:

  1. Updating the Java template to also use FlutterFragmentActivity
  2. Or explaining why the templates differ in their respective use cases

Copilot uses AI. Check for mistakes.
Comment on lines +39 to +43
final androidMainManifestFilePath =
(customDirPath is String && customDirPath.isNotEmpty)
? _androidMainManifestFilePath.replaceAll(
_androidAppDirPath, customDirPath)
: _androidMainManifestFilePath;
Copy link

Copilot AI Nov 12, 2025

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.

Copilot uses AI. Check for mistakes.
Comment on lines +33 to +35
final iosInfoPlistFilePath = (customDirPath is String && customDirPath.isNotEmpty)
? _iosInfoPlistFilePath.replaceFirst(_iosDirPath, customDirPath)
: _iosInfoPlistFilePath;
Copy link

Copilot AI Nov 12, 2025

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.

Copilot uses AI. Check for mistakes.
if (androidConfig != null) _logger.w(_majorTaskDoneLine);
}
}

Copy link

Copilot AI Nov 12, 2025

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:

  1. What customDirPath is used for (custom directory path for melos/microfrontend support)
  2. What host is used for (appears to set the android:host attribute in AndroidManifest.xml)
  3. 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) {
Suggested change
/// 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 uses AI. Check for mistakes.
}

void _setIOSDisplayName(dynamic appName) {
void _setIOSDisplayName(dynamic appName, {String? customDirPath}) {
Copy link

Copilot AI Nov 12, 2025

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}) {

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants