# Integrate Monday Hero to your Existing Project

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](https://pub.dev/packages/easy_localization/install) for more information if needed.

```
flutter pub add easy_localization
```

**Step 2:** Declare your asset directories in the pubspec.yaml file.

```
assets:
    #Localization Files
    - assets/translations/
    # Localization Files generated by Monday Hero
    - assets/translations/mh_generated/
    - assets/images/
```

**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:

```
import 'package:easy_localization/easy_localization.dart';
import 'core/localization/mh_localization_asset_loader.dart';
```

**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:

```
void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await EasyLocalization.ensureInitialized();
  runApp(
    EasyLocalization(
      supportedLocales: const [
        Locale('en', 'US'),
      ],
      path: 'assets/translations',
      assetLoader: const MHLocalizationAssetLoader(),
      fallbackLocale: const Locale('en', 'US'),
      child: const MyApp(),
    ),
  );
}
```

### 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:

```
MaterialApp(
   // ...
   initialRoute: AppRoutes.init,
   onGenerateRoute: (settings) => AppRouter.generateRoute(settings),
   // ...
    )
```

You're all set! Next, synchronize the project with your local directory to obtain the missing folders and files.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.mondayhero.io/design-to-flutter/flutter-project-base/integrate-monday-hero-to-your-existing-project.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
