Integrate Monday Hero to your Existing Project
Manually add dependencies and sync code for integration
If you already have a Flutter project, you can integrate it into Monday Hero by manually installing the dependencies in your workspace. After you complete the instructions on this page, use the sync function as explained on the next page. Monday Hero will automatically create the missing folders/files.
Setting Up The Localization Requirements
MHLocalizationAssetLoader is an essential custom asset loader for managing app-specific localization files and Monday Hero-generated localization files. This allows translation files under both assets/translations and assets/translations/mh_generated to be used in the app and managed separately.
Step 1: Add the 'easy_localization' package in your pubspec.yaml and complete installation by executing the following command in your project root. Check out the package documentation for more information if needed.
Step 2: Declare your asset directories in the pubspec.yaml file.
Step 3: Navigate to the file where your project's main() function is located. By default, this is the main.dart file. Add the following imports:
Step 4: Call 'await EasyLocalization.ensureInitialized();' in your main function.
Set the path as 'assets/translations'
Set assetLoader as const MHLocalizationAssetLoader()
Set child as your app instance.
Sample Configuration:
Setting Up The App Router
Flutter features an idiomatic declarative routing mechanism similar to the build methods used with widgets. To implement this mechanism in your projects with Monday Hero, you need to adjust your app definition from the MaterialApp() widget.
Step 1: Navigate to your app definition and delete the home value if your app has one.
Step 2: Set initialRoute and onGenerateRoute as follows:
You're all set! Next, synchronize the project with your local directory to obtain the missing folders and files.
Last updated