This document outlines the steps required to integrate the Mooncake module into a Flutter host app and enable communication between them.
In the host app’s pubspec.yaml:
-
Add the
xmodule as a dependency using either:- Local path: Point to the location where the Mooncake module is located.
- Git repository: If hosted on a version control system, provide the URL and branch.
-
Run
flutter pub getto install the dependencies.
In the host app’s Dart files, import the Mooncake module to make its components accessible.
Use the Flutter Navigator to push the Mooncake module onto the navigation stack. This allows the user to interact with the module and return data back to the host app.
When the user completes an action in the Mooncake module, the module will send data back to the host app. Ensure the host app:
- Receives the data via
Navigator.pop(). - Updates the user interface to reflect the returned data.
- Use
flutter runto build and launch the host app. - Trigger the Mooncake module from the host app to verify:
- The module opens as expected.
- The user can input data in the module.
- Data returns correctly to the host app upon closing the module.
- Dependency issues: Ensure paths or Git URLs are correct in
pubspec.yaml. - Navigation issues: Confirm that the host app properly pushes the Mooncake module using
Navigator. - Null return values: Handle cases where no data is returned from the module (e.g., user cancels input).
This setup allows the host app to trigger the Mooncake module and retrieve user input or other data seamlessly, ensuring smooth communication between the two.# mooncake_plugin