├── .gitignore ├── .metadata ├── README.md ├── analysis_options.yaml ├── android ├── .gitignore ├── app │ ├── build.gradle │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── greaper │ │ │ │ └── flutter_micro_frontend │ │ │ │ └── flutter_micro_frontend │ │ │ │ └── MainActivity.kt │ │ └── res │ │ │ ├── drawable-v21 │ │ │ └── launch_background.xml │ │ │ ├── drawable │ │ │ └── launch_background.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── values-night │ │ │ └── styles.xml │ │ │ └── values │ │ │ └── styles.xml │ │ └── profile │ │ └── AndroidManifest.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties └── settings.gradle ├── assets └── images │ └── img_splash.png ├── ios ├── .gitignore ├── Flutter │ ├── AppFrameworkInfo.plist │ ├── Debug.xcconfig │ └── Release.xcconfig ├── Podfile ├── Podfile.lock ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── WorkspaceSettings.xcsettings ├── Runner │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ ├── Icon-App-20x20@1x.png │ │ │ ├── Icon-App-20x20@2x.png │ │ │ ├── Icon-App-20x20@3x.png │ │ │ ├── Icon-App-29x29@1x.png │ │ │ ├── Icon-App-29x29@2x.png │ │ │ ├── Icon-App-29x29@3x.png │ │ │ ├── Icon-App-40x40@1x.png │ │ │ ├── Icon-App-40x40@2x.png │ │ │ ├── Icon-App-40x40@3x.png │ │ │ ├── Icon-App-60x60@2x.png │ │ │ ├── Icon-App-60x60@3x.png │ │ │ ├── Icon-App-76x76@1x.png │ │ │ ├── Icon-App-76x76@2x.png │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ └── LaunchImage.imageset │ │ │ ├── Contents.json │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ └── README.md │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ └── Runner-Bridging-Header.h └── RunnerTests │ └── RunnerTests.swift ├── l10n.yaml ├── lib ├── environments │ ├── app_environment.dart │ └── environment.dart ├── main.dart ├── main_production.dart ├── main_staging.dart ├── modules │ ├── app_modules.dart │ └── base_module.dart └── presentation │ ├── app.dart │ ├── localization │ ├── intl_en.arb │ ├── intl_vi.arb │ └── localization.dart │ ├── routes.dart │ ├── screens │ ├── home │ │ └── home_screen.dart │ ├── screens.dart │ └── splash │ │ ├── splash_binding.dart │ │ ├── splash_controller.dart │ │ └── splash_screen.dart │ └── utils │ └── definition.dart ├── linux ├── .gitignore ├── CMakeLists.txt ├── flutter │ ├── CMakeLists.txt │ ├── generated_plugin_registrant.cc │ ├── generated_plugin_registrant.h │ └── generated_plugins.cmake ├── main.cc ├── my_application.cc └── my_application.h ├── macos ├── .gitignore ├── Flutter │ ├── Flutter-Debug.xcconfig │ ├── Flutter-Release.xcconfig │ └── GeneratedPluginRegistrant.swift ├── Podfile ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── Runner │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── app_icon_1024.png │ │ │ ├── app_icon_128.png │ │ │ ├── app_icon_16.png │ │ │ ├── app_icon_256.png │ │ │ ├── app_icon_32.png │ │ │ ├── app_icon_512.png │ │ │ └── app_icon_64.png │ ├── Base.lproj │ │ └── MainMenu.xib │ ├── Configs │ │ ├── AppInfo.xcconfig │ │ ├── Debug.xcconfig │ │ ├── Release.xcconfig │ │ └── Warnings.xcconfig │ ├── DebugProfile.entitlements │ ├── Info.plist │ ├── MainFlutterWindow.swift │ └── Release.entitlements └── RunnerTests │ └── RunnerTests.swift ├── melos.yaml ├── modules ├── auth │ ├── .gitignore │ ├── .metadata │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── analysis_options.yaml │ ├── l10n.yaml │ ├── lib │ │ ├── auth.dart │ │ └── src │ │ │ ├── auth_module.dart │ │ │ ├── auth_module_imp.dart │ │ │ ├── data │ │ │ ├── injection.dart │ │ │ ├── local │ │ │ │ ├── get_storage_imp.dart │ │ │ │ ├── hive_service_imp.dart │ │ │ │ └── local_service.dart │ │ │ ├── models │ │ │ │ ├── login_model.dart │ │ │ │ ├── login_model.g.dart │ │ │ │ ├── login_request_model.dart │ │ │ │ ├── login_request_model.g.dart │ │ │ │ └── models.dart │ │ │ ├── remote │ │ │ │ ├── auth_interceptor.dart │ │ │ │ └── clients │ │ │ │ │ ├── remote_client.dart │ │ │ │ │ └── remote_client.g.dart │ │ │ └── repository_imp.dart │ │ │ ├── domain │ │ │ ├── repository.dart │ │ │ └── use_cases │ │ │ │ ├── check_is_logged_in_use_case.dart │ │ │ │ └── login_use_case.dart │ │ │ └── presentation │ │ │ ├── auth_controller.dart │ │ │ ├── localization │ │ │ ├── intl_en.arb │ │ │ ├── intl_vi.arb │ │ │ └── localization.dart │ │ │ ├── routes.dart │ │ │ ├── screens │ │ │ ├── login │ │ │ │ ├── field_vm.dart │ │ │ │ ├── login_controller.dart │ │ │ │ └── login_screen.dart │ │ │ ├── login_v2 │ │ │ │ ├── login_bloc.dart │ │ │ │ ├── login_form_key.dart │ │ │ │ └── login_screen.dart │ │ │ └── screens.dart │ │ │ └── utils │ │ │ └── defination.dart │ ├── pubspec.yaml │ └── pubspec_overrides.yaml ├── core │ ├── .gitignore │ ├── .metadata │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── analysis_options.yaml │ ├── l10n.yaml │ ├── lib │ │ ├── core.dart │ │ └── src │ │ │ ├── base │ │ │ └── base_module.dart │ │ │ ├── core_module.dart │ │ │ ├── core_module_imp.dart │ │ │ ├── data │ │ │ ├── data.dart │ │ │ ├── injection.dart │ │ │ ├── mappers │ │ │ │ └── exception_mapper.dart │ │ │ └── models │ │ │ │ ├── base_response.dart │ │ │ │ ├── base_response.g.dart │ │ │ │ ├── error_model.dart │ │ │ │ └── models.dart │ │ │ ├── domain │ │ │ ├── domain.dart │ │ │ ├── models │ │ │ │ ├── exceptions │ │ │ │ │ ├── app_exception.dart │ │ │ │ │ ├── exceptions.dart │ │ │ │ │ ├── net_exception.dart │ │ │ │ │ ├── no_connection_exception.dart │ │ │ │ │ └── unknown_exception.dart │ │ │ │ └── models.dart │ │ │ └── utils │ │ │ │ ├── either.dart │ │ │ │ └── utils.dart │ │ │ ├── environment.dart │ │ │ ├── libs.dart │ │ │ └── presentation │ │ │ ├── base_bloc │ │ │ ├── base.dart │ │ │ ├── base_bloc.dart │ │ │ ├── base_bloc_event.dart │ │ │ ├── base_bloc_screen.dart │ │ │ ├── base_bloc_state.dart │ │ │ └── base_navigator │ │ │ │ ├── base_navigator_bloc.dart │ │ │ │ └── base_navigator_state.dart │ │ │ ├── base_get │ │ │ ├── base.dart │ │ │ ├── base_controller.dart │ │ │ ├── base_handle_controller.dart │ │ │ ├── base_screen.dart │ │ │ ├── base_view_status.dart │ │ │ └── base_widget.dart │ │ │ ├── localization │ │ │ ├── intl_en.arb │ │ │ ├── intl_vi.arb │ │ │ └── localization.dart │ │ │ ├── presentation.dart │ │ │ └── screens │ │ │ └── base_handle_view.dart │ ├── pubspec.yaml │ └── pubspec_overrides.yaml ├── product │ ├── .gitignore │ ├── .metadata │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── analysis_options.yaml │ ├── l10n.yaml │ ├── lib │ │ ├── product.dart │ │ └── src │ │ │ ├── data │ │ │ ├── injection.dart │ │ │ ├── mapper │ │ │ │ └── data_mapper.dart │ │ │ ├── models │ │ │ │ ├── item_model.dart │ │ │ │ ├── item_model.g.dart │ │ │ │ └── models.dart │ │ │ ├── remote │ │ │ │ └── clients │ │ │ │ │ ├── remote_client.dart │ │ │ │ │ └── remote_client.g.dart │ │ │ └── repository_imp.dart │ │ │ ├── domain │ │ │ ├── models │ │ │ │ ├── item.dart │ │ │ │ └── models.dart │ │ │ ├── repository.dart │ │ │ └── use_cases │ │ │ │ └── home_product_use_case.dart │ │ │ ├── presentation │ │ │ ├── localization │ │ │ │ ├── intl_en.arb │ │ │ │ ├── intl_vi.arb │ │ │ │ └── localization.dart │ │ │ └── routes.dart │ │ │ ├── product_module.dart │ │ │ ├── product_module_imp.dart │ │ │ └── widgets │ │ │ ├── home_product_widget │ │ │ ├── home_product_controller.dart │ │ │ └── home_product_widget.dart │ │ │ ├── home_product_widget_v2 │ │ │ ├── home_product_bloc.dart │ │ │ └── home_product_widget.dart │ │ │ └── widgets.dart │ ├── pubspec.yaml │ └── pubspec_overrides.yaml └── ui │ ├── .gitignore │ ├── .metadata │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── analysis_options.yaml │ ├── assets │ ├── fonts │ │ ├── SFProText-Bold.ttf │ │ ├── SFProText-Medium.ttf │ │ ├── SFProText-Regular.ttf │ │ └── SFProText-SemiBold.ttf │ └── images │ │ └── default_avatar.png │ ├── l10n.yaml │ ├── lib │ ├── src │ │ ├── dialogs │ │ │ ├── dialogs.dart │ │ │ └── message_dialog.dart │ │ ├── form_builder │ │ │ ├── form_builder.dart │ │ │ ├── form_builder_checkbox.dart │ │ │ ├── form_builder_decoration.dart │ │ │ └── form_builder_text_field.dart │ │ ├── libs.dart │ │ ├── list_view │ │ │ ├── grid_view_load_more.dart │ │ │ ├── list_view.dart │ │ │ └── list_view_load_more.dart │ │ ├── localization │ │ │ ├── intl_en.arb │ │ │ ├── intl_vi.arb │ │ │ └── localization.dart │ │ ├── themes │ │ │ ├── colors.dart │ │ │ ├── fonts.dart │ │ │ └── theme.dart │ │ └── ui.dart │ └── ui.dart │ └── pubspec.yaml ├── pubspec.lock ├── pubspec.yaml ├── web ├── favicon.png ├── icons │ ├── Icon-192.png │ ├── Icon-512.png │ ├── Icon-maskable-192.png │ └── Icon-maskable-512.png ├── index.html └── manifest.json └── windows ├── .gitignore ├── CMakeLists.txt ├── flutter ├── CMakeLists.txt ├── generated_plugin_registrant.cc ├── generated_plugin_registrant.h └── generated_plugins.cmake └── runner ├── CMakeLists.txt ├── Runner.rc ├── flutter_window.cpp ├── flutter_window.h ├── main.cpp ├── resource.h ├── resources └── app_icon.ico ├── runner.exe.manifest ├── utils.cpp ├── utils.h ├── win32_window.cpp └── win32_window.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | **/doc/api/ 26 | **/ios/Flutter/.last_build_id 27 | .dart_tool/ 28 | .flutter-plugins 29 | .flutter-plugins-dependencies 30 | .packages 31 | .pub-cache/ 32 | .pub/ 33 | /build/ 34 | 35 | # Symbolication related 36 | app.*.symbols 37 | 38 | # Obfuscation related 39 | app.*.map.json 40 | 41 | # Android Studio will place build artifacts here 42 | /android/app/debug 43 | /android/app/profile 44 | /android/app/release 45 | **/generated/ 46 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: "367f9ea16bfae1ca451b9cc27c1366870b187ae2" 8 | channel: "stable" 9 | 10 | project_type: app 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 17 | base_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 18 | - platform: android 19 | create_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 20 | base_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 21 | - platform: ios 22 | create_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 23 | base_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 24 | - platform: linux 25 | create_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 26 | base_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 27 | - platform: macos 28 | create_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 29 | base_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 30 | - platform: web 31 | create_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 32 | base_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 33 | - platform: windows 34 | create_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 35 | base_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 36 | 37 | # User provided section 38 | 39 | # List of Local paths (relative to this file) that should be 40 | # ignored by the migrate tool. 41 | # 42 | # Files that are not part of the templates will be ignored by default. 43 | unmanaged_files: 44 | - 'lib/main.dart' 45 | - 'ios/Runner.xcodeproj/project.pbxproj' 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## About 2 | 3 | With the concept of monorepo, a big project can be split into many small packages (call `service` or `repo`) so we can maintenance or test each module easily. 4 | 5 | ## Guide 6 | Guide is available at [Medium article](https://medium.com/@tungnd.dev/micro-frontend-in-flutter-modularization-application-dde7dea454e4). 7 | 8 | 9 | ## Run 10 | * Install Flutter 3.13.4 11 | * Install `melos` by run `dart pub global activate melos` 12 | * Run `melos bootstrap` to pub get all packages 13 | * Run `melos gen-l10n` to generate language files for all packages 14 | * Run `flutter pub get` to get and sync all libraries 15 | * Run `flutter gen-l10n` to generate language files for main app 16 | * Run on device `flutter run` 17 | 18 | ## Roadmap 19 | * [x] Build shared (ui, core) modules 20 | * [x] Build authetication module 21 | * [x] Build a functional module 22 | * [ ] Testing for shared modules 23 | * [ ] Testing for functional module 24 | * [ ] Create example for fucntional module and run locally (without Main Application) 25 | * [ ] [Improve] Now `successView()` function is confused about generic type 26 | * [ ] [Improve] Consider concept linking `controller` - `screen`, one `controller` has many `blocs`, instead of linking `bloc` - `screen` 27 | 28 | 29 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at https://dart.dev/lints. 17 | # 18 | # Instead of disabling a lint rule for the entire project in the 19 | # section below, it can also be suppressed for a single line of code 20 | # or a specific dart file by using the `// ignore: name_of_lint` and 21 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 22 | # producing the lint. 23 | rules: 24 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 25 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 26 | 27 | # Additional information about this file can be found at 28 | # https://dart.dev/guides/language/analysis-options 29 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "com.android.application" 3 | id "kotlin-android" 4 | id "dev.flutter.flutter-gradle-plugin" 5 | } 6 | 7 | def localProperties = new Properties() 8 | def localPropertiesFile = rootProject.file('local.properties') 9 | if (localPropertiesFile.exists()) { 10 | localPropertiesFile.withReader('UTF-8') { reader -> 11 | localProperties.load(reader) 12 | } 13 | } 14 | 15 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 16 | if (flutterVersionCode == null) { 17 | flutterVersionCode = '1' 18 | } 19 | 20 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 21 | if (flutterVersionName == null) { 22 | flutterVersionName = '1.0' 23 | } 24 | 25 | android { 26 | namespace "com.greaper.flutter_micro_frontend.flutter_micro_frontend" 27 | compileSdkVersion flutter.compileSdkVersion 28 | ndkVersion flutter.ndkVersion 29 | 30 | compileOptions { 31 | sourceCompatibility JavaVersion.VERSION_1_8 32 | targetCompatibility JavaVersion.VERSION_1_8 33 | } 34 | 35 | kotlinOptions { 36 | jvmTarget = '1.8' 37 | } 38 | 39 | sourceSets { 40 | main.java.srcDirs += 'src/main/kotlin' 41 | } 42 | 43 | defaultConfig { 44 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 45 | applicationId "com.greaper.flutter_micro_frontend.flutter_micro_frontend" 46 | // You can update the following values to match your application needs. 47 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. 48 | minSdkVersion flutter.minSdkVersion 49 | targetSdkVersion flutter.targetSdkVersion 50 | versionCode flutterVersionCode.toInteger() 51 | versionName flutterVersionName 52 | } 53 | 54 | buildTypes { 55 | release { 56 | // TODO: Add your own signing config for the release build. 57 | // Signing with the debug keys for now, so `flutter run --release` works. 58 | signingConfig signingConfigs.debug 59 | } 60 | } 61 | } 62 | 63 | flutter { 64 | source '../..' 65 | } 66 | 67 | dependencies {} 68 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 14 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | 29 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/greaper/flutter_micro_frontend/flutter_micro_frontend/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.greaper.flutter_micro_frontend.flutter_micro_frontend 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.7.10' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.3.0' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | mavenCentral() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | tasks.register("clean", Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip 6 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | def flutterSdkPath = { 3 | def properties = new Properties() 4 | file("local.properties").withInputStream { properties.load(it) } 5 | def flutterSdkPath = properties.getProperty("flutter.sdk") 6 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 7 | return flutterSdkPath 8 | } 9 | settings.ext.flutterSdkPath = flutterSdkPath() 10 | 11 | includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle") 12 | 13 | plugins { 14 | id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false 15 | } 16 | } 17 | 18 | include ":app" 19 | 20 | apply from: "${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle/app_plugin_loader.gradle" 21 | -------------------------------------------------------------------------------- /assets/images/img_splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/assets/images/img_splash.png -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 11.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '11.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | target 'RunnerTests' do 36 | inherit! :search_paths 37 | end 38 | end 39 | 40 | post_install do |installer| 41 | installer.pods_project.targets.each do |target| 42 | flutter_additional_ios_build_settings(target) 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Flutter (1.0.0) 3 | - flutter_native_splash (0.0.1): 4 | - Flutter 5 | - path_provider_foundation (0.0.1): 6 | - Flutter 7 | - FlutterMacOS 8 | 9 | DEPENDENCIES: 10 | - Flutter (from `Flutter`) 11 | - flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`) 12 | - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) 13 | 14 | EXTERNAL SOURCES: 15 | Flutter: 16 | :path: Flutter 17 | flutter_native_splash: 18 | :path: ".symlinks/plugins/flutter_native_splash/ios" 19 | path_provider_foundation: 20 | :path: ".symlinks/plugins/path_provider_foundation/darwin" 21 | 22 | SPEC CHECKSUMS: 23 | Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 24 | flutter_native_splash: 52501b97d1c0a5f898d687f1646226c1f93c56ef 25 | path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c 26 | 27 | PODFILE CHECKSUM: 70d9d25280d0dd177a5f637cdb0f0b0b12c6a189 28 | 29 | COCOAPODS: 1.15.2 30 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Flutter Micro Frontend 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | flutter_micro_frontend 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | CADisableMinimumFrameDurationOnPhone 45 | 46 | UIApplicationSupportsIndirectInputEvents 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /ios/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /l10n.yaml: -------------------------------------------------------------------------------- 1 | arb-dir: lib/presentation/localization 2 | template-arb-file: intl_en.arb 3 | synthetic-package: false 4 | output-dir: lib/presentation/localization/generated 5 | output-class: AppLocalizationImp -------------------------------------------------------------------------------- /lib/environments/app_environment.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_micro_frontend/modules/app_modules.dart'; 2 | 3 | import 'environment.dart'; 4 | 5 | class AppEnv extends Environment { 6 | AppEnv._({ 7 | required super.name, 8 | required super.baseUrl, 9 | required super.modules, 10 | }); 11 | 12 | static final dev = AppEnv._( 13 | name: 'development', 14 | baseUrl: "https://bbdd19e4-7ba1-4d22-8960-d3f6cf8b2e29.mock.pstmn.io/api/", 15 | modules: AppModules(), 16 | ); 17 | 18 | static final uat = AppEnv._( 19 | name: 'uat', 20 | baseUrl: "https://bbdd19e4-7ba1-4d22-8960-d3f6cf8b2e29.mock.pstmn.io/api/", 21 | modules: AppModules(), 22 | ); 23 | 24 | static final production = AppEnv._( 25 | name: 'production', 26 | baseUrl: "https://bbdd19e4-7ba1-4d22-8960-d3f6cf8b2e29.mock.pstmn.io/api/", 27 | modules: AppModules(), 28 | ); 29 | } 30 | -------------------------------------------------------------------------------- /lib/environments/environment.dart: -------------------------------------------------------------------------------- 1 | // variable can change during use app 2 | import '../modules/base_module.dart'; 3 | 4 | abstract class Environment { 5 | final String name; 6 | final String baseUrl; 7 | final BaseModules modules; 8 | 9 | const Environment({ 10 | required this.name, 11 | required this.baseUrl, 12 | required this.modules, 13 | }); 14 | } 15 | 16 | class FlavorConfig { 17 | static Environment? _env; 18 | static bool canAccessDeveloperMode = false; 19 | 20 | static List listEnvs = []; 21 | 22 | static initValue(List envs, 23 | {bool canAccessDevelopmentMode = false}) { 24 | assert(envs.isNotEmpty); 25 | listEnvs = envs; 26 | _env = envs[0]; 27 | canAccessDeveloperMode = canAccessDevelopmentMode; 28 | } 29 | 30 | static Environment get env { 31 | if (_env == null) throw Exception('Environment not set'); 32 | return _env!; 33 | } 34 | 35 | static set env(Environment env) { 36 | _env = env; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'environments/app_environment.dart'; 2 | import 'environments/environment.dart'; 3 | import 'presentation/app.dart'; 4 | 5 | void main() { 6 | FlavorConfig.initValue([AppEnv.dev, AppEnv.uat], 7 | canAccessDevelopmentMode: true); 8 | startApp(); 9 | } 10 | -------------------------------------------------------------------------------- /lib/main_production.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_micro_frontend/environments/app_environment.dart'; 2 | 3 | import 'environments/environment.dart'; 4 | import 'presentation/app.dart'; 5 | 6 | void main() { 7 | FlavorConfig.initValue([AppEnv.production]); 8 | startApp(); 9 | } 10 | -------------------------------------------------------------------------------- /lib/main_staging.dart: -------------------------------------------------------------------------------- 1 | import 'environments/app_environment.dart'; 2 | import 'environments/environment.dart'; 3 | import 'presentation/app.dart'; 4 | 5 | void main() { 6 | FlavorConfig.initValue([AppEnv.dev, AppEnv.uat], 7 | canAccessDevelopmentMode: true); 8 | startApp(); 9 | } 10 | -------------------------------------------------------------------------------- /lib/modules/app_modules.dart: -------------------------------------------------------------------------------- 1 | import 'package:auth/auth.dart'; 2 | import 'package:flutter/widgets.dart'; 3 | import 'package:flutter_micro_frontend/modules/base_module.dart'; 4 | import 'package:core/core.dart'; 5 | import 'package:product/product.dart'; 6 | import 'package:ui/ui.dart'; 7 | 8 | import '../environments/environment.dart'; 9 | 10 | class AppModules extends BaseModules { 11 | AppModules(); 12 | 13 | final List modules = []; 14 | 15 | @override 16 | void initEnv() { 17 | modules.addAll([ 18 | CoreModule.newInstance( 19 | environment: CoreEnvironment(baseUrl: FlavorConfig.env.baseUrl)), 20 | AuthModule.instance, 21 | ProductModule.instance 22 | ]); 23 | } 24 | 25 | @override 26 | List get localizationsDelegates => [ 27 | ...modules.map((e) => e.localizationsDelegate).toList(), 28 | UI.localizationsDelegate 29 | ]; 30 | 31 | @override 32 | Future inject() async { 33 | await Future.wait(modules.map((e) => e.inject()).toList()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/modules/base_module.dart: -------------------------------------------------------------------------------- 1 | import 'package:core/core.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | abstract class BaseModules { 5 | const BaseModules(); 6 | 7 | List> get localizationsDelegates; 8 | 9 | void initEnv(); 10 | 11 | Future inject(); 12 | } 13 | -------------------------------------------------------------------------------- /lib/presentation/app.dart: -------------------------------------------------------------------------------- 1 | import 'package:core/core.dart'; 2 | import 'package:flutter/foundation.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter/services.dart'; 5 | import 'package:flutter_micro_frontend/presentation/localization/localization.dart'; 6 | import 'package:flutter_native_splash/flutter_native_splash.dart'; 7 | import 'package:ui/ui.dart'; 8 | 9 | import '../environments/environment.dart'; 10 | import 'routes.dart'; 11 | 12 | void startApp() async { 13 | WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized(); 14 | FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding); 15 | Logger.root.onRecord.listen((record) { 16 | if (kDebugMode) { 17 | print('${record.level.name}: ${record.time}: ${record.message}'); 18 | } 19 | }); 20 | FlavorConfig.env.modules.initEnv(); 21 | await FlavorConfig.env.modules.inject(); 22 | SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle( 23 | statusBarColor: Colors.transparent, 24 | statusBarBrightness: Brightness.dark)); 25 | SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); 26 | runApp(const MyApp()); 27 | } 28 | 29 | class MyApp extends StatefulWidget { 30 | const MyApp({Key? key}) : super(key: key); 31 | 32 | @override 33 | State createState() => MyAppState(); 34 | 35 | static MyAppState? of(BuildContext context) => 36 | context.findAncestorStateOfType(); 37 | } 38 | 39 | class MyAppState extends State { 40 | @override 41 | Widget build(BuildContext context) { 42 | return AnnotatedRegion( 43 | value: SystemUiOverlayStyle.dark, 44 | child: GetMaterialApp( 45 | title: 'Flutter Micro Frontend', 46 | theme: uiTheme, 47 | debugShowCheckedModeBanner: false, 48 | localizationsDelegates: [ 49 | GlobalMaterialLocalizations.delegate, 50 | GlobalWidgetsLocalizations.delegate, 51 | GlobalCupertinoLocalizations.delegate, 52 | AppLocalization.delegate, 53 | ...FlavorConfig.env.modules.localizationsDelegates 54 | ], 55 | locale: Get.deviceLocale, 56 | supportedLocales: const [ 57 | Locale.fromSubtags(languageCode: 'en'), 58 | Locale.fromSubtags(languageCode: 'vi'), 59 | ], 60 | initialRoute: MainRouteName.splash, 61 | getPages: [...MainRoutePages.pages], 62 | ), 63 | ); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /lib/presentation/localization/intl_en.arb: -------------------------------------------------------------------------------- 1 | { 2 | 3 | } -------------------------------------------------------------------------------- /lib/presentation/localization/intl_vi.arb: -------------------------------------------------------------------------------- 1 | { 2 | } -------------------------------------------------------------------------------- /lib/presentation/localization/localization.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'package:flutter/foundation.dart'; 3 | import 'package:flutter/widgets.dart'; 4 | import 'generated/app_localizations.dart'; 5 | import 'generated/app_localizations_en.dart'; 6 | 7 | /// The actual `Localizations` class is [AppLocalizationImp], this class exists only for forward compatibility purposes... 8 | 9 | class AppLocalization { 10 | AppLocalization._(); 11 | 12 | static AppLocalizationImp of(BuildContext context) { 13 | return Localizations.of( 14 | context, AppLocalizationImp) ?? 15 | _default; 16 | } 17 | 18 | static const LocalizationsDelegate delegate = 19 | AppLocalizationsDelegate(); 20 | static const List> localizationsDelegates = 21 | AppLocalizationImp.localizationsDelegates; 22 | 23 | static const List supportedLocales = 24 | AppLocalizationImp.supportedLocales; 25 | static final _default = AppLocalizationImpEn(); 26 | static AppLocalizationImp? _current; 27 | 28 | static void setCurrentInstance(AppLocalizationImp? current) => 29 | _current = current; 30 | 31 | static AppLocalizationImp get current => _current ?? _default; 32 | } 33 | 34 | class AppLocalizationsDelegate 35 | extends LocalizationsDelegate { 36 | const AppLocalizationsDelegate(); 37 | 38 | @override 39 | Future load(Locale locale) { 40 | final instance = lookupAppLocalizationImp(locale); 41 | AppLocalization.setCurrentInstance(instance); 42 | return SynchronousFuture(instance); 43 | } 44 | 45 | @override 46 | bool isSupported(Locale locale) => AppLocalizationImp.supportedLocales 47 | .map((e) => e.languageCode) 48 | .contains(locale.languageCode); 49 | 50 | @override 51 | bool shouldReload(AppLocalizationsDelegate old) => false; 52 | } 53 | -------------------------------------------------------------------------------- /lib/presentation/routes.dart: -------------------------------------------------------------------------------- 1 | import 'package:core/core.dart'; 2 | 3 | import 'screens/screens.dart'; 4 | 5 | class MainRouteName { 6 | static const splash = '/'; 7 | static const home = '/home'; 8 | } 9 | 10 | class MainRoutePages { 11 | static final pages = [ 12 | GetPage( 13 | name: MainRouteName.splash, 14 | page: () => const SplashScreen(), 15 | binding: SplashBinding()), 16 | GetPage( 17 | name: MainRouteName.home, 18 | page: () => const HomeScreen(), 19 | transitionDuration: const Duration(seconds: 0)), 20 | ]; 21 | } 22 | -------------------------------------------------------------------------------- /lib/presentation/screens/home/home_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:product/product.dart'; 3 | 4 | class HomeScreen extends StatelessWidget { 5 | const HomeScreen({super.key}); 6 | 7 | @override 8 | Widget build(BuildContext context) { 9 | return Scaffold( 10 | appBar: AppBar( 11 | title: const Text('App bar'), 12 | ), 13 | body: SafeArea(child: HomeProductWidget())); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /lib/presentation/screens/screens.dart: -------------------------------------------------------------------------------- 1 | export 'home/home_screen.dart'; 2 | export 'splash/splash_screen.dart'; 3 | export 'splash/splash_binding.dart'; -------------------------------------------------------------------------------- /lib/presentation/screens/splash/splash_binding.dart: -------------------------------------------------------------------------------- 1 | import 'package:core/core.dart'; 2 | import 'package:flutter_micro_frontend/presentation/screens/splash/splash_controller.dart'; 3 | 4 | class SplashBinding extends Bindings { 5 | @override 6 | void dependencies() { 7 | Get.put(SplashController()); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /lib/presentation/screens/splash/splash_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:auth/auth.dart'; 2 | import 'package:core/core.dart'; 3 | import 'package:flutter_micro_frontend/presentation/routes.dart'; 4 | import 'package:flutter_native_splash/flutter_native_splash.dart'; 5 | 6 | class SplashController extends BaseController { 7 | @override 8 | void onReady() async { 9 | super.onReady(); 10 | final isAuth = AuthModule.instance.isAuth(); 11 | if (isAuth) { 12 | // do other task 13 | _goToHome(); 14 | FlutterNativeSplash.remove(); 15 | return; 16 | } 17 | FlutterNativeSplash.remove(); 18 | await AuthModule.instance.start(Get.context!); 19 | _goToHome(); 20 | } 21 | 22 | void _goToHome() { 23 | Get.offNamedUntil(MainRouteName.home, (route) => false); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lib/presentation/screens/splash/splash_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_micro_frontend/presentation/utils/definition.dart'; 3 | 4 | class SplashScreen extends StatelessWidget { 5 | const SplashScreen({super.key}); 6 | 7 | @override 8 | Widget build(BuildContext context) { 9 | return Scaffold( 10 | backgroundColor: Colors.black, 11 | body: Center( 12 | child: Image.asset(ImageConst.splash), 13 | ), 14 | ); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/presentation/utils/definition.dart: -------------------------------------------------------------------------------- 1 | class ImageConst { 2 | static const _path = "assets/images/"; 3 | static const splash = "${_path}img_splash.png"; 4 | } 5 | -------------------------------------------------------------------------------- /linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.10) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | 12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 13 | # which isn't available in 3.10. 14 | function(list_prepend LIST_NAME PREFIX) 15 | set(NEW_LIST "") 16 | foreach(element ${${LIST_NAME}}) 17 | list(APPEND NEW_LIST "${PREFIX}${element}") 18 | endforeach(element) 19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 20 | endfunction() 21 | 22 | # === Flutter Library === 23 | # System-level dependencies. 24 | find_package(PkgConfig REQUIRED) 25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 28 | 29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 30 | 31 | # Published to parent scope for install step. 32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 36 | 37 | list(APPEND FLUTTER_LIBRARY_HEADERS 38 | "fl_basic_message_channel.h" 39 | "fl_binary_codec.h" 40 | "fl_binary_messenger.h" 41 | "fl_dart_project.h" 42 | "fl_engine.h" 43 | "fl_json_message_codec.h" 44 | "fl_json_method_codec.h" 45 | "fl_message_codec.h" 46 | "fl_method_call.h" 47 | "fl_method_channel.h" 48 | "fl_method_codec.h" 49 | "fl_method_response.h" 50 | "fl_plugin_registrar.h" 51 | "fl_plugin_registry.h" 52 | "fl_standard_message_codec.h" 53 | "fl_standard_method_codec.h" 54 | "fl_string_codec.h" 55 | "fl_value.h" 56 | "fl_view.h" 57 | "flutter_linux.h" 58 | ) 59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 60 | add_library(flutter INTERFACE) 61 | target_include_directories(flutter INTERFACE 62 | "${EPHEMERAL_DIR}" 63 | ) 64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 65 | target_link_libraries(flutter INTERFACE 66 | PkgConfig::GTK 67 | PkgConfig::GLIB 68 | PkgConfig::GIO 69 | ) 70 | add_dependencies(flutter flutter_assemble) 71 | 72 | # === Flutter tool backend === 73 | # _phony_ is a non-existent file to force this command to run every time, 74 | # since currently there's no way to get a full input/output list from the 75 | # flutter tool. 76 | add_custom_command( 77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 79 | COMMAND ${CMAKE_COMMAND} -E env 80 | ${FLUTTER_TOOL_ENVIRONMENT} 81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 83 | VERBATIM 84 | ) 85 | add_custom_target(flutter_assemble DEPENDS 86 | "${FLUTTER_LIBRARY}" 87 | ${FLUTTER_LIBRARY_HEADERS} 88 | ) 89 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | 10 | void fl_register_plugins(FlPluginRegistry* registry) { 11 | } 12 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | ) 7 | 8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 9 | ) 10 | 11 | set(PLUGIN_BUNDLED_LIBRARIES) 12 | 13 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 18 | endforeach(plugin) 19 | 20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 23 | endforeach(ffi_plugin) 24 | -------------------------------------------------------------------------------- /linux/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /linux/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import path_provider_foundation 9 | 10 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 11 | PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) 12 | } 13 | -------------------------------------------------------------------------------- /macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.14' 2 | 3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 5 | 6 | project 'Runner', { 7 | 'Debug' => :debug, 8 | 'Profile' => :release, 9 | 'Release' => :release, 10 | } 11 | 12 | def flutter_root 13 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) 14 | unless File.exist?(generated_xcode_build_settings_path) 15 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" 16 | end 17 | 18 | File.foreach(generated_xcode_build_settings_path) do |line| 19 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 20 | return matches[1].strip if matches 21 | end 22 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" 23 | end 24 | 25 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 26 | 27 | flutter_macos_podfile_setup 28 | 29 | target 'Runner' do 30 | use_frameworks! 31 | use_modular_headers! 32 | 33 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) 34 | target 'RunnerTests' do 35 | inherit! :search_paths 36 | end 37 | end 38 | 39 | post_install do |installer| 40 | installer.pods_project.targets.each do |target| 41 | flutter_additional_macos_build_settings(target) 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "app_icon_16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "app_icon_32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "app_icon_32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "app_icon_64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "app_icon_128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "app_icon_256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "app_icon_256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "app_icon_512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "app_icon_512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "app_icon_1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = flutter_micro_frontend 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.greaper.fluttermicrofrontend.flutterMicroFrontend 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2024 com.greaper.flutter_micro_frontend. All rights reserved. 15 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.server 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | $(PRODUCT_COPYRIGHT) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import FlutterMacOS 2 | import Cocoa 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /melos.yaml: -------------------------------------------------------------------------------- 1 | name: flutter-micro-frontend 2 | 3 | packages: 4 | - modules/* 5 | 6 | command: 7 | bootstrap: 8 | runPubGetInParallel: false 9 | 10 | scripts: 11 | gen-l10n: 12 | exec: flutter gen-l10n 13 | ignoreErrors: true -------------------------------------------------------------------------------- /modules/auth/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. 26 | /pubspec.lock 27 | **/doc/api/ 28 | .dart_tool/ 29 | .packages 30 | build/ 31 | -------------------------------------------------------------------------------- /modules/auth/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: "367f9ea16bfae1ca451b9cc27c1366870b187ae2" 8 | channel: "stable" 9 | 10 | project_type: package 11 | -------------------------------------------------------------------------------- /modules/auth/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.0.1 2 | 3 | * TODO: Describe initial release. 4 | -------------------------------------------------------------------------------- /modules/auth/LICENSE: -------------------------------------------------------------------------------- 1 | TODO: Add your license here. 2 | -------------------------------------------------------------------------------- /modules/auth/README.md: -------------------------------------------------------------------------------- 1 | 13 | 14 | TODO: Put a short description of the package here that helps potential users 15 | know whether this package might be useful for them. 16 | 17 | ## Features 18 | 19 | TODO: List what your package can do. Maybe include images, gifs, or videos. 20 | 21 | ## Getting started 22 | 23 | TODO: List prerequisites and provide or point to information on how to 24 | start using the package. 25 | 26 | ## Usage 27 | 28 | TODO: Include short and useful examples for package users. Add longer examples 29 | to `/example` folder. 30 | 31 | ```dart 32 | const like = 'sample'; 33 | ``` 34 | 35 | ## Additional information 36 | 37 | TODO: Tell users more about the package: where to find more information, how to 38 | contribute to the package, how to file issues, what response they can expect 39 | from the package authors, and more. 40 | -------------------------------------------------------------------------------- /modules/auth/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:flutter_lints/flutter.yaml 2 | 3 | # Additional information about this file can be found at 4 | # https://dart.dev/guides/language/analysis-options 5 | -------------------------------------------------------------------------------- /modules/auth/l10n.yaml: -------------------------------------------------------------------------------- 1 | arb-dir: lib/src/presentation/localization 2 | template-arb-file: intl_en.arb 3 | output-class: ModuleLocalizationImp 4 | synthetic-package: false 5 | output-dir: lib/src/presentation/localization/generated -------------------------------------------------------------------------------- /modules/auth/lib/auth.dart: -------------------------------------------------------------------------------- 1 | library auth; 2 | 3 | export 'src/auth_module.dart'; 4 | -------------------------------------------------------------------------------- /modules/auth/lib/src/auth_module.dart: -------------------------------------------------------------------------------- 1 | import 'package:core/core.dart'; 2 | import 'package:flutter/widgets.dart'; 3 | 4 | import 'data/injection.dart'; 5 | import 'presentation/auth_controller.dart'; 6 | import 'presentation/localization/localization.dart'; 7 | 8 | part 'auth_module_imp.dart'; 9 | 10 | abstract class AuthModule extends BaseModule { 11 | static final AuthModule _instance = _AuthModuleImp(); 12 | 13 | static AuthModule get instance { 14 | return _instance; 15 | } 16 | 17 | Future start(BuildContext context); 18 | 19 | bool isAuth(); 20 | } 21 | -------------------------------------------------------------------------------- /modules/auth/lib/src/auth_module_imp.dart: -------------------------------------------------------------------------------- 1 | part of 'auth_module.dart'; 2 | 3 | class _AuthModuleImp extends AuthModule { 4 | _AuthModuleImp(); 5 | 6 | @override 7 | Future inject() async { 8 | await DataInjection().inject(); 9 | GetIt.instance.registerSingleton(AuthController()); 10 | } 11 | 12 | @override 13 | LocalizationsDelegate get localizationsDelegate => 14 | ModuleLocalization.delegate; 15 | 16 | @override 17 | Future start(BuildContext context) { 18 | return GetIt.instance.get().auth(context); 19 | } 20 | 21 | @override 22 | bool isAuth() { 23 | return GetIt.instance.get().isAuth(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /modules/auth/lib/src/data/injection.dart: -------------------------------------------------------------------------------- 1 | import 'package:auth/src/data/local/get_storage_imp.dart'; 2 | import 'package:core/core.dart'; 3 | 4 | import '../domain/repository.dart'; 5 | import 'local/local_service.dart'; 6 | import 'remote/auth_interceptor.dart'; 7 | import 'remote/clients/remote_client.dart'; 8 | import 'repository_imp.dart'; 9 | 10 | class DataInjection { 11 | final _getIt = GetIt.instance; 12 | 13 | Future inject() async { 14 | await _injectLocalService(); 15 | _injectRemoteService(); 16 | } 17 | 18 | Future _injectLocalService() async { 19 | _getIt.registerSingleton(GetStorageImp()); 20 | await _getIt.get().initialize(); 21 | } 22 | 23 | void _injectRemoteService() { 24 | _getIt.registerLazySingleton(() => RemoteClient(_getIt.get())); 25 | _getIt.registerLazySingleton(() => AuthRepositoryImp( 26 | _getIt.get(), _getIt.get())); 27 | _getIt.registerLazySingleton( 28 | () => AuthInterceptor(_getIt.get(), _getIt.get())); 29 | 30 | _getIt.get().interceptors.add(_getIt.get()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /modules/auth/lib/src/data/local/get_storage_imp.dart: -------------------------------------------------------------------------------- 1 | import 'package:core/core.dart'; 2 | 3 | import 'local_service.dart'; 4 | 5 | class GetStorageImp extends LocalService { 6 | @override 7 | String? get accessToken => GetStorage(prefBox).read(keyAccessToken); 8 | 9 | @override 10 | Future initialize() { 11 | return GetStorage.init(prefBox); 12 | } 13 | 14 | @override 15 | Future saveAccessToken(String accessToken) { 16 | return GetStorage(prefBox).write(keyAccessToken, accessToken); 17 | } 18 | 19 | @override 20 | String? get refreshToken => GetStorage(prefBox).read(keyRefreshToken); 21 | 22 | @override 23 | Future saveRefreshToken(String refreshToken) { 24 | return GetStorage(prefBox).write(keyRefreshToken, refreshToken); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /modules/auth/lib/src/data/local/hive_service_imp.dart: -------------------------------------------------------------------------------- 1 | import 'package:core/core.dart'; 2 | 3 | import 'local_service.dart'; 4 | 5 | class HiveServiceImp extends LocalService { 6 | @override 7 | Future saveAccessToken(String accessToken) { 8 | return Hive.box(prefBox).put(keyAccessToken, accessToken); 9 | } 10 | 11 | @override 12 | Future initialize() async { 13 | final appDocumentDirectory = await getApplicationDocumentsDirectory(); 14 | Hive.init(appDocumentDirectory.path); 15 | await Hive.openBox(prefBox); 16 | } 17 | 18 | @override 19 | String? get accessToken => Hive.box(prefBox).get(keyAccessToken); 20 | 21 | @override 22 | String? get refreshToken => Hive.box(prefBox).get(keyRefreshToken); 23 | 24 | @override 25 | Future saveRefreshToken(String refreshToken) { 26 | return Hive.box(prefBox).put(keyRefreshToken, refreshToken); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /modules/auth/lib/src/data/local/local_service.dart: -------------------------------------------------------------------------------- 1 | abstract class LocalService { 2 | final String prefBox = "AuthCache"; 3 | final String keyAccessToken = "AccessToken"; 4 | final String keyRefreshToken = "RefreshToken"; 5 | 6 | Future initialize(); 7 | 8 | String? get accessToken; 9 | 10 | String? get refreshToken; 11 | 12 | Future saveAccessToken(String accessToken); 13 | 14 | Future saveRefreshToken(String refreshToken); 15 | } 16 | -------------------------------------------------------------------------------- /modules/auth/lib/src/data/models/login_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:core/core.dart'; 2 | 3 | part 'login_model.g.dart'; 4 | 5 | @JsonSerializable() 6 | class LoginModel { 7 | String accessToken; 8 | String refreshToken; 9 | 10 | LoginModel(this.accessToken, this.refreshToken); 11 | 12 | factory LoginModel.fromJson(Map json) => _$LoginModelFromJson(json); 13 | } -------------------------------------------------------------------------------- /modules/auth/lib/src/data/models/login_model.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'login_model.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | LoginModel _$LoginModelFromJson(Map json) => LoginModel( 10 | json['accessToken'] as String, 11 | json['refreshToken'] as String, 12 | ); 13 | 14 | Map _$LoginModelToJson(LoginModel instance) => 15 | { 16 | 'accessToken': instance.accessToken, 17 | 'refreshToken': instance.refreshToken, 18 | }; 19 | -------------------------------------------------------------------------------- /modules/auth/lib/src/data/models/login_request_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:core/core.dart'; 2 | 3 | part 'login_request_model.g.dart'; 4 | 5 | @JsonSerializable() 6 | class LoginRequestModel { 7 | String username; 8 | String password; 9 | LoginRequestModel(this.username, this.password); 10 | 11 | Map toJson() => _$LoginRequestModelToJson(this); 12 | } -------------------------------------------------------------------------------- /modules/auth/lib/src/data/models/login_request_model.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'login_request_model.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | LoginRequestModel _$LoginRequestModelFromJson(Map json) => 10 | LoginRequestModel( 11 | json['username'] as String, 12 | json['password'] as String, 13 | ); 14 | 15 | Map _$LoginRequestModelToJson(LoginRequestModel instance) => 16 | { 17 | 'username': instance.username, 18 | 'password': instance.password, 19 | }; 20 | -------------------------------------------------------------------------------- /modules/auth/lib/src/data/models/models.dart: -------------------------------------------------------------------------------- 1 | export 'login_model.dart'; 2 | export 'login_request_model.dart'; -------------------------------------------------------------------------------- /modules/auth/lib/src/data/remote/auth_interceptor.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:core/core.dart'; 4 | 5 | import '../../domain/repository.dart'; 6 | 7 | class AuthInterceptor extends QueuedInterceptorsWrapper { 8 | final Dio _dio; 9 | final Repository _repository; 10 | 11 | AuthInterceptor(this._dio, this._repository); 12 | 13 | @override 14 | void onRequest(RequestOptions options, RequestInterceptorHandler handler) { 15 | final token = _repository.cacheAccessToken; 16 | if (token != null) { 17 | options.headers[HttpHeaders.authorizationHeader] = token; 18 | } 19 | super.onRequest(options, handler); 20 | } 21 | 22 | @override 23 | void onError(DioException err, ErrorInterceptorHandler handler) async { 24 | try { 25 | if (err.response?.statusCode == 401) { 26 | // final refreshTokenDio = Dio(_dio.options); 27 | _dio.httpClientAdapter = _dio.httpClientAdapter; 28 | final requestOptions = err.requestOptions; 29 | final currentAuthInterceptor = _dio.interceptors 30 | .firstWhereOrNull((element) => element is AuthInterceptor); 31 | _dio.interceptors.removeWhere((element) => element is AuthInterceptor); 32 | final newToken = await _repository.refreshToken(); 33 | if (newToken != null) { 34 | requestOptions.headers[HttpHeaders.authorizationHeader] = newToken; 35 | final response = await _dio.fetch(requestOptions); 36 | if (currentAuthInterceptor != null) { 37 | _dio.interceptors.insert(0, currentAuthInterceptor); 38 | } 39 | return handler.resolve(response); 40 | } else { 41 | if (currentAuthInterceptor != null) { 42 | _dio.interceptors.insert(0, currentAuthInterceptor); 43 | } 44 | super.onError(err, handler); 45 | } 46 | } else { 47 | super.onError(err, handler); 48 | } 49 | } catch (e) { 50 | if (e is DioException) { 51 | super.onError(e, handler); 52 | } else { 53 | super.onError(err.copyWith(error: e), handler); 54 | } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /modules/auth/lib/src/data/remote/clients/remote_client.dart: -------------------------------------------------------------------------------- 1 | import 'package:core/core.dart'; 2 | 3 | import '../../models/models.dart'; 4 | 5 | part 'remote_client.g.dart'; 6 | 7 | @RestApi() 8 | abstract class RemoteClient { 9 | factory RemoteClient(Dio dio) = _RemoteClient; 10 | 11 | @POST('/refresh_token') 12 | Future> refreshToken(@Field("refreshToken") String refreshToken); 13 | 14 | @POST('/login') 15 | Future> login(@Body() LoginRequestModel model); 16 | } -------------------------------------------------------------------------------- /modules/auth/lib/src/data/repository_imp.dart: -------------------------------------------------------------------------------- 1 | import 'package:auth/src/data/remote/clients/remote_client.dart'; 2 | import 'package:auth/src/domain/repository.dart'; 3 | import 'package:core/core.dart'; 4 | 5 | import 'local/local_service.dart'; 6 | import 'models/models.dart'; 7 | 8 | class AuthRepositoryImp extends Repository with ExceptionMapper { 9 | LocalService localService; 10 | RemoteClient authClient; 11 | 12 | AuthRepositoryImp(this.localService, this.authClient); 13 | 14 | @override 15 | String? get cacheAccessToken => localService.accessToken; 16 | 17 | @override 18 | String? get cacheRefreshToken => localService.refreshToken; 19 | 20 | @override 21 | Future saveCacheAccessToken(String accessToken) => 22 | localService.saveAccessToken(accessToken); 23 | 24 | @override 25 | Future saveCacheRefreshToken(String refreshToken) => 26 | localService.saveRefreshToken(refreshToken); 27 | 28 | @override 29 | Future refreshToken() async { 30 | final refreshToken = localService.refreshToken; 31 | if (refreshToken == null) return null; 32 | final newToken = await authClient.refreshToken(refreshToken); 33 | if (newToken.data != null) { 34 | await saveCacheAccessToken(newToken.data!); 35 | } 36 | return newToken.data; 37 | } 38 | 39 | @override 40 | Future login(String username, String password) async { 41 | try { 42 | final response = 43 | await authClient.login(LoginRequestModel(username, password)); 44 | if (response.data != null) { 45 | await saveCacheAccessToken(response.data!.accessToken); 46 | await saveCacheRefreshToken(response.data!.refreshToken); 47 | } 48 | } catch (e) { 49 | throw mapException(e); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /modules/auth/lib/src/domain/repository.dart: -------------------------------------------------------------------------------- 1 | abstract class Repository { 2 | 3 | String? get cacheAccessToken; 4 | 5 | String? get cacheRefreshToken; 6 | 7 | Future saveCacheAccessToken(String accessToken); 8 | 9 | Future saveCacheRefreshToken(String refreshToken); 10 | 11 | Future refreshToken(); 12 | 13 | Future login(String username, String password); 14 | } 15 | -------------------------------------------------------------------------------- /modules/auth/lib/src/domain/use_cases/check_is_logged_in_use_case.dart: -------------------------------------------------------------------------------- 1 | import 'package:auth/src/domain/repository.dart'; 2 | import 'package:core/core.dart'; 3 | 4 | class CheckIsLoggedInUseCase { 5 | final Repository _repository; 6 | 7 | CheckIsLoggedInUseCase(this._repository); 8 | 9 | Either execute() { 10 | try { 11 | final token = _repository.cacheAccessToken; 12 | return Left(token != null); 13 | } on AppException catch (e) { 14 | return Right(e); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /modules/auth/lib/src/domain/use_cases/login_use_case.dart: -------------------------------------------------------------------------------- 1 | import 'package:auth/src/domain/repository.dart'; 2 | import 'package:core/core.dart'; 3 | 4 | class LoginUseCase { 5 | final Repository _repository; 6 | 7 | LoginUseCase(this._repository); 8 | 9 | Future> execute( 10 | String username, String password) async { 11 | try { 12 | await _repository.login(username, password); 13 | return const Left(null); 14 | } on AppException catch (e) { 15 | return Right(e); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /modules/auth/lib/src/presentation/auth_controller.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:auth/src/domain/repository.dart'; 4 | import 'package:auth/src/domain/use_cases/check_is_logged_in_use_case.dart'; 5 | import 'package:auth/src/presentation/routes.dart'; 6 | import 'package:core/core.dart'; 7 | import 'package:flutter/cupertino.dart'; 8 | 9 | class AuthController with BaseHandleView { 10 | late Completer completer; 11 | 12 | Future auth(BuildContext context) { 13 | completer = Completer(); 14 | final result = CheckIsLoggedInUseCase(GetIt.instance.get()).execute(); 15 | result.fold((left) { 16 | if (left) { 17 | completer.complete(); 18 | } else { 19 | Navigator.pushAndRemoveUntil(context, Routes.checkPhone(), (route) => false); 20 | } 21 | }, (right) { 22 | showError(context, right); 23 | }); 24 | return completer.future; 25 | } 26 | 27 | void loginSuccessfully() { 28 | if (!completer.isCompleted) { 29 | completer.complete(); 30 | } 31 | } 32 | 33 | bool isAuth() => CheckIsLoggedInUseCase(GetIt.instance.get()) 34 | .execute() 35 | .fold((left) => left, (right) => false); 36 | 37 | 38 | } 39 | -------------------------------------------------------------------------------- /modules/auth/lib/src/presentation/localization/intl_en.arb: -------------------------------------------------------------------------------- 1 | { 2 | "lbl_user_name": "Username", 3 | "lbl_password": "Password", 4 | "btn_login": "Login" 5 | } -------------------------------------------------------------------------------- /modules/auth/lib/src/presentation/localization/intl_vi.arb: -------------------------------------------------------------------------------- 1 | { 2 | "lbl_user_name": "Tên đăng nhập", 3 | "lbl_password": "Mật khẩu", 4 | "btn_login": "Đăng nhập" 5 | } -------------------------------------------------------------------------------- /modules/auth/lib/src/presentation/localization/localization.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'package:core/core.dart'; 3 | import 'package:flutter/foundation.dart'; 4 | import 'package:flutter/widgets.dart'; 5 | import 'generated/app_localizations.dart'; 6 | import 'generated/app_localizations_en.dart'; 7 | 8 | /// The actual `Localizations` class is [ModuleLocalizationImp], this class exists only for forward compatibility purposes... 9 | 10 | class ModuleLocalization { 11 | ModuleLocalization._(); 12 | 13 | static ModuleLocalizationImp of(BuildContext context) { 14 | return Localizations.of( 15 | context, ModuleLocalizationImp) ?? 16 | _default; 17 | } 18 | 19 | static const LocalizationsDelegate delegate = 20 | ModuleLocalizationsDelegate(); 21 | static const List> localizationsDelegates = 22 | ModuleLocalizationImp.localizationsDelegates; 23 | 24 | static const List supportedLocales = 25 | ModuleLocalizationImp.supportedLocales; 26 | static final _default = ModuleLocalizationImpEn(); 27 | static ModuleLocalizationImp? _current; 28 | 29 | static void setCurrentInstance(ModuleLocalizationImp? current) => 30 | _current = current; 31 | 32 | static ModuleLocalizationImp get current => _current ?? _default; 33 | } 34 | 35 | class ModuleLocalizationsDelegate 36 | extends LocalizationsDelegate { 37 | const ModuleLocalizationsDelegate(); 38 | 39 | @override 40 | Future load(Locale locale) { 41 | final instance = lookupModuleLocalizationImp(locale); 42 | ModuleLocalization.setCurrentInstance(instance); 43 | return SynchronousFuture(instance); 44 | } 45 | 46 | @override 47 | bool isSupported(Locale locale) => ModuleLocalizationImp.supportedLocales 48 | .map((e) => e.languageCode) 49 | .contains(locale.languageCode); 50 | 51 | @override 52 | bool shouldReload(ModuleLocalizationsDelegate old) => false; 53 | } 54 | 55 | extension GetModuleLocalization on GetInterface { 56 | ModuleLocalizationImp get moduleLocalization { 57 | if (context == null) throw Exception('Context is null'); 58 | return ModuleLocalization.of(context!); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /modules/auth/lib/src/presentation/routes.dart: -------------------------------------------------------------------------------- 1 | import 'package:core/core.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | import 'screens/screens.dart'; 5 | 6 | class RouteName { 7 | static const _prefix = "/auth"; 8 | static const login = "${_prefix}_login"; 9 | } 10 | 11 | class Routes { 12 | static PageRoute checkPhone() => MaterialPageRoute( 13 | builder: (context) => LoginScreen(), 14 | settings: const RouteSettings(name: RouteName.login)); 15 | } 16 | -------------------------------------------------------------------------------- /modules/auth/lib/src/presentation/screens/login/field_vm.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | 3 | class FieldVM with EquatableMixin { 4 | String? Function(String content)? validator; 5 | String _content = ""; 6 | 7 | set content(String newValue) { 8 | _content = newValue; 9 | initial = false; 10 | } 11 | 12 | String get content => _content; 13 | bool initial = true; 14 | 15 | String? get errorText { 16 | if (initial) return null; 17 | return validate(); 18 | } 19 | 20 | String? validate() { 21 | if (validator != null) { 22 | return validator!.call(_content); 23 | } 24 | if (_content.isEmpty) return 'Invalid field'; 25 | return null; 26 | } 27 | 28 | FieldVM(this._content); 29 | 30 | @override 31 | List get props => [_content]; 32 | } 33 | -------------------------------------------------------------------------------- /modules/auth/lib/src/presentation/screens/login/login_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:auth/src/domain/repository.dart'; 2 | import 'package:auth/src/domain/use_cases/login_use_case.dart'; 3 | import 'package:auth/src/presentation/auth_controller.dart'; 4 | import 'package:core/core.dart'; 5 | 6 | import '../../routes.dart'; 7 | import 'field_vm.dart'; 8 | 9 | class LoginController extends BaseController { 10 | final Rx username = FieldVM("").obs; 11 | final Rx password = FieldVM("").obs; 12 | 13 | bool get isValid => 14 | username.value.validate() == null && password.value.validate() == null; 15 | 16 | void changePassword(String password) { 17 | this.password.update((val) { 18 | val?.content = password; 19 | }); 20 | } 21 | 22 | void changeUsername(String username) { 23 | this.username.update((val) { 24 | val?.content = username; 25 | }); 26 | } 27 | 28 | void startLogin() async { 29 | showLoadingDialog(); 30 | final Either result = 31 | await LoginUseCase(GetIt.instance.get()) 32 | .execute(username.value.content, password.value.content); 33 | hideLoadingDialog(); 34 | result.fold((left) { 35 | GetIt.instance.get().loginSuccessfully(); 36 | }, (right) { 37 | showError(right); 38 | return; 39 | }); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /modules/auth/lib/src/presentation/screens/login/login_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:auth/src/presentation/localization/localization.dart'; 2 | import 'package:core/core.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'login_controller.dart'; 5 | 6 | class LoginScreen extends GetWidget { 7 | const LoginScreen({super.key}); 8 | 9 | @override 10 | Widget build(BuildContext context) { 11 | Get.put(LoginController()); 12 | return Scaffold( 13 | body: Padding( 14 | padding: const EdgeInsets.all(12), 15 | child: Align( 16 | alignment: const Alignment(0, -1 / 3), 17 | child: Column( 18 | mainAxisSize: MainAxisSize.min, 19 | children: [ 20 | _UsernameInput(), 21 | const Padding(padding: EdgeInsets.all(12)), 22 | _PasswordInput(), 23 | const Padding(padding: EdgeInsets.all(12)), 24 | _LoginButton(), 25 | ], 26 | ), 27 | ), 28 | ), 29 | ); 30 | } 31 | } 32 | 33 | class _UsernameInput extends StatelessWidget { 34 | @override 35 | Widget build(BuildContext context) { 36 | final controller = Get.find(); 37 | return Obx(() { 38 | return TextField( 39 | key: const Key('loginForm_usernameInput_textField'), 40 | onChanged: (username) => controller.changeUsername(username), 41 | decoration: InputDecoration( 42 | labelText: Get.moduleLocalization.lbl_user_name, 43 | errorText: controller.username.value.errorText, 44 | ), 45 | ); 46 | }); 47 | } 48 | } 49 | 50 | class _PasswordInput extends StatelessWidget { 51 | @override 52 | Widget build(BuildContext context) { 53 | final controller = Get.find(); 54 | return Obx(() { 55 | return TextField( 56 | key: const Key('loginForm_passwordInput_textField'), 57 | onChanged: (password) => controller.changePassword(password), 58 | obscureText: true, 59 | decoration: InputDecoration( 60 | labelText: ModuleLocalization.of(context).lbl_password, 61 | errorText: controller.password.value.errorText, 62 | ), 63 | ); 64 | }); 65 | } 66 | } 67 | 68 | class _LoginButton extends StatelessWidget { 69 | @override 70 | Widget build(BuildContext context) { 71 | final controller = Get.find(); 72 | return Obx( 73 | () => ElevatedButton( 74 | key: const Key('loginForm_continue_raisedButton'), 75 | onPressed: controller.isValid 76 | ? () { 77 | controller.startLogin(); 78 | } 79 | : null, 80 | child: Text(ModuleLocalization.of(context).btn_login), 81 | ), 82 | ); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /modules/auth/lib/src/presentation/screens/login_v2/login_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'package:auth/src/domain/repository.dart'; 2 | import 'package:auth/src/domain/use_cases/login_use_case.dart'; 3 | import 'package:auth/src/presentation/auth_controller.dart'; 4 | import 'package:auth/src/presentation/screens/login_v2/login_form_key.dart'; 5 | import 'package:core/core.dart'; 6 | 7 | class LoginBloc extends BaseBloc { 8 | LoginBloc(super.navigatorBloc); 9 | 10 | @override 11 | Future onInitialLoad(Emitter emit) async {} 12 | 13 | @override 14 | Future onSubmit(Emitter emit, data) async { 15 | showLoadingDialog(); 16 | final dataMap = data as Map; 17 | final Either result = 18 | await LoginUseCase(GetIt.instance.get()) 19 | .execute( 20 | dataMap[LoginFormKey.username], dataMap[LoginFormKey.password]); 21 | hideLoadingDialog(); 22 | result.fold((left) { 23 | GetIt.instance.get().loginSuccessfully(); 24 | }, (right) { 25 | showErrorDialog(right); 26 | return; 27 | }); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /modules/auth/lib/src/presentation/screens/login_v2/login_form_key.dart: -------------------------------------------------------------------------------- 1 | class LoginFormKey { 2 | static const username = "username"; 3 | static const password = "password"; 4 | } 5 | -------------------------------------------------------------------------------- /modules/auth/lib/src/presentation/screens/login_v2/login_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:auth/src/presentation/localization/localization.dart'; 2 | import 'package:auth/src/presentation/screens/login_v2/login_form_key.dart'; 3 | import 'package:core/core.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:ui/ui.dart'; 6 | import 'login_bloc.dart'; 7 | 8 | class LoginScreen extends BaseBlocWidget { 9 | final _formKey = GlobalKey(); 10 | 11 | LoginScreen({super.key}); 12 | 13 | @override 14 | LoginBloc buildBloc(BaseNavigatorBloc navigatorBloc) => 15 | LoginBloc(navigatorBloc); 16 | 17 | @override 18 | Widget successView(BuildContext context, T data) => const SizedBox(); 19 | 20 | @override 21 | Widget initialView(BuildContext context) { 22 | return Scaffold( 23 | body: Padding( 24 | padding: const EdgeInsets.all(12), 25 | child: FormBuilder( 26 | key: _formKey, 27 | child: Column( 28 | crossAxisAlignment: CrossAxisAlignment.stretch, 29 | mainAxisAlignment: MainAxisAlignment.center, 30 | children: [ 31 | const SizedBox( 32 | height: 30, 33 | ), 34 | UIFormBuilderTextField.normalRequired( 35 | key: const Key('loginForm_usernameInput_textField'), 36 | context: context, 37 | name: LoginFormKey.username, 38 | labelText: ModuleLocalization.of(context).lbl_user_name, 39 | ), 40 | const SizedBox( 41 | height: 16, 42 | ), 43 | UIFormBuilderTextField.normalRequired( 44 | key: const Key('loginForm_passwordInput_textField'), 45 | context: context, 46 | name: LoginFormKey.password, 47 | labelText: ModuleLocalization.of(context).lbl_password, 48 | obscureText: false), 49 | const SizedBox( 50 | height: 40, 51 | ), 52 | ElevatedButton( 53 | key: const Key('loginForm_continue_raisedButton'), 54 | onPressed: () { 55 | FocusScope.of(context).requestFocus(FocusNode()); 56 | if (_formKey.currentState?.saveAndValidate() ?? false) { 57 | final data = _formKey.currentState?.value ?? {}; 58 | onSubmit(context, data); 59 | } 60 | }, 61 | child: Text(ModuleLocalization.of(context).btn_login), 62 | ), 63 | ], 64 | ), 65 | ), 66 | ), 67 | ); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /modules/auth/lib/src/presentation/screens/screens.dart: -------------------------------------------------------------------------------- 1 | // export 'login/login_screen.dart'; 2 | export 'login_v2/login_screen.dart'; -------------------------------------------------------------------------------- /modules/auth/lib/src/presentation/utils/defination.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | class ImageConst { 4 | static const _path = "packages/auth/assets/images/"; 5 | } 6 | 7 | class ColorConst { 8 | } 9 | -------------------------------------------------------------------------------- /modules/auth/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: auth 2 | description: A new Flutter package project. 3 | version: 0.0.1 4 | publish_to: none 5 | 6 | environment: 7 | sdk: '>=3.1.2 <4.0.0' 8 | flutter: ">=1.17.0" 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | ui: 14 | path: ../ui 15 | core: 16 | path: ../core 17 | 18 | dev_dependencies: 19 | flutter_test: 20 | sdk: flutter 21 | flutter_lints: ^2.0.0 22 | json_serializable: any 23 | build_runner: any 24 | retrofit_generator: any 25 | http_mock_adapter: any 26 | 27 | flutter: 28 | assets: 29 | - assets/images/ 30 | -------------------------------------------------------------------------------- /modules/auth/pubspec_overrides.yaml: -------------------------------------------------------------------------------- 1 | # melos_managed_dependency_overrides: core,ui 2 | dependency_overrides: 3 | core: 4 | path: ../core 5 | ui: 6 | path: ../ui 7 | -------------------------------------------------------------------------------- /modules/core/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. 26 | /pubspec.lock 27 | **/doc/api/ 28 | .dart_tool/ 29 | .packages 30 | build/ 31 | -------------------------------------------------------------------------------- /modules/core/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: "367f9ea16bfae1ca451b9cc27c1366870b187ae2" 8 | channel: "stable" 9 | 10 | project_type: package 11 | -------------------------------------------------------------------------------- /modules/core/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.0.1 2 | 3 | * TODO: Describe initial release. 4 | -------------------------------------------------------------------------------- /modules/core/LICENSE: -------------------------------------------------------------------------------- 1 | TODO: Add your license here. 2 | -------------------------------------------------------------------------------- /modules/core/README.md: -------------------------------------------------------------------------------- 1 | 13 | 14 | TODO: Put a short description of the package here that helps potential users 15 | know whether this package might be useful for them. 16 | 17 | ## Features 18 | 19 | TODO: List what your package can do. Maybe include images, gifs, or videos. 20 | 21 | ## Getting started 22 | 23 | TODO: List prerequisites and provide or point to information on how to 24 | start using the package. 25 | 26 | ## Usage 27 | 28 | TODO: Include short and useful examples for package users. Add longer examples 29 | to `/example` folder. 30 | 31 | ```dart 32 | const like = 'sample'; 33 | ``` 34 | 35 | ## Additional information 36 | 37 | TODO: Tell users more about the package: where to find more information, how to 38 | contribute to the package, how to file issues, what response they can expect 39 | from the package authors, and more. 40 | -------------------------------------------------------------------------------- /modules/core/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:flutter_lints/flutter.yaml 2 | 3 | # Additional information about this file can be found at 4 | # https://dart.dev/guides/language/analysis-options 5 | -------------------------------------------------------------------------------- /modules/core/l10n.yaml: -------------------------------------------------------------------------------- 1 | arb-dir: lib/src/presentation/localization 2 | template-arb-file: intl_en.arb 3 | output-class: ModuleLocalizationImp 4 | synthetic-package: false 5 | output-dir: lib/src/presentation/localization/generated -------------------------------------------------------------------------------- /modules/core/lib/core.dart: -------------------------------------------------------------------------------- 1 | library core; 2 | 3 | export 'src/base/base_module.dart'; 4 | export 'src/presentation/presentation.dart'; 5 | export 'src/data/data.dart'; 6 | export 'src/domain/domain.dart'; 7 | 8 | export 'src/libs.dart'; 9 | 10 | export 'src/core_module.dart'; -------------------------------------------------------------------------------- /modules/core/lib/src/base/base_module.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | 3 | abstract class BaseModule { 4 | LocalizationsDelegate get localizationsDelegate; 5 | 6 | Future inject(); 7 | } 8 | -------------------------------------------------------------------------------- /modules/core/lib/src/core_module.dart: -------------------------------------------------------------------------------- 1 | import 'package:core/core.dart'; 2 | import 'package:flutter/widgets.dart'; 3 | 4 | import 'data/injection.dart'; 5 | import 'presentation/localization/localization.dart'; 6 | 7 | export 'environment.dart'; 8 | 9 | part 'core_module_imp.dart'; 10 | 11 | abstract class CoreModule extends BaseModule { 12 | static final CoreModule _instance = _CoreModuleImp(); 13 | 14 | static CoreModule newInstance({required CoreEnvironment environment}) { 15 | GetIt.instance.registerSingleton(environment); 16 | return _instance; 17 | } 18 | 19 | static CoreModule get instance { 20 | final isRegisEnv = GetIt.instance.isRegistered(); 21 | if (!isRegisEnv) throw Exception('Core Environment not set'); 22 | return _instance; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /modules/core/lib/src/core_module_imp.dart: -------------------------------------------------------------------------------- 1 | part of 'core_module.dart'; 2 | 3 | class _CoreModuleImp extends CoreModule { 4 | _CoreModuleImp(); 5 | 6 | @override 7 | Future inject() async { 8 | DataInjection().inject(GetIt.instance.get()); 9 | } 10 | 11 | @override 12 | LocalizationsDelegate get localizationsDelegate => 13 | ModuleLocalization.delegate; 14 | } 15 | -------------------------------------------------------------------------------- /modules/core/lib/src/data/data.dart: -------------------------------------------------------------------------------- 1 | export 'models/models.dart'; 2 | export 'mappers/exception_mapper.dart'; -------------------------------------------------------------------------------- /modules/core/lib/src/data/injection.dart: -------------------------------------------------------------------------------- 1 | import 'package:core/core.dart'; 2 | import 'package:flutter/foundation.dart'; 3 | 4 | class DataInjection { 5 | void inject(CoreEnvironment coreEnvironment) { 6 | final getIt = GetIt.instance; 7 | getIt.registerSingleton( 8 | BaseOptions(baseUrl: coreEnvironment.baseUrl)); 9 | getIt.registerSingleton(Dio(getIt.get())); 10 | if (kDebugMode) { 11 | getIt.get().interceptors.add(LogInterceptor(requestBody: true)); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /modules/core/lib/src/data/mappers/exception_mapper.dart: -------------------------------------------------------------------------------- 1 | import 'package:core/src/domain/models/exceptions/exceptions.dart'; 2 | import 'package:dio/dio.dart'; 3 | import '../models/models.dart'; 4 | 5 | mixin ExceptionMapper { 6 | AppException mapException(Object e) { 7 | if (e is DioException) { 8 | switch (e.type) { 9 | case DioExceptionType.connectionTimeout: 10 | return NoConnectionException(); 11 | case DioExceptionType.sendTimeout: 12 | return NoConnectionException(); 13 | case DioExceptionType.receiveTimeout: 14 | return NoConnectionException(); 15 | case DioExceptionType.badCertificate: 16 | return UnknownException(e); 17 | case DioExceptionType.badResponse: 18 | final data = e.response?.data; 19 | final errorModel = ErrorModel.fromJson(data); 20 | var type = NetworkExceptionType.moduleError; 21 | switch (errorModel.code) { 22 | case "USER_INVALID": 23 | type = NetworkExceptionType.userInvalid; 24 | break; 25 | } 26 | if (e.response?.statusCode == 401) { 27 | type = NetworkExceptionType.expiredToken; 28 | } 29 | throw NetworkException( 30 | type, errorModel.message ?? "", errorModel.code ?? ""); 31 | case DioExceptionType.cancel: 32 | return UnknownException(e); 33 | case DioExceptionType.connectionError: 34 | return NoConnectionException(); 35 | case DioExceptionType.unknown: 36 | return UnknownException(e); 37 | } 38 | } 39 | return UnknownException(e); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /modules/core/lib/src/data/models/base_response.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_annotation/json_annotation.dart'; 2 | part 'base_response.g.dart'; 3 | 4 | @JsonSerializable( 5 | constructor: '_', 6 | createToJson: false, 7 | genericArgumentFactories: true, 8 | ) 9 | class BaseResponse { 10 | final String? code; 11 | final String? message; 12 | final T? data; 13 | 14 | BaseResponse._(this.code, this.message, this.data); 15 | 16 | factory BaseResponse.fromJson(Map json, T Function(Object? json) fromJsonT) => _$BaseResponseFromJson(json, fromJsonT); 17 | } -------------------------------------------------------------------------------- /modules/core/lib/src/data/models/base_response.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'base_response.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | BaseResponse _$BaseResponseFromJson( 10 | Map json, 11 | T Function(Object? json) fromJsonT, 12 | ) => 13 | BaseResponse._( 14 | json['code'] as String?, 15 | json['message'] as String?, 16 | _$nullableGenericFromJson(json['data'], fromJsonT), 17 | ); 18 | 19 | T? _$nullableGenericFromJson( 20 | Object? input, 21 | T Function(Object? json) fromJson, 22 | ) => 23 | input == null ? null : fromJson(input); 24 | -------------------------------------------------------------------------------- /modules/core/lib/src/data/models/error_model.dart: -------------------------------------------------------------------------------- 1 | class ErrorModel { 2 | final String? code; 3 | final String? message; 4 | 5 | ErrorModel(this.code, this.message); 6 | 7 | factory ErrorModel.fromJson(Map json) => ErrorModel( 8 | json['code'] is String ? json['code'] : "SOMETHING WENT WRONG", 9 | json['message'] as String?, 10 | ); 11 | 12 | Map toJson() => { 13 | 'code': code, 14 | 'message': message, 15 | }; 16 | } 17 | -------------------------------------------------------------------------------- /modules/core/lib/src/data/models/models.dart: -------------------------------------------------------------------------------- 1 | export 'base_response.dart'; 2 | export 'error_model.dart'; -------------------------------------------------------------------------------- /modules/core/lib/src/domain/domain.dart: -------------------------------------------------------------------------------- 1 | export 'utils/utils.dart'; 2 | export 'models/models.dart'; -------------------------------------------------------------------------------- /modules/core/lib/src/domain/models/exceptions/app_exception.dart: -------------------------------------------------------------------------------- 1 | class AppException implements Exception { 2 | AppException([this._message = ""]); 3 | final dynamic _message; 4 | 5 | @override 6 | String toString() { 7 | return "$_message"; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /modules/core/lib/src/domain/models/exceptions/exceptions.dart: -------------------------------------------------------------------------------- 1 | export 'app_exception.dart'; 2 | export 'net_exception.dart'; 3 | export 'unknown_exception.dart'; 4 | export 'no_connection_exception.dart'; 5 | -------------------------------------------------------------------------------- /modules/core/lib/src/domain/models/exceptions/net_exception.dart: -------------------------------------------------------------------------------- 1 | import 'app_exception.dart'; 2 | 3 | enum NetworkExceptionType { 4 | expiredToken, 5 | userInvalid, 6 | moduleError 7 | } 8 | 9 | class NetworkException extends AppException { 10 | NetworkExceptionType type; 11 | String message; 12 | String code; 13 | 14 | NetworkException(this.type, this.message, this.code); 15 | 16 | @override 17 | String toString() { 18 | return message; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /modules/core/lib/src/domain/models/exceptions/no_connection_exception.dart: -------------------------------------------------------------------------------- 1 | import 'app_exception.dart'; 2 | 3 | class NoConnectionException extends AppException { 4 | 5 | } -------------------------------------------------------------------------------- /modules/core/lib/src/domain/models/exceptions/unknown_exception.dart: -------------------------------------------------------------------------------- 1 | import 'app_exception.dart'; 2 | 3 | class UnknownException extends AppException { 4 | final Object? error; 5 | UnknownException(this.error); 6 | } 7 | -------------------------------------------------------------------------------- /modules/core/lib/src/domain/models/models.dart: -------------------------------------------------------------------------------- 1 | export 'exceptions/exceptions.dart'; -------------------------------------------------------------------------------- /modules/core/lib/src/domain/utils/either.dart: -------------------------------------------------------------------------------- 1 | abstract class Either { 2 | const Either(); 3 | 4 | B fold(B Function(L left) ifLeft, B Function(R right) ifRight); 5 | 6 | bool isLeft() => fold((_) => true, (_) => false); 7 | 8 | bool isRight() => fold((_) => false, (_) => true); 9 | } 10 | 11 | class Left extends Either { 12 | final L _l; 13 | 14 | const Left(this._l); 15 | 16 | L get value => _l; 17 | 18 | @override 19 | B fold(B Function(L l) ifLeft, B Function(R r) ifRight) => ifLeft(_l); 20 | 21 | @override 22 | bool operator ==(other) => other is Left && other._l == _l; 23 | 24 | @override 25 | int get hashCode => _l.hashCode; 26 | } 27 | 28 | class Right extends Either { 29 | final R _r; 30 | 31 | const Right(this._r); 32 | 33 | R get value => _r; 34 | 35 | @override 36 | B fold(B Function(L l) ifLeft, B Function(R r) ifRight) => ifRight(_r); 37 | 38 | @override 39 | bool operator ==(other) => other is Right && other._r == _r; 40 | 41 | @override 42 | int get hashCode => _r.hashCode; 43 | } 44 | -------------------------------------------------------------------------------- /modules/core/lib/src/domain/utils/utils.dart: -------------------------------------------------------------------------------- 1 | export 'either.dart'; -------------------------------------------------------------------------------- /modules/core/lib/src/environment.dart: -------------------------------------------------------------------------------- 1 | class CoreEnvironment { 2 | String baseUrl; 3 | 4 | CoreEnvironment({required this.baseUrl}); 5 | } 6 | -------------------------------------------------------------------------------- /modules/core/lib/src/libs.dart: -------------------------------------------------------------------------------- 1 | export 'package:get/get.dart' hide FormData, MultipartFile, Response, Transition; 2 | export 'package:json_annotation/json_annotation.dart'; 3 | export 'package:logging/logging.dart'; 4 | export 'package:retrofit/retrofit.dart' hide Headers; 5 | export 'package:flutter_localizations/flutter_localizations.dart'; 6 | export 'package:hive/hive.dart'; 7 | export 'package:path_provider/path_provider.dart'; 8 | export 'package:get_storage/get_storage.dart'; 9 | export 'package:dio/dio.dart'; 10 | export 'package:get_it/get_it.dart'; 11 | export 'package:collection/collection.dart'; 12 | export 'package:flutter_bloc/flutter_bloc.dart'; -------------------------------------------------------------------------------- /modules/core/lib/src/presentation/base_bloc/base.dart: -------------------------------------------------------------------------------- 1 | export 'base_bloc_screen.dart'; 2 | export 'base_bloc.dart'; 3 | export 'base_navigator/base_navigator_bloc.dart'; -------------------------------------------------------------------------------- /modules/core/lib/src/presentation/base_bloc/base_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_bloc/flutter_bloc.dart'; 2 | 3 | import 'package:core/src/domain/domain.dart'; 4 | import 'base_bloc_event.dart'; 5 | import 'base_navigator/base_navigator_bloc.dart'; 6 | 7 | export 'base_bloc_event.dart'; 8 | 9 | part 'base_bloc_state.dart'; 10 | 11 | abstract class BaseBloc extends Bloc { 12 | BaseNavigatorBloc navigatorBloc; 13 | 14 | BaseBloc(this.navigatorBloc, {BaseBlocState? initialState}) 15 | : super(initialState ?? BaseBlocInitial()) { 16 | on(_onBaseBlocEvent); 17 | } 18 | 19 | void showLoadingDialog() => navigatorBloc.showLoadingDialog(); 20 | 21 | void hideLoadingDialog() => navigatorBloc.hideLoadingDialog(); 22 | 23 | void showErrorDialog(AppException error) => 24 | navigatorBloc.showErrorDialog(error); 25 | 26 | void navigate(T data) => navigatorBloc.navigate(data); 27 | 28 | void _onBaseBlocEvent( 29 | BaseBlocEvent event, Emitter emit) async { 30 | switch (event) { 31 | case BaseBlocEventInitial(): 32 | await onInitialLoad(emit); 33 | break; 34 | case BaseBlocEventSubmit(): 35 | await onSubmit(emit, event.data); 36 | break; 37 | case BaseBlocEventCustomize(): 38 | await onEventCustomize(emit, event.eventScreen); 39 | break; 40 | } 41 | } 42 | 43 | Future onInitialLoad(Emitter emit); 44 | 45 | Future onSubmit(Emitter emit, dynamic data) async {} 46 | 47 | Future onEventCustomize( 48 | Emitter emit, BaseBlocEventScreen event) async {} 49 | } 50 | 51 | extension EmitterUI on Emitter { 52 | void loadingView() => call(BaseBlocLoadingView()); 53 | 54 | void failedView(AppException error) => call(BaseBlocLoadFailed(error)); 55 | 56 | void successfulView(T data) => call(BaseBlocStateSuccessful(data)); 57 | 58 | void customizeState(BaseBlocStateScreen state) => 59 | call(BaseBlocStateScreenCustomize(state)); 60 | } 61 | -------------------------------------------------------------------------------- /modules/core/lib/src/presentation/base_bloc/base_bloc_event.dart: -------------------------------------------------------------------------------- 1 | sealed class BaseBlocEvent {} 2 | 3 | class BaseBlocEventInitial extends BaseBlocEvent {} 4 | 5 | class BaseBlocEventSubmit extends BaseBlocEvent { 6 | T data; 7 | 8 | BaseBlocEventSubmit(this.data); 9 | } 10 | 11 | class BaseBlocEventCustomize extends BaseBlocEvent { 12 | BaseBlocEventScreen eventScreen; 13 | 14 | BaseBlocEventCustomize(this.eventScreen); 15 | } 16 | 17 | class BaseBlocEventScreen {} 18 | -------------------------------------------------------------------------------- /modules/core/lib/src/presentation/base_bloc/base_bloc_state.dart: -------------------------------------------------------------------------------- 1 | part of 'base_bloc.dart'; 2 | 3 | sealed class BaseBlocState {} 4 | 5 | class BaseBlocInitial extends BaseBlocState {} 6 | 7 | class BaseBlocStateSuccessful extends BaseBlocState { 8 | T data; 9 | 10 | BaseBlocStateSuccessful(this.data); 11 | } 12 | 13 | class BaseBlocLoadFailed extends BaseBlocState { 14 | AppException exception; 15 | 16 | BaseBlocLoadFailed(this.exception); 17 | } 18 | 19 | class BaseBlocLoadingView extends BaseBlocState {} 20 | 21 | class BaseBlocStateScreenCustomize extends BaseBlocState { 22 | BaseBlocStateScreen stateScreen; 23 | 24 | BaseBlocStateScreenCustomize(this.stateScreen); 25 | } 26 | 27 | class BaseBlocStateScreen {} 28 | -------------------------------------------------------------------------------- /modules/core/lib/src/presentation/base_bloc/base_navigator/base_navigator_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_bloc/flutter_bloc.dart'; 2 | 3 | import 'package:core/src/domain/domain.dart'; 4 | 5 | part 'base_navigator_state.dart'; 6 | 7 | class BaseNavigatorBloc extends Cubit { 8 | BaseNavigatorBloc() : super(BaseNavigatorStateIdle()); 9 | 10 | void showLoadingDialog() => emit(BaseNavigatorStateShowLoading()); 11 | 12 | void hideLoadingDialog() => emit(BaseNavigatorStateHideLoading()); 13 | 14 | void showErrorDialog(AppException error) => emit(BaseNavigatorStateShowError(error)); 15 | 16 | void navigate(T data) => emit(BaseNavigatorStateCustomize(data)); 17 | } 18 | -------------------------------------------------------------------------------- /modules/core/lib/src/presentation/base_bloc/base_navigator/base_navigator_state.dart: -------------------------------------------------------------------------------- 1 | part of 'base_navigator_bloc.dart'; 2 | 3 | sealed class BaseNavigatorState {} 4 | 5 | class BaseNavigatorStateIdle extends BaseNavigatorState {} 6 | 7 | class BaseNavigatorStateShowLoading extends BaseNavigatorState {} 8 | 9 | class BaseNavigatorStateHideLoading extends BaseNavigatorState {} 10 | 11 | class BaseNavigatorStateShowError extends BaseNavigatorState { 12 | AppException error; 13 | 14 | BaseNavigatorStateShowError(this.error); 15 | } 16 | 17 | class BaseNavigatorStateCustomize 18 | extends BaseNavigatorState { 19 | BaseNavigatorStateScreen customizeNavigator; 20 | 21 | BaseNavigatorStateCustomize(this.customizeNavigator); 22 | } 23 | 24 | class BaseNavigatorStateScreen {} 25 | -------------------------------------------------------------------------------- /modules/core/lib/src/presentation/base_get/base.dart: -------------------------------------------------------------------------------- 1 | export 'base_controller.dart'; 2 | export 'base_screen.dart'; 3 | export 'base_handle_controller.dart'; 4 | export 'base_view_status.dart'; 5 | export 'base_widget.dart'; -------------------------------------------------------------------------------- /modules/core/lib/src/presentation/base_get/base_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:get/get.dart'; 2 | 3 | import 'base_handle_controller.dart'; 4 | import 'base_view_status.dart'; 5 | 6 | class BaseController extends GetxController with BaseHandleController { 7 | Rx viewStatus = BaseViewStatus.loading.obs; 8 | } 9 | 10 | 11 | -------------------------------------------------------------------------------- /modules/core/lib/src/presentation/base_get/base_handle_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:core/src/domain/models/exceptions/exceptions.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:get/get.dart'; 4 | import 'package:ui/ui.dart'; 5 | 6 | mixin BaseHandleController { 7 | final loadingDialogTag = "/loadingDialog"; 8 | 9 | void showLoadingDialog() { 10 | Get.dialog( 11 | Center( 12 | child: CircularProgressIndicator( 13 | strokeWidth: 3.0, 14 | color: Theme.of(Get.context!).primaryColor, 15 | )), 16 | barrierDismissible: false, 17 | barrierColor: const Color(0x88000000), 18 | name: loadingDialogTag); 19 | } 20 | 21 | void hideLoadingDialog() { 22 | Get.until((route) => route.settings.name != loadingDialogTag); 23 | } 24 | 25 | void showError(AppException exception) { 26 | if (exception is NoConnectionException) { 27 | // showNoConnectionDialog(context, onRetry: action); 28 | return; 29 | } 30 | if (exception is NetworkException) { 31 | if (exception.type == NetworkExceptionType.userInvalid || 32 | exception.type == NetworkExceptionType.expiredToken) { 33 | // showExpiredSessionDialog(context, exception.message, onClose: () { 34 | // }); 35 | return; 36 | } 37 | showMessageDialog(exception.message); 38 | return; 39 | } 40 | if (exception is UnknownException) { 41 | showMessageDialog('Something went wrong'); 42 | return; 43 | } 44 | showMessageDialog(exception.toString()); 45 | } 46 | 47 | void showMessageDialog(String message, {Function()? onDone}) { 48 | Get.dialog( 49 | MessageDialog( 50 | content: message, 51 | onDone: () { 52 | onDone?.call(); 53 | }), 54 | barrierDismissible: false); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /modules/core/lib/src/presentation/base_get/base_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:get/get.dart'; 3 | 4 | import 'base_controller.dart'; 5 | import 'base_view_status.dart'; 6 | 7 | abstract class BaseScreen extends GetWidget { 8 | const BaseScreen({super.key}); 9 | 10 | @override 11 | Widget build(BuildContext context) { 12 | return Scaffold( 13 | appBar: AppBar( 14 | title: const Text('App bar'), 15 | ), 16 | body: SafeArea(child: Obx(() => _buildWidget(context))), 17 | ); 18 | } 19 | 20 | Widget loadingView(BuildContext context) => Center( 21 | child: SizedBox( 22 | width: 30, 23 | height: 30, 24 | child: CircularProgressIndicator( 25 | strokeWidth: 3, 26 | color: Theme.of(context).primaryColor, 27 | ), 28 | )); 29 | 30 | Widget failedView(BuildContext context) => 31 | const Center(child: Text('Loaded failed')); 32 | 33 | Widget emptyView(BuildContext context) => 34 | const Center(child: Text('Empty view')); 35 | 36 | Widget successView(BuildContext context); 37 | 38 | Widget _buildWidget(BuildContext context) { 39 | return switch (controller.viewStatus.value) { 40 | BaseViewStatus.loading => loadingView(context), 41 | BaseViewStatus.empty => emptyView(context), 42 | BaseViewStatus.failed => failedView(context), 43 | BaseViewStatus.success => successView(context), 44 | }; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /modules/core/lib/src/presentation/base_get/base_view_status.dart: -------------------------------------------------------------------------------- 1 | enum BaseViewStatus { loading, empty, failed, success } -------------------------------------------------------------------------------- /modules/core/lib/src/presentation/base_get/base_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:get/get.dart'; 3 | 4 | import 'base_controller.dart'; 5 | import 'base_view_status.dart'; 6 | 7 | abstract class BaseWidget extends StatelessWidget { 8 | const BaseWidget( 9 | {super.key, this.initState, this.dispose, this.didChangeDependencies}); 10 | 11 | final void Function(GetBuilderState state)? initState, 12 | dispose, 13 | didChangeDependencies; 14 | 15 | @override 16 | Widget build(BuildContext context) { 17 | return GetBuilder( 18 | init: controller(), 19 | initState: initState, 20 | dispose: dispose, 21 | didChangeDependencies: didChangeDependencies, 22 | builder: (T controller) => _buildWidget(controller, context)); 23 | } 24 | 25 | T controller(); 26 | 27 | Widget loadingView(BuildContext context) => Center( 28 | child: SizedBox( 29 | width: 30, 30 | height: 30, 31 | child: CircularProgressIndicator( 32 | strokeWidth: 3, 33 | color: Theme.of(context).primaryColor, 34 | ), 35 | )); 36 | 37 | Widget failedView(BuildContext context) => 38 | const Center(child: Text('Loaded failed')); 39 | 40 | Widget emptyView(BuildContext context) => 41 | const Center(child: Text('Empty view')); 42 | 43 | Widget successView(BuildContext context); 44 | 45 | Widget _buildWidget(T controller, BuildContext context) { 46 | return switch (controller.viewStatus.value) { 47 | BaseViewStatus.loading => loadingView(context), 48 | BaseViewStatus.empty => emptyView(context), 49 | BaseViewStatus.failed => failedView(context), 50 | BaseViewStatus.success => successView(context), 51 | }; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /modules/core/lib/src/presentation/localization/intl_en.arb: -------------------------------------------------------------------------------- 1 | { 2 | } -------------------------------------------------------------------------------- /modules/core/lib/src/presentation/localization/intl_vi.arb: -------------------------------------------------------------------------------- 1 | { 2 | } -------------------------------------------------------------------------------- /modules/core/lib/src/presentation/localization/localization.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'package:flutter/foundation.dart'; 3 | import 'package:flutter/widgets.dart'; 4 | import 'generated/app_localizations.dart'; 5 | import 'generated/app_localizations_en.dart'; 6 | 7 | /// The actual `Localizations` class is [ModuleLocalizationImp], this class exists only for forward compatibility purposes... 8 | 9 | // for public 10 | typedef CoreLocalization = ModuleLocalization; 11 | 12 | class ModuleLocalization { 13 | ModuleLocalization._(); 14 | 15 | static ModuleLocalizationImp of(BuildContext context) { 16 | return Localizations.of( 17 | context, ModuleLocalizationImp) ?? 18 | _default; 19 | } 20 | 21 | static const LocalizationsDelegate delegate = 22 | ModuleLocalizationsDelegate(); 23 | static const List> localizationsDelegates = 24 | ModuleLocalizationImp.localizationsDelegates; 25 | 26 | static const List supportedLocales = 27 | ModuleLocalizationImp.supportedLocales; 28 | static final _default = ModuleLocalizationImpEn(); 29 | static ModuleLocalizationImp? _current; 30 | 31 | static void setCurrentInstance(ModuleLocalizationImp? current) => 32 | _current = current; 33 | 34 | static ModuleLocalizationImp get current => _current ?? _default; 35 | } 36 | 37 | class ModuleLocalizationsDelegate 38 | extends LocalizationsDelegate { 39 | const ModuleLocalizationsDelegate(); 40 | 41 | @override 42 | Future load(Locale locale) { 43 | final instance = lookupModuleLocalizationImp(locale); 44 | ModuleLocalization.setCurrentInstance(instance); 45 | return SynchronousFuture(instance); 46 | } 47 | 48 | @override 49 | bool isSupported(Locale locale) => ModuleLocalizationImp.supportedLocales 50 | .map((e) => e.languageCode) 51 | .contains(locale.languageCode); 52 | 53 | @override 54 | bool shouldReload(ModuleLocalizationsDelegate old) => false; 55 | } 56 | -------------------------------------------------------------------------------- /modules/core/lib/src/presentation/presentation.dart: -------------------------------------------------------------------------------- 1 | export 'base_get/base.dart'; 2 | export 'screens/base_handle_view.dart'; 3 | export 'base_bloc/base.dart'; -------------------------------------------------------------------------------- /modules/core/lib/src/presentation/screens/base_handle_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:core/src/domain/models/exceptions/exceptions.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:ui/ui.dart'; 4 | 5 | mixin BaseHandleView { 6 | final loadingDialogTag = "/loadingDialog"; 7 | 8 | void showLoadingDialog(BuildContext context) { 9 | final currentRoute = ModalRoute.of(context)?.settings.name; 10 | if (currentRoute == loadingDialogTag) return; 11 | showGeneralDialog( 12 | context: context, 13 | barrierDismissible: false, 14 | barrierColor: const Color(0x88000000), 15 | routeSettings: RouteSettings(name: loadingDialogTag), 16 | pageBuilder: (_, __, ___) => Center( 17 | child: CircularProgressIndicator( 18 | strokeWidth: 3.0, 19 | color: Theme.of(context).primaryColor, 20 | ))); 21 | } 22 | 23 | void hideLoadingDialog(BuildContext context) { 24 | Navigator.popUntil( 25 | context, (route) => route.settings.name != loadingDialogTag); 26 | } 27 | 28 | void showError(BuildContext context, AppException exception) { 29 | if (exception is NoConnectionException) { 30 | // showNoConnectionDialog(context, onRetry: action); 31 | return; 32 | } 33 | if (exception is NetworkException) { 34 | if (exception.type == NetworkExceptionType.userInvalid || 35 | exception.type == NetworkExceptionType.expiredToken) { 36 | // showExpiredSessionDialog(context, exception.message, onClose: () { 37 | // }); 38 | return; 39 | } 40 | showMessageDialog(context, exception.message); 41 | return; 42 | } 43 | if (exception is UnknownException) { 44 | showMessageDialog(context, 'Something went wrong'); 45 | return; 46 | } 47 | showMessageDialog(context, exception.toString()); 48 | } 49 | 50 | showMessageDialog(BuildContext context, String message, 51 | {Function()? onDone}) { 52 | showDialog( 53 | context: context, 54 | barrierDismissible: false, 55 | builder: (_) => MessageDialog( 56 | content: message, 57 | onDone: () { 58 | onDone?.call(); 59 | }), 60 | ); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /modules/core/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: core 2 | description: A new Flutter package project. 3 | version: 0.0.1 4 | publish_to: none 5 | 6 | environment: 7 | sdk: '>=3.1.2 <4.0.0' 8 | flutter: ">=1.17.0" 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | flutter_localizations: 14 | sdk: flutter 15 | get: ^4.6.6 16 | retrofit: ^4.1.0 17 | hive: ^2.2.3 18 | path_provider: ^2.1.3 19 | get_storage: ^2.1.1 20 | json_annotation: ^4.8.1 21 | logger: ^2.2.0 22 | dio: ^5.4.2+1 23 | logging: ^1.2.0 24 | mockito: ^5.4.4 25 | equatable: ^2.0.5 26 | ui: 27 | path: ../ui 28 | get_it: ^7.6.7 29 | collection: ^1.17.2 30 | flutter_bloc: ^8.1.5 31 | 32 | dev_dependencies: 33 | flutter_test: 34 | sdk: flutter 35 | flutter_lints: ^2.0.0 36 | json_serializable: ^6.7.1 37 | build_runner: ^2.4.9 38 | retrofit_generator: ^8.1.0 39 | http_mock_adapter: ^0.6.1 40 | 41 | flutter: -------------------------------------------------------------------------------- /modules/core/pubspec_overrides.yaml: -------------------------------------------------------------------------------- 1 | # melos_managed_dependency_overrides: ui 2 | dependency_overrides: 3 | ui: 4 | path: ../ui 5 | -------------------------------------------------------------------------------- /modules/product/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. 26 | /pubspec.lock 27 | **/doc/api/ 28 | .dart_tool/ 29 | .packages 30 | build/ 31 | -------------------------------------------------------------------------------- /modules/product/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: "367f9ea16bfae1ca451b9cc27c1366870b187ae2" 8 | channel: "stable" 9 | 10 | project_type: package 11 | -------------------------------------------------------------------------------- /modules/product/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.0.1 2 | 3 | * TODO: Describe initial release. 4 | -------------------------------------------------------------------------------- /modules/product/LICENSE: -------------------------------------------------------------------------------- 1 | TODO: Add your license here. 2 | -------------------------------------------------------------------------------- /modules/product/README.md: -------------------------------------------------------------------------------- 1 | 13 | 14 | TODO: Put a short description of the package here that helps potential users 15 | know whether this package might be useful for them. 16 | 17 | ## Features 18 | 19 | TODO: List what your package can do. Maybe include images, gifs, or videos. 20 | 21 | ## Getting started 22 | 23 | TODO: List prerequisites and provide or point to information on how to 24 | start using the package. 25 | 26 | ## Usage 27 | 28 | TODO: Include short and useful examples for package users. Add longer examples 29 | to `/example` folder. 30 | 31 | ```dart 32 | const like = 'sample'; 33 | ``` 34 | 35 | ## Additional information 36 | 37 | TODO: Tell users more about the package: where to find more information, how to 38 | contribute to the package, how to file issues, what response they can expect 39 | from the package authors, and more. 40 | -------------------------------------------------------------------------------- /modules/product/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:flutter_lints/flutter.yaml 2 | 3 | # Additional information about this file can be found at 4 | # https://dart.dev/guides/language/analysis-options 5 | -------------------------------------------------------------------------------- /modules/product/l10n.yaml: -------------------------------------------------------------------------------- 1 | arb-dir: lib/src/presentation/localization 2 | template-arb-file: intl_en.arb 3 | output-class: ModuleLocalizationImp 4 | synthetic-package: false 5 | output-dir: lib/src/presentation/localization/generated -------------------------------------------------------------------------------- /modules/product/lib/product.dart: -------------------------------------------------------------------------------- 1 | library product; 2 | 3 | export 'src/product_module.dart'; 4 | export 'src/widgets/widgets.dart'; -------------------------------------------------------------------------------- /modules/product/lib/src/data/injection.dart: -------------------------------------------------------------------------------- 1 | import 'package:core/core.dart'; 2 | import 'package:product/src/data/mapper/data_mapper.dart'; 3 | import 'package:product/src/data/repository_imp.dart'; 4 | 5 | import 'remote/clients/remote_client.dart'; 6 | 7 | class DataInjection { 8 | final _getIt = GetIt.instance; 9 | 10 | void inject() { 11 | _getIt.registerLazySingleton( 12 | () => RemoteClient(_getIt.get())); 13 | _getIt.registerLazySingleton(() => DataMapper()); 14 | _getIt.registerLazySingleton(() => 15 | RepositoryImp(_getIt.get(), _getIt.get())); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /modules/product/lib/src/data/mapper/data_mapper.dart: -------------------------------------------------------------------------------- 1 | import '../../domain/models/models.dart'; 2 | import '../models/models.dart'; 3 | 4 | class DataMapper { 5 | ProductItem mapProductItem(ProductItemModel? model) { 6 | return ProductItem(id: model?.id ?? 0, name: model?.name ?? ""); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /modules/product/lib/src/data/models/item_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:core/core.dart'; 2 | 3 | part 'item_model.g.dart'; 4 | 5 | @JsonSerializable(createToJson: false) 6 | class ProductItemModel { 7 | int? id; 8 | String? name; 9 | 10 | ProductItemModel({this.id, this.name}); 11 | 12 | factory ProductItemModel.fromJson(Map json) => _$ProductItemModelFromJson(json); 13 | } 14 | -------------------------------------------------------------------------------- /modules/product/lib/src/data/models/item_model.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'item_model.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | ProductItemModel _$ProductItemModelFromJson(Map json) => 10 | ProductItemModel( 11 | id: (json['id'] as num?)?.toInt(), 12 | name: json['name'] as String?, 13 | ); 14 | -------------------------------------------------------------------------------- /modules/product/lib/src/data/models/models.dart: -------------------------------------------------------------------------------- 1 | export 'item_model.dart'; -------------------------------------------------------------------------------- /modules/product/lib/src/data/remote/clients/remote_client.dart: -------------------------------------------------------------------------------- 1 | import 'package:core/core.dart'; 2 | 3 | import '../../models/models.dart'; 4 | 5 | part 'remote_client.g.dart'; 6 | 7 | @RestApi() 8 | abstract class RemoteClient { 9 | factory RemoteClient(Dio dio) = _RemoteClient; 10 | 11 | @GET('/product') 12 | Future>> fetchProductItems( 13 | @Query("page") int page, @Query("limit") int limit); 14 | } 15 | -------------------------------------------------------------------------------- /modules/product/lib/src/data/remote/clients/remote_client.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'remote_client.dart'; 4 | 5 | // ************************************************************************** 6 | // RetrofitGenerator 7 | // ************************************************************************** 8 | 9 | // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers 10 | 11 | class _RemoteClient implements RemoteClient { 12 | _RemoteClient( 13 | this._dio, { 14 | this.baseUrl, 15 | }); 16 | 17 | final Dio _dio; 18 | 19 | String? baseUrl; 20 | 21 | @override 22 | Future>> fetchProductItems( 23 | int page, 24 | int limit, 25 | ) async { 26 | final _extra = {}; 27 | final queryParameters = { 28 | r'page': page, 29 | r'limit': limit, 30 | }; 31 | final _headers = {}; 32 | const Map? _data = null; 33 | final _result = await _dio.fetch>( 34 | _setStreamType>>(Options( 35 | method: 'GET', 36 | headers: _headers, 37 | extra: _extra, 38 | ) 39 | .compose( 40 | _dio.options, 41 | '/product', 42 | queryParameters: queryParameters, 43 | data: _data, 44 | ) 45 | .copyWith( 46 | baseUrl: _combineBaseUrls( 47 | _dio.options.baseUrl, 48 | baseUrl, 49 | )))); 50 | final value = BaseResponse>.fromJson( 51 | _result.data!, 52 | (json) => json is List 53 | ? json 54 | .map( 55 | (i) => ProductItemModel.fromJson(i as Map)) 56 | .toList() 57 | : List.empty(), 58 | ); 59 | return value; 60 | } 61 | 62 | RequestOptions _setStreamType(RequestOptions requestOptions) { 63 | if (T != dynamic && 64 | !(requestOptions.responseType == ResponseType.bytes || 65 | requestOptions.responseType == ResponseType.stream)) { 66 | if (T == String) { 67 | requestOptions.responseType = ResponseType.plain; 68 | } else { 69 | requestOptions.responseType = ResponseType.json; 70 | } 71 | } 72 | return requestOptions; 73 | } 74 | 75 | String _combineBaseUrls( 76 | String dioBaseUrl, 77 | String? baseUrl, 78 | ) { 79 | if (baseUrl == null || baseUrl.trim().isEmpty) { 80 | return dioBaseUrl; 81 | } 82 | 83 | final url = Uri.parse(baseUrl); 84 | 85 | if (url.isAbsolute) { 86 | return url.toString(); 87 | } 88 | 89 | return Uri.parse(dioBaseUrl).resolveUri(url).toString(); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /modules/product/lib/src/data/repository_imp.dart: -------------------------------------------------------------------------------- 1 | import 'package:core/core.dart'; 2 | import 'package:product/src/data/mapper/data_mapper.dart'; 3 | import 'package:product/src/domain/repository.dart'; 4 | 5 | import '../domain/models/models.dart'; 6 | import 'remote/clients/remote_client.dart'; 7 | export '../domain/repository.dart'; 8 | 9 | class RepositoryImp extends Repository with ExceptionMapper { 10 | RemoteClient client; 11 | DataMapper mapper; 12 | 13 | RepositoryImp(this.client, this.mapper); 14 | 15 | @override 16 | Future> fetchProductItems(int page, int limit) async { 17 | try { 18 | final response = await client.fetchProductItems(page, limit); 19 | return response.data?.map((e) => mapper.mapProductItem(e)).toList() ?? []; 20 | } catch (e) { 21 | throw mapException(e); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /modules/product/lib/src/domain/models/item.dart: -------------------------------------------------------------------------------- 1 | class ProductItem { 2 | int id; 3 | String name; 4 | 5 | ProductItem({ 6 | required this.id, 7 | required this.name 8 | }); 9 | } -------------------------------------------------------------------------------- /modules/product/lib/src/domain/models/models.dart: -------------------------------------------------------------------------------- 1 | export 'item.dart'; -------------------------------------------------------------------------------- /modules/product/lib/src/domain/repository.dart: -------------------------------------------------------------------------------- 1 | import 'models/models.dart'; 2 | 3 | abstract class Repository { 4 | Future> fetchProductItems(int page, int limit); 5 | } 6 | -------------------------------------------------------------------------------- /modules/product/lib/src/domain/use_cases/home_product_use_case.dart: -------------------------------------------------------------------------------- 1 | import 'package:core/core.dart'; 2 | import '../models/models.dart'; 3 | import '../repository.dart'; 4 | 5 | class HomeProductUseCase { 6 | final Repository _repository; 7 | 8 | HomeProductUseCase(this._repository); 9 | 10 | Future, AppException>> execute( 11 | int page, int limit) async { 12 | try { 13 | final result = await _repository.fetchProductItems(page, limit); 14 | return Left(result); 15 | } on AppException catch (e) { 16 | return Right(e); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /modules/product/lib/src/presentation/localization/intl_en.arb: -------------------------------------------------------------------------------- 1 | { 2 | } -------------------------------------------------------------------------------- /modules/product/lib/src/presentation/localization/intl_vi.arb: -------------------------------------------------------------------------------- 1 | { 2 | } -------------------------------------------------------------------------------- /modules/product/lib/src/presentation/localization/localization.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'package:core/core.dart'; 3 | import 'package:flutter/foundation.dart'; 4 | import 'package:flutter/widgets.dart'; 5 | import 'generated/app_localizations.dart'; 6 | import 'generated/app_localizations_en.dart'; 7 | 8 | /// The actual `Localizations` class is [ModuleLocalizationImp], this class exists only for forward compatibility purposes... 9 | 10 | class ModuleLocalization { 11 | ModuleLocalization._(); 12 | 13 | static ModuleLocalizationImp of(BuildContext context) { 14 | return Localizations.of( 15 | context, ModuleLocalizationImp) ?? 16 | _default; 17 | } 18 | 19 | static const LocalizationsDelegate delegate = 20 | ModuleLocalizationsDelegate(); 21 | static const List> localizationsDelegates = 22 | ModuleLocalizationImp.localizationsDelegates; 23 | 24 | static const List supportedLocales = 25 | ModuleLocalizationImp.supportedLocales; 26 | static final _default = ModuleLocalizationImpEn(); 27 | static ModuleLocalizationImp? _current; 28 | 29 | static void setCurrentInstance(ModuleLocalizationImp? current) => 30 | _current = current; 31 | 32 | static ModuleLocalizationImp get current => _current ?? _default; 33 | } 34 | 35 | class ModuleLocalizationsDelegate 36 | extends LocalizationsDelegate { 37 | const ModuleLocalizationsDelegate(); 38 | 39 | @override 40 | Future load(Locale locale) { 41 | final instance = lookupModuleLocalizationImp(locale); 42 | ModuleLocalization.setCurrentInstance(instance); 43 | return SynchronousFuture(instance); 44 | } 45 | 46 | @override 47 | bool isSupported(Locale locale) => ModuleLocalizationImp.supportedLocales 48 | .map((e) => e.languageCode) 49 | .contains(locale.languageCode); 50 | 51 | @override 52 | bool shouldReload(ModuleLocalizationsDelegate old) => false; 53 | } 54 | 55 | extension GetModuleLocalization on GetInterface { 56 | ModuleLocalizationImp get moduleLocalization { 57 | if (context == null) throw Exception('Context is null'); 58 | return ModuleLocalization.of(context!); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /modules/product/lib/src/presentation/routes.dart: -------------------------------------------------------------------------------- 1 | import 'package:core/core.dart'; 2 | 3 | class RouteName {} 4 | 5 | class RoutePages { 6 | } 7 | -------------------------------------------------------------------------------- /modules/product/lib/src/product_module.dart: -------------------------------------------------------------------------------- 1 | import 'package:core/core.dart'; 2 | import 'package:flutter/widgets.dart'; 3 | 4 | import 'data/injection.dart'; 5 | import 'presentation/localization/localization.dart'; 6 | 7 | part 'product_module_imp.dart'; 8 | 9 | abstract class ProductModule extends BaseModule { 10 | static final ProductModule _instance = _ProductModuleImp(); 11 | 12 | static ProductModule get instance { 13 | return _instance; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /modules/product/lib/src/product_module_imp.dart: -------------------------------------------------------------------------------- 1 | part of 'product_module.dart'; 2 | 3 | class _ProductModuleImp extends ProductModule { 4 | _ProductModuleImp(); 5 | 6 | @override 7 | Future inject() async { 8 | DataInjection().inject(); 9 | } 10 | 11 | @override 12 | LocalizationsDelegate get localizationsDelegate => 13 | ModuleLocalization.delegate; 14 | } 15 | -------------------------------------------------------------------------------- /modules/product/lib/src/widgets/home_product_widget/home_product_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:core/core.dart'; 2 | 3 | import '../../data/repository_imp.dart'; 4 | import '../../domain/models/models.dart'; 5 | import '../../domain/use_cases/home_product_use_case.dart'; 6 | 7 | class HomeProductController extends BaseController { 8 | List items = []; 9 | bool canLoadMore = true; 10 | 11 | final limit = 10; 12 | int currentPage = 1; 13 | 14 | @override 15 | void onInit() { 16 | super.onInit(); 17 | Get.put(HomeProductUseCase(GetIt.instance.get())); 18 | fetchNewData(); 19 | } 20 | 21 | void fetchNewData() async { 22 | items.clear(); 23 | currentPage = 1; 24 | canLoadMore = true; 25 | viewStatus.value = BaseViewStatus.loading; 26 | await fetchData(); 27 | viewStatus.value = BaseViewStatus.success; 28 | } 29 | 30 | void loadMore() async { 31 | currentPage++; 32 | await fetchData(); 33 | } 34 | 35 | Future fetchData() async { 36 | final result = 37 | await Get.find().execute(currentPage, limit); 38 | result.fold((left) { 39 | canLoadMore = left.length == limit; 40 | items.addAll(left); 41 | update(); 42 | }, (right) { 43 | showError(right); 44 | }); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /modules/product/lib/src/widgets/home_product_widget/home_product_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:core/core.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:ui/ui.dart'; 4 | import '../../domain/models/models.dart'; 5 | import 'home_product_controller.dart'; 6 | 7 | class HomeProductWidget extends BaseWidget { 8 | const HomeProductWidget({super.key}); 9 | 10 | @override 11 | Widget successView(BuildContext context) { 12 | final controller = Get.find(); 13 | return ListViewLoadMore( 14 | itemBuilder: (ProductItem item, int index) { 15 | return _buildItem(context, item); 16 | }, 17 | onLoadMore: () => controller.loadMore(), 18 | list: controller.items, 19 | canLoadMore: controller.canLoadMore, 20 | onRefresh: () => controller.fetchNewData(), 21 | ); 22 | } 23 | 24 | Widget _buildItem(BuildContext context, ProductItem item) { 25 | return Container( 26 | margin: const EdgeInsets.symmetric(horizontal: 20, vertical: 10), 27 | padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10), 28 | decoration: BoxDecoration( 29 | borderRadius: BorderRadius.circular(4), 30 | border: Border.all(color: Colors.grey)), 31 | child: Column( 32 | crossAxisAlignment: CrossAxisAlignment.start, 33 | children: [ 34 | Text( 35 | item.name, 36 | style: Theme.of(context) 37 | .textTheme 38 | .bodyMedium 39 | ?.copyWith(fontSize: 19), 40 | ), 41 | const SizedBox( 42 | height: 7, 43 | ), 44 | Text( 45 | "id: ${item.id}", 46 | style: 47 | Theme.of(context).textTheme.bodySmall?.copyWith(fontSize: 16), 48 | ), 49 | ], 50 | )); 51 | } 52 | 53 | @override 54 | HomeProductController controller() => HomeProductController(); 55 | } 56 | -------------------------------------------------------------------------------- /modules/product/lib/src/widgets/home_product_widget_v2/home_product_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'package:core/core.dart'; 2 | 3 | import '../../data/repository_imp.dart'; 4 | import '../../domain/models/models.dart'; 5 | import '../../domain/use_cases/home_product_use_case.dart'; 6 | 7 | class HomeProductBloc extends BaseBloc { 8 | List items = []; 9 | 10 | final limit = 10; 11 | int currentPage = 1; 12 | 13 | HomeProductBloc(super.navigatorBloc); 14 | 15 | Future fetchNewData(Emitter emit) async { 16 | items.clear(); 17 | currentPage = 1; 18 | emit.loadingView(); 19 | await fetchData(emit); 20 | } 21 | 22 | Future loadMore(Emitter emit) async { 23 | currentPage++; 24 | await fetchData(emit); 25 | } 26 | 27 | Future fetchData(Emitter emit) async { 28 | final result = await HomeProductUseCase(GetIt.instance.get()) 29 | .execute(currentPage, limit); 30 | result.fold((left) { 31 | bool canLoadMore = left.length == limit; 32 | items.addAll(left); 33 | emit.customizeState(HomeProductBlocListViewState(items, canLoadMore)); 34 | }, (right) { 35 | showErrorDialog(right); 36 | }); 37 | } 38 | 39 | @override 40 | Future onInitialLoad(Emitter emit) { 41 | return fetchNewData(emit); 42 | } 43 | 44 | @override 45 | Future onEventCustomize( 46 | Emitter emit, BaseBlocEventScreen event) async { 47 | if (event is HomeProductBlocLoadMore) { 48 | await loadMore(emit); 49 | } 50 | } 51 | } 52 | 53 | class HomeProductBlocLoadMore extends BaseBlocEventScreen {} 54 | 55 | class HomeProductBlocListViewState extends BaseBlocStateScreen { 56 | List items; 57 | bool canLoadMore; 58 | 59 | HomeProductBlocListViewState(this.items, this.canLoadMore); 60 | } 61 | -------------------------------------------------------------------------------- /modules/product/lib/src/widgets/home_product_widget_v2/home_product_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:core/core.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:product/src/domain/models/models.dart'; 4 | import 'package:ui/ui.dart'; 5 | 6 | import 'home_product_bloc.dart'; 7 | 8 | class HomeProductWidget extends BaseBlocWidget { 9 | HomeProductWidget({super.key}); 10 | 11 | @override 12 | Widget customizeStateView( 13 | BuildContext context, BaseBlocStateScreen stateScreen) { 14 | if (stateScreen is HomeProductBlocListViewState) { 15 | return ListViewLoadMore( 16 | itemBuilder: (ProductItem item, int index) { 17 | return _buildItem(context, item); 18 | }, 19 | onLoadMore: () => 20 | onEmitCustomizeEvent(context, HomeProductBlocLoadMore()), 21 | list: stateScreen.items, 22 | canLoadMore: stateScreen.canLoadMore, 23 | onRefresh: () => 24 | context.read().add(BaseBlocEventInitial()), 25 | ); 26 | } 27 | return super.customizeStateView(context, stateScreen); 28 | } 29 | 30 | Widget _buildItem(BuildContext context, ProductItem item) { 31 | return Container( 32 | margin: const EdgeInsets.symmetric(horizontal: 20, vertical: 10), 33 | padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10), 34 | decoration: BoxDecoration( 35 | borderRadius: BorderRadius.circular(4), 36 | border: Border.all(color: Colors.grey)), 37 | child: Column( 38 | crossAxisAlignment: CrossAxisAlignment.start, 39 | children: [ 40 | Text( 41 | item.name, 42 | style: Theme.of(context) 43 | .textTheme 44 | .bodyMedium 45 | ?.copyWith(fontSize: 19), 46 | ), 47 | const SizedBox( 48 | height: 7, 49 | ), 50 | Text( 51 | "id: ${item.id}", 52 | style: 53 | Theme.of(context).textTheme.bodySmall?.copyWith(fontSize: 16), 54 | ), 55 | ], 56 | )); 57 | } 58 | 59 | @override 60 | HomeProductBloc buildBloc(BaseNavigatorBloc navigatorBloc) => 61 | HomeProductBloc(navigatorBloc); 62 | 63 | @override 64 | Widget successView(BuildContext context, D data) { 65 | return const SizedBox(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /modules/product/lib/src/widgets/widgets.dart: -------------------------------------------------------------------------------- 1 | // export 'home_product_widget/home_product_widget.dart'; 2 | export 'home_product_widget_v2/home_product_widget.dart'; 3 | -------------------------------------------------------------------------------- /modules/product/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: product 2 | description: A new Flutter package project. 3 | version: 0.0.1 4 | publish_to: none 5 | 6 | environment: 7 | sdk: '>=3.1.2 <4.0.0' 8 | flutter: ">=1.17.0" 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | ui: 14 | path: ../ui 15 | core: 16 | path: ../core 17 | 18 | dev_dependencies: 19 | flutter_test: 20 | sdk: flutter 21 | flutter_lints: ^2.0.0 22 | json_serializable: any 23 | build_runner: any 24 | retrofit_generator: any 25 | http_mock_adapter: any 26 | 27 | flutter: -------------------------------------------------------------------------------- /modules/product/pubspec_overrides.yaml: -------------------------------------------------------------------------------- 1 | # melos_managed_dependency_overrides: core,ui 2 | dependency_overrides: 3 | core: 4 | path: ../core 5 | ui: 6 | path: ../ui 7 | -------------------------------------------------------------------------------- /modules/ui/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. 26 | /pubspec.lock 27 | **/doc/api/ 28 | .dart_tool/ 29 | .packages 30 | build/ 31 | -------------------------------------------------------------------------------- /modules/ui/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: "367f9ea16bfae1ca451b9cc27c1366870b187ae2" 8 | channel: "stable" 9 | 10 | project_type: package 11 | -------------------------------------------------------------------------------- /modules/ui/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.0.1 2 | 3 | * TODO: Describe initial release. 4 | -------------------------------------------------------------------------------- /modules/ui/LICENSE: -------------------------------------------------------------------------------- 1 | TODO: Add your license here. 2 | -------------------------------------------------------------------------------- /modules/ui/README.md: -------------------------------------------------------------------------------- 1 | 13 | 14 | TODO: Put a short description of the package here that helps potential users 15 | know whether this package might be useful for them. 16 | 17 | ## Features 18 | 19 | TODO: List what your package can do. Maybe include images, gifs, or videos. 20 | 21 | ## Getting started 22 | 23 | TODO: List prerequisites and provide or point to information on how to 24 | start using the package. 25 | 26 | ## Usage 27 | 28 | TODO: Include short and useful examples for package users. Add longer examples 29 | to `/example` folder. 30 | 31 | ```dart 32 | const like = 'sample'; 33 | ``` 34 | 35 | ## Additional information 36 | 37 | TODO: Tell users more about the package: where to find more information, how to 38 | contribute to the package, how to file issues, what response they can expect 39 | from the package authors, and more. 40 | -------------------------------------------------------------------------------- /modules/ui/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:flutter_lints/flutter.yaml 2 | 3 | # Additional information about this file can be found at 4 | # https://dart.dev/guides/language/analysis-options 5 | -------------------------------------------------------------------------------- /modules/ui/assets/fonts/SFProText-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/modules/ui/assets/fonts/SFProText-Bold.ttf -------------------------------------------------------------------------------- /modules/ui/assets/fonts/SFProText-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/modules/ui/assets/fonts/SFProText-Medium.ttf -------------------------------------------------------------------------------- /modules/ui/assets/fonts/SFProText-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/modules/ui/assets/fonts/SFProText-Regular.ttf -------------------------------------------------------------------------------- /modules/ui/assets/fonts/SFProText-SemiBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/modules/ui/assets/fonts/SFProText-SemiBold.ttf -------------------------------------------------------------------------------- /modules/ui/assets/images/default_avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/modules/ui/assets/images/default_avatar.png -------------------------------------------------------------------------------- /modules/ui/l10n.yaml: -------------------------------------------------------------------------------- 1 | arb-dir: lib/src/localization 2 | template-arb-file: intl_en.arb 3 | output-class: ModuleLocalizationImp 4 | synthetic-package: false 5 | output-dir: lib/src/localization/generated -------------------------------------------------------------------------------- /modules/ui/lib/src/dialogs/dialogs.dart: -------------------------------------------------------------------------------- 1 | export 'message_dialog.dart'; -------------------------------------------------------------------------------- /modules/ui/lib/src/dialogs/message_dialog.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:ui/src/localization/localization.dart'; 3 | 4 | class MessageDialog extends StatelessWidget { 5 | final String? title; 6 | final String content; 7 | final Function? onDone; 8 | final String? textButton; 9 | 10 | const MessageDialog( 11 | {Key? key, 12 | this.title, 13 | required this.content, 14 | this.onDone, 15 | this.textButton}) 16 | : super(key: key); 17 | 18 | @override 19 | Widget build(BuildContext context) { 20 | return Center( 21 | child: Container( 22 | decoration: BoxDecoration( 23 | color: Colors.white, 24 | borderRadius: BorderRadius.circular(4.0), 25 | ), 26 | margin: const EdgeInsets.symmetric(horizontal: 50.0), 27 | padding: const EdgeInsets.only( 28 | top: 20.0, left: 20.0, right: 20.0, bottom: 10.0), 29 | child: Column( 30 | crossAxisAlignment: CrossAxisAlignment.stretch, 31 | mainAxisSize: MainAxisSize.min, 32 | children: [ 33 | Text( 34 | title ?? ModuleLocalization.of(context).dialog_message_title, 35 | style: Theme.of(context).textTheme.titleLarge, 36 | ), 37 | const SizedBox( 38 | height: 16.0, 39 | ), 40 | Text( 41 | content, 42 | style: Theme.of(context).textTheme.bodyMedium, 43 | ), 44 | const SizedBox(height: 16.0), 45 | SizedBox( 46 | height: 48.0, 47 | child: Align( 48 | alignment: Alignment.centerRight, 49 | child: GestureDetector( 50 | onTap: () { 51 | Navigator.pop(context); 52 | onDone?.call(); 53 | }, 54 | child: Padding( 55 | padding: 56 | const EdgeInsets.only(left: 10, top: 10, bottom: 10), 57 | child: Text( 58 | (textButton ?? 59 | ModuleLocalization.of(context) 60 | .dialog_message_done_button) 61 | .toUpperCase(), 62 | style: Theme.of(context).textTheme.labelLarge), 63 | ), 64 | ), 65 | ), 66 | ), 67 | ], 68 | ), 69 | ), 70 | ); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /modules/ui/lib/src/form_builder/form_builder.dart: -------------------------------------------------------------------------------- 1 | export 'form_builder_decoration.dart'; 2 | export 'form_builder_text_field.dart'; 3 | export 'form_builder_checkbox.dart'; 4 | -------------------------------------------------------------------------------- /modules/ui/lib/src/form_builder/form_builder_checkbox.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import 'package:flutter_form_builder/flutter_form_builder.dart'; 4 | 5 | class UIFormBuilderCheckbox extends FormBuilderFieldDecoration { 6 | final Widget title; 7 | 8 | final bool shouldRequestFocus; 9 | 10 | /// Creates a single Checkbox field 11 | UIFormBuilderCheckbox({ 12 | //From Super 13 | Key? key, 14 | required String name, 15 | FormFieldValidator? validator, 16 | bool? initialValue, 17 | InputDecoration decoration = const InputDecoration( 18 | border: InputBorder.none, 19 | focusedBorder: InputBorder.none, 20 | enabledBorder: InputBorder.none, 21 | errorBorder: InputBorder.none, 22 | disabledBorder: InputBorder.none, 23 | isDense: true, 24 | contentPadding: EdgeInsets.zero, 25 | errorStyle: TextStyle(fontSize: 13, height: 0.7, fontWeight: FontWeight.w400), 26 | ), 27 | ValueChanged? onChanged, 28 | ValueTransformer? valueTransformer, 29 | bool enabled = true, 30 | FormFieldSetter? onSaved, 31 | AutovalidateMode autovalidateMode = AutovalidateMode.disabled, 32 | VoidCallback? onReset, 33 | FocusNode? focusNode, 34 | required this.title, 35 | this.shouldRequestFocus = false, 36 | }) : super( 37 | key: key, 38 | initialValue: initialValue, 39 | name: name, 40 | validator: validator, 41 | valueTransformer: valueTransformer, 42 | onChanged: onChanged, 43 | autovalidateMode: autovalidateMode, 44 | onSaved: onSaved, 45 | enabled: enabled, 46 | onReset: onReset, 47 | decoration: decoration, 48 | focusNode: focusNode, 49 | builder: (FormFieldState field) { 50 | final state = field as FormBuilderCheckboxState; 51 | return InputDecorator( 52 | decoration: state.decoration, 53 | child: Row( 54 | crossAxisAlignment: CrossAxisAlignment.start, 55 | children: [ 56 | SizedBox( 57 | width: 24, 58 | height: 24, 59 | child: Checkbox( 60 | value: state.value ?? false, 61 | onChanged: state.enabled 62 | ? (value) { 63 | if (shouldRequestFocus) { 64 | state.focus(); 65 | } 66 | state.didChange(value); 67 | } 68 | : null, 69 | ), 70 | ), 71 | const SizedBox( 72 | width: 10, 73 | ), 74 | Expanded( 75 | child: InkWell( 76 | onTap: () { 77 | state.didChange(!(state.value ?? false)); 78 | }, 79 | child: title, 80 | ), 81 | ) 82 | ], 83 | ), 84 | ); 85 | }, 86 | ); 87 | 88 | @override 89 | FormBuilderCheckboxState createState() => FormBuilderCheckboxState(); 90 | } 91 | 92 | class FormBuilderCheckboxState 93 | extends FormBuilderFieldDecorationState {} 94 | -------------------------------------------------------------------------------- /modules/ui/lib/src/form_builder/form_builder_decoration.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:ui/src/themes/fonts.dart'; 3 | 4 | class UIInputDecoration extends InputDecoration { 5 | const UIInputDecoration( 6 | {super.isDense = true, 7 | super.counterText = "", 8 | required super.labelText, 9 | super.alignLabelWithHint = true, 10 | super.border = const OutlineInputBorder(), 11 | super.focusedBorder, 12 | super.enabledBorder, 13 | super.labelStyle = const TextStyle( 14 | fontFamily: UIFonts.sfPro, fontSize: 14, color: Color(0xFF7B8794)), 15 | super.floatingLabelStyle = const TextStyle( 16 | fontFamily: UIFonts.sfPro, 17 | fontSize: 14, 18 | color: Color(0xFF7B8794), 19 | fontWeight: FontWeight.w500), 20 | super.contentPadding = const EdgeInsets.fromLTRB(11, 13, 11, 12), 21 | super.errorStyle = const TextStyle( 22 | fontFamily: UIFonts.sfPro, 23 | fontSize: 13, 24 | height: 1, 25 | fontWeight: FontWeight.w400), 26 | super.errorMaxLines = 2, 27 | super.prefixIcon, 28 | super.prefixIconConstraints, 29 | super.enabled, 30 | super.filled = false, 31 | super.fillColor = const Color(0xFFFAFAFA), 32 | super.floatingLabelBehavior = FloatingLabelBehavior.auto, 33 | super.hintMaxLines = 15, 34 | super.hintText, 35 | super.hintStyle = const TextStyle( 36 | fontFamily: UIFonts.sfPro, fontSize: 14, color: Color(0xFF7B8794)), 37 | super.suffixIcon, 38 | super.prefixText, 39 | super.suffixIconConstraints}); 40 | } 41 | -------------------------------------------------------------------------------- /modules/ui/lib/src/libs.dart: -------------------------------------------------------------------------------- 1 | export 'package:flutter_form_builder/flutter_form_builder.dart'; 2 | export 'package:form_builder_validators/form_builder_validators.dart'; -------------------------------------------------------------------------------- /modules/ui/lib/src/list_view/list_view.dart: -------------------------------------------------------------------------------- 1 | export 'grid_view_load_more.dart'; 2 | export 'list_view_load_more.dart'; -------------------------------------------------------------------------------- /modules/ui/lib/src/list_view/list_view_load_more.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | class ListViewLoadMore extends StatefulWidget { 5 | final Widget Function(T item, int index) itemBuilder; 6 | final Function() onLoadMore; 7 | final Function()? onRefresh; 8 | final List list; 9 | final ScrollController? scrollController; 10 | final bool canLoadMore; 11 | 12 | const ListViewLoadMore( 13 | {super.key, 14 | required this.itemBuilder, 15 | required this.onLoadMore, 16 | this.onRefresh, 17 | required this.list, 18 | this.scrollController, 19 | required this.canLoadMore}); 20 | 21 | @override 22 | State createState() => _ListViewLoadMoreState(); 23 | } 24 | 25 | class _ListViewLoadMoreState extends State> { 26 | bool _canLoadMore = false; 27 | bool _loading = false; 28 | final double _endReachedThreshold = 200; 29 | late ScrollController _scrollController; 30 | 31 | @override 32 | void initState() { 33 | super.initState(); 34 | _canLoadMore = widget.canLoadMore; 35 | _scrollController = widget.scrollController ?? ScrollController(); 36 | _scrollController.addListener(_onScroll); 37 | } 38 | 39 | void _onScroll() { 40 | if (!_scrollController.hasClients || _loading || !_canLoadMore) return; 41 | 42 | final thresholdReached = 43 | _scrollController.position.extentAfter < _endReachedThreshold; 44 | 45 | if (thresholdReached) { 46 | widget.onLoadMore(); 47 | _loading = true; 48 | } 49 | } 50 | 51 | @override 52 | Widget build(BuildContext context) { 53 | _loading = false; 54 | if (_canLoadMore != widget.canLoadMore) { 55 | _canLoadMore = widget.canLoadMore; 56 | } 57 | return CustomScrollView( 58 | controller: _scrollController, 59 | slivers: [ 60 | CupertinoSliverRefreshControl( 61 | onRefresh: () async { 62 | widget.onRefresh?.call(); 63 | }, 64 | ), 65 | SliverList( 66 | delegate: SliverChildBuilderDelegate( 67 | (context, index) { 68 | T item = widget.list[index]; 69 | return widget.itemBuilder(item, index); 70 | }, 71 | childCount: widget.list.length, 72 | ), 73 | ), 74 | SliverToBoxAdapter( 75 | child: _canLoadMore 76 | ? const Row( 77 | mainAxisAlignment: MainAxisAlignment.center, 78 | children: [ 79 | Padding( 80 | padding: EdgeInsets.all(12.0), 81 | child: SizedBox( 82 | height: 23.0, 83 | width: 23.0, 84 | child: CircularProgressIndicator(strokeWidth: 2), 85 | ), 86 | ) 87 | ], 88 | ) 89 | : const SizedBox(), 90 | ), 91 | ], 92 | ); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /modules/ui/lib/src/localization/intl_en.arb: -------------------------------------------------------------------------------- 1 | { 2 | "dialog_message_done_button": "Done", 3 | "dialog_message_title": "Notice", 4 | "required_info": "Required info", 5 | "invalid_input": "Invalid input" 6 | } -------------------------------------------------------------------------------- /modules/ui/lib/src/localization/intl_vi.arb: -------------------------------------------------------------------------------- 1 | { 2 | "dialog_message_done_button": "Xong", 3 | "dialog_message_title": "Thông báo", 4 | "required_info": "Thông tin bắt buộc", 5 | "invalid_input": "Dữ liệu không hợpn lệ" 6 | } -------------------------------------------------------------------------------- /modules/ui/lib/src/localization/localization.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'package:flutter/foundation.dart'; 3 | import 'package:flutter/widgets.dart'; 4 | import 'generated/app_localizations.dart'; 5 | import 'generated/app_localizations_en.dart'; 6 | 7 | /// The actual `Localizations` class is [ModuleLocalizationImp], this class exists only for forward compatibility purposes... 8 | 9 | // for public 10 | typedef UILocalization = ModuleLocalization; 11 | 12 | class ModuleLocalization { 13 | ModuleLocalization._(); 14 | 15 | static ModuleLocalizationImp of(BuildContext context) { 16 | return Localizations.of( 17 | context, ModuleLocalizationImp) ?? 18 | _default; 19 | } 20 | 21 | static const LocalizationsDelegate delegate = 22 | ModuleLocalizationsDelegate(); 23 | static const List> localizationsDelegates = 24 | ModuleLocalizationImp.localizationsDelegates; 25 | 26 | static const List supportedLocales = 27 | ModuleLocalizationImp.supportedLocales; 28 | static final _default = ModuleLocalizationImpEn(); 29 | static ModuleLocalizationImp? _current; 30 | 31 | static void setCurrentInstance(ModuleLocalizationImp? current) => 32 | _current = current; 33 | 34 | static ModuleLocalizationImp get current => _current ?? _default; 35 | } 36 | 37 | class ModuleLocalizationsDelegate 38 | extends LocalizationsDelegate { 39 | const ModuleLocalizationsDelegate(); 40 | 41 | @override 42 | Future load(Locale locale) { 43 | final instance = lookupModuleLocalizationImp(locale); 44 | ModuleLocalization.setCurrentInstance(instance); 45 | return SynchronousFuture(instance); 46 | } 47 | 48 | @override 49 | bool isSupported(Locale locale) => ModuleLocalizationImp.supportedLocales 50 | .map((e) => e.languageCode) 51 | .contains(locale.languageCode); 52 | 53 | @override 54 | bool shouldReload(ModuleLocalizationsDelegate old) => false; 55 | } 56 | -------------------------------------------------------------------------------- /modules/ui/lib/src/themes/colors.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | class UIColor { 4 | UIColor._(); 5 | 6 | static Color primaryColor = const Color(0xFF457DDE); 7 | } 8 | -------------------------------------------------------------------------------- /modules/ui/lib/src/themes/fonts.dart: -------------------------------------------------------------------------------- 1 | class UIFonts { 2 | UIFonts._(); 3 | 4 | //fonts 5 | static const String sfPro = 'packages/ui/sf_pro'; 6 | static const String fontPath = 7 | 'packages/ui/assets/fonts/SFProText-Regular.ttf'; 8 | } 9 | -------------------------------------------------------------------------------- /modules/ui/lib/src/themes/theme.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:ui/src/themes/fonts.dart'; 3 | 4 | import 'colors.dart'; 5 | 6 | final uiTheme = ThemeData( 7 | primaryColor: UIColor.primaryColor, 8 | colorScheme: ColorScheme.fromSeed( 9 | seedColor: UIColor.primaryColor, primary: UIColor.primaryColor), 10 | textTheme: textTheme, 11 | fontFamily: UIFonts.sfPro, 12 | checkboxTheme: CheckboxThemeData( 13 | fillColor: MaterialStateProperty.resolveWith( 14 | (Set states) { 15 | if (states.contains(MaterialState.disabled)) { 16 | return null; 17 | } 18 | if (states.contains(MaterialState.selected)) { 19 | return UIColor.primaryColor; 20 | } 21 | return null; 22 | }), 23 | ), 24 | radioTheme: RadioThemeData( 25 | fillColor: MaterialStateProperty.resolveWith( 26 | (Set states) { 27 | if (states.contains(MaterialState.disabled)) { 28 | return null; 29 | } 30 | if (states.contains(MaterialState.selected)) { 31 | return UIColor.primaryColor; 32 | } 33 | return null; 34 | }), 35 | ), 36 | switchTheme: SwitchThemeData( 37 | thumbColor: MaterialStateProperty.resolveWith( 38 | (Set states) { 39 | if (states.contains(MaterialState.disabled)) { 40 | return null; 41 | } 42 | if (states.contains(MaterialState.selected)) { 43 | return UIColor.primaryColor; 44 | } 45 | return null; 46 | }), 47 | trackColor: MaterialStateProperty.resolveWith( 48 | (Set states) { 49 | if (states.contains(MaterialState.disabled)) { 50 | return null; 51 | } 52 | if (states.contains(MaterialState.selected)) { 53 | return UIColor.primaryColor; 54 | } 55 | return null; 56 | }), 57 | )); 58 | 59 | final textTheme = TextTheme( 60 | headlineSmall: const TextStyle(fontSize: 24, fontWeight: FontWeight.w600), 61 | titleLarge: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600), 62 | labelLarge: TextStyle( 63 | fontSize: 16, fontWeight: FontWeight.w500, color: UIColor.primaryColor), 64 | bodyLarge: const TextStyle( 65 | fontSize: 16, 66 | ), 67 | bodyMedium: const TextStyle( 68 | fontSize: 14, 69 | ), 70 | bodySmall: const TextStyle(fontSize: 13, fontWeight: FontWeight.w500), 71 | titleMedium: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600), 72 | titleSmall: const TextStyle(fontSize: 14, fontWeight: FontWeight.w500)); 73 | -------------------------------------------------------------------------------- /modules/ui/lib/src/ui.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | 3 | import 'localization/generated/app_localizations.dart'; 4 | import 'localization/localization.dart'; 5 | 6 | class UI { 7 | static const LocalizationsDelegate 8 | localizationsDelegate = ModuleLocalization.delegate; 9 | } 10 | -------------------------------------------------------------------------------- /modules/ui/lib/ui.dart: -------------------------------------------------------------------------------- 1 | library ui; 2 | 3 | export 'src/dialogs/dialogs.dart'; 4 | export 'src/list_view/list_view.dart'; 5 | export 'src/themes/theme.dart'; 6 | export 'src/ui.dart'; 7 | export 'src/form_builder/form_builder.dart'; 8 | export 'src/libs.dart'; 9 | -------------------------------------------------------------------------------- /modules/ui/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: ui 2 | description: A new Flutter package project. 3 | version: 0.0.1 4 | publish_to: none 5 | 6 | environment: 7 | sdk: '>=3.1.2 <4.0.0' 8 | flutter: ">=1.17.0" 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | intl: ^0.18.0 14 | flutter_form_builder: ^9.1.1 15 | form_builder_validators: ^9.1.0 16 | flutter_localizations: 17 | sdk: flutter 18 | 19 | dev_dependencies: 20 | flutter_test: 21 | sdk: flutter 22 | flutter_lints: ^2.0.0 23 | 24 | flutter: 25 | assets: 26 | - assets/images/ 27 | fonts: 28 | - family: sf_pro 29 | fonts: 30 | - asset: assets/fonts/SFProText-Regular.ttf 31 | weight: 400 32 | - asset: assets/fonts/SFProText-Medium.ttf 33 | weight: 500 34 | - asset: assets/fonts/SFProText-SemiBold.ttf 35 | weight: 600 36 | - asset: assets/fonts/SFProText-Bold.ttf 37 | weight: 700 38 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_micro_frontend 2 | description: Flutter Micro Front-end 3 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev 4 | 5 | version: 1.0.0+1 6 | 7 | environment: 8 | sdk: '>=3.1.2 <4.0.0' 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | flutter_localizations: 14 | sdk: flutter 15 | cupertino_icons: ^1.0.2 16 | flutter_native_splash: ^2.3.7 17 | core: 18 | path: ./modules/core 19 | ui: 20 | path: ./modules/ui 21 | auth: 22 | path: ./modules/auth 23 | product: 24 | path: ./modules/product 25 | 26 | dev_dependencies: 27 | flutter_test: 28 | sdk: flutter 29 | flutter_lints: ^2.0.0 30 | melos: ^3.4.0 31 | 32 | flutter: 33 | uses-material-design: true 34 | assets: 35 | - assets/images/ 36 | -------------------------------------------------------------------------------- /web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/web/favicon.png -------------------------------------------------------------------------------- /web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/web/icons/Icon-192.png -------------------------------------------------------------------------------- /web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/web/icons/Icon-512.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | flutter_micro_frontend 33 | 34 | 35 | 39 | 40 | 41 | 42 | 43 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "flutter_micro_frontend", 3 | "short_name": "flutter_micro_frontend", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "Flutter Micro Front-end", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | 10 | void RegisterPlugins(flutter::PluginRegistry* registry) { 11 | } 12 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | ) 7 | 8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 9 | ) 10 | 11 | set(PLUGIN_BUNDLED_LIBRARIES) 12 | 13 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 18 | endforeach(plugin) 19 | 20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 23 | endforeach(ffi_plugin) 24 | -------------------------------------------------------------------------------- /windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} WIN32 10 | "flutter_window.cpp" 11 | "main.cpp" 12 | "utils.cpp" 13 | "win32_window.cpp" 14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 15 | "Runner.rc" 16 | "runner.exe.manifest" 17 | ) 18 | 19 | # Apply the standard set of build settings. This can be removed for applications 20 | # that need different build settings. 21 | apply_standard_settings(${BINARY_NAME}) 22 | 23 | # Add preprocessor definitions for the build version. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") 25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") 26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") 27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") 28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") 29 | 30 | # Disable Windows macros that collide with C++ standard library functions. 31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 32 | 33 | # Add dependency libraries and include directories. Add any application-specific 34 | # dependencies here. 35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 36 | target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") 37 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 38 | 39 | # Run the Flutter tool portions of the build. This must not be removed. 40 | add_dependencies(${BINARY_NAME} flutter_assemble) 41 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | 30 | flutter_controller_->engine()->SetNextFrameCallback([&]() { 31 | this->Show(); 32 | }); 33 | 34 | // Flutter can complete the first frame before the "show window" callback is 35 | // registered. The following call ensures a frame is pending to ensure the 36 | // window is shown. It is a no-op if the first frame hasn't completed yet. 37 | flutter_controller_->ForceRedraw(); 38 | 39 | return true; 40 | } 41 | 42 | void FlutterWindow::OnDestroy() { 43 | if (flutter_controller_) { 44 | flutter_controller_ = nullptr; 45 | } 46 | 47 | Win32Window::OnDestroy(); 48 | } 49 | 50 | LRESULT 51 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 52 | WPARAM const wparam, 53 | LPARAM const lparam) noexcept { 54 | // Give Flutter, including plugins, an opportunity to handle window messages. 55 | if (flutter_controller_) { 56 | std::optional result = 57 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 58 | lparam); 59 | if (result) { 60 | return *result; 61 | } 62 | } 63 | 64 | switch (message) { 65 | case WM_FONTCHANGE: 66 | flutter_controller_->engine()->ReloadSystemFonts(); 67 | break; 68 | } 69 | 70 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 71 | } 72 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.Create(L"flutter_micro_frontend", origin, size)) { 31 | return EXIT_FAILURE; 32 | } 33 | window.SetQuitOnClose(true); 34 | 35 | ::MSG msg; 36 | while (::GetMessage(&msg, nullptr, 0, 0)) { 37 | ::TranslateMessage(&msg); 38 | ::DispatchMessage(&msg); 39 | } 40 | 41 | ::CoUninitialize(); 42 | return EXIT_SUCCESS; 43 | } 44 | -------------------------------------------------------------------------------- /windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tungnddev/flutter_micro_frontend/a50c8031e2df8b3a5f0bd9ea8df15c7c2e93cd28/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr) 51 | -1; // remove the trailing null character 52 | int input_length = (int)wcslen(utf16_string); 53 | std::string utf8_string; 54 | if (target_length <= 0 || target_length > utf8_string.max_size()) { 55 | return utf8_string; 56 | } 57 | utf8_string.resize(target_length); 58 | int converted_length = ::WideCharToMultiByte( 59 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 60 | input_length, utf8_string.data(), target_length, nullptr, nullptr); 61 | if (converted_length == 0) { 62 | return std::string(); 63 | } 64 | return utf8_string; 65 | } 66 | -------------------------------------------------------------------------------- /windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | --------------------------------------------------------------------------------