├── .gitignore ├── .metadata ├── .vscode ├── launch.json └── settings.json ├── CHANGELOG.md ├── LICENSE ├── README.md ├── README.pt-br.md ├── analysis_options.yaml ├── devtools_options.yaml ├── example ├── .gitignore ├── .metadata ├── README.md ├── analysis_options.yaml ├── devtools_options.yaml ├── lib │ ├── application │ │ ├── bindings │ │ │ ├── application_bindings.dart │ │ │ └── navigator_bindings.dart │ │ ├── debug │ │ │ └── my_debug_log.dart │ │ ├── deep_link │ │ │ └── my_deep_link.dart │ │ ├── middleware │ │ │ ├── auth_middleware.dart │ │ │ ├── module_middleware.dart │ │ │ ├── page_middleware.dart │ │ │ └── print_middleware.dart │ │ └── session │ │ │ ├── model │ │ │ └── user_model.dart │ │ │ └── user_session.dart │ ├── main.dart │ └── src │ │ ├── auth │ │ ├── repository │ │ │ └── auth_repository.dart │ │ └── view │ │ │ ├── active_account │ │ │ ├── active_account_controller.dart │ │ │ ├── active_account_page.dart │ │ │ └── validate_email_controller.dart │ │ │ ├── login │ │ │ ├── login_controller.dart │ │ │ └── login_page.dart │ │ │ └── register │ │ │ ├── register_controller.dart │ │ │ └── register_page.dart │ │ ├── detail │ │ ├── detail_controller.dart │ │ ├── detail_module.dart │ │ ├── detail_page.dart │ │ ├── detail_repository.dart │ │ ├── detail_super_controller.dart │ │ ├── detail_super_page.dart │ │ ├── internal │ │ │ ├── detail_internal_child.dart │ │ │ ├── detail_internal_page.dart │ │ │ └── detail_internal_repository.dart │ │ └── widget │ │ │ ├── form_item.dart │ │ │ └── form_item_controller.dart │ │ ├── home │ │ ├── home_controller.dart │ │ ├── home_module.dart │ │ └── home_page.dart │ │ ├── landing │ │ ├── initialize_bloc.dart │ │ ├── initialize_controller.dart │ │ ├── initialize_page.dart │ │ ├── landing_module.dart │ │ └── presentation_page.dart │ │ ├── loader │ │ └── load_dependencies.dart │ │ ├── nav_bar │ │ ├── my_nav_bar.dart │ │ ├── my_nav_bar_helper_controller.dart │ │ └── nav_bar_module.dart │ │ ├── param_example │ │ ├── param_example_module.dart │ │ ├── param_page.dart │ │ └── param_page_controller.dart │ │ ├── products │ │ ├── model │ │ │ └── product_model.dart │ │ ├── product_controller.dart │ │ ├── products_detail.dart │ │ ├── products_module.dart │ │ └── products_page.dart │ │ ├── random │ │ ├── random_controller.dart │ │ └── random_page.dart │ │ ├── route_outlet_nav_bar │ │ ├── my_nav_bar.dart │ │ ├── my_nav_bar_helper_controller.dart │ │ └── nav_bar_module.dart │ │ └── splash │ │ └── splash_page.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 │ ├── Podfile.lock │ ├── 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 ├── pubspec.lock ├── pubspec.yaml ├── test │ └── widget_test.dart ├── 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 ├── extension └── devtools │ ├── .pubignore │ ├── build │ ├── assets │ │ ├── AssetManifest.bin │ │ ├── AssetManifest.bin.json │ │ ├── AssetManifest.json │ │ ├── FontManifest.json │ │ ├── NOTICES │ │ ├── fonts │ │ │ └── MaterialIcons-Regular.otf │ │ ├── packages │ │ │ ├── cupertino_icons │ │ │ │ └── assets │ │ │ │ │ └── CupertinoIcons.ttf │ │ │ └── devtools_app_shared │ │ │ │ └── fonts │ │ │ │ ├── Roboto │ │ │ │ ├── Roboto-Black.ttf │ │ │ │ ├── Roboto-Bold.ttf │ │ │ │ ├── Roboto-Light.ttf │ │ │ │ ├── Roboto-Medium.ttf │ │ │ │ ├── Roboto-Regular.ttf │ │ │ │ └── Roboto-Thin.ttf │ │ │ │ └── Roboto_Mono │ │ │ │ ├── RobotoMono-Bold.ttf │ │ │ │ ├── RobotoMono-Light.ttf │ │ │ │ ├── RobotoMono-Medium.ttf │ │ │ │ ├── RobotoMono-Regular.ttf │ │ │ │ └── RobotoMono-Thin.ttf │ │ └── shaders │ │ │ └── ink_sparkle.frag │ ├── canvaskit │ │ ├── canvaskit.js │ │ ├── canvaskit.js.symbols │ │ ├── canvaskit.wasm │ │ ├── chromium │ │ │ ├── canvaskit.js │ │ │ ├── canvaskit.js.symbols │ │ │ └── canvaskit.wasm │ │ ├── skwasm.js │ │ ├── skwasm.js.symbols │ │ ├── skwasm.wasm │ │ └── skwasm.worker.js │ ├── favicon.png │ ├── flutter.js │ ├── flutter_bootstrap.js │ ├── flutter_service_worker.js │ ├── icons │ │ ├── Icon-192.png │ │ ├── Icon-512.png │ │ ├── Icon-maskable-192.png │ │ └── Icon-maskable-512.png │ ├── index.html │ ├── main.dart.js │ ├── manifest.json │ └── version.json │ └── config.yaml ├── lib ├── flutter_getit.dart └── src │ ├── config │ └── flutter_getit_config.dart │ ├── core │ ├── flutter_getit_container_register.dart │ └── model │ │ └── binding_register.dart │ ├── debug │ ├── debug_device.dart │ ├── debug_mode.dart │ ├── debug_web.dart │ ├── extension │ │ └── flutter_get_it_extension.dart │ └── log │ │ └── flutter_get_it_logger.dart │ ├── dependency_injector │ ├── binds │ │ ├── application_bindings.dart │ │ ├── bind.dart │ │ └── flutter_get_it_binding_register.dart │ ├── flutter_get_it_binding_opened.dart │ ├── flutter_get_it_check_dependency.dart │ └── injector.dart │ ├── enum │ └── middleware_result.dart │ ├── helper │ └── flutter_get_it_helper.dart │ ├── middleware │ ├── flutter_get_it_async_middleware.dart │ ├── flutter_get_it_middleware.dart │ ├── flutter_get_it_middleware_context.dart │ └── flutter_get_it_sync_middleware.dart │ ├── mixin │ └── flutter_get_it_mixin.dart │ ├── routers │ ├── flutter_get_it_route_params_extractor.dart │ ├── flutter_getit_module.dart │ └── flutter_getit_module_page_router.dart │ ├── types │ └── flutter_getit_typedefs.dart │ └── widget │ ├── flutter_getit_route_outlet.dart │ ├── flutter_getit_view.dart │ └── flutter_getit_widget.dart └── pubspec.yaml /.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 | !/extension/devtools/build/ -------------------------------------------------------------------------------- /.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: ffccd96b62ee8cec7740dab303538c5fc26ac543 8 | channel: stable 9 | 10 | project_type: package 11 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "flutter_getit", 9 | "request": "launch", 10 | "type": "dart", 11 | // "program": "example/lib/main.dart" 12 | }, 13 | { 14 | "name": "flutter_getit (profile mode)", 15 | "request": "launch", 16 | "type": "dart", 17 | "flutterMode": "profile" 18 | }, 19 | { 20 | "name": "flutter_getit (release mode)", 21 | "request": "launch", 22 | "type": "dart", 23 | "flutterMode": "release" 24 | } 25 | ] 26 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "cSpell.words": [ 3 | "academiadoflutter", 4 | "Classe", 5 | "fgetit", 6 | "getit", 7 | "typedefs" 8 | ] 9 | } -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Versions 2 | ## 3.0.1 3 | Fix: FGetit it was removing dependency when would still be use in another module 4 | 5 | ## 3.0.0 6 | - **Breaking Change**: For existing users, please review the detailed in the documentation. 7 | 8 | ## 3.0.0-rc.6 9 | - Fix: Add check when the bind is already registered 10 | 11 | ## 3.0.0-rc.5 12 | - Fix: 13 | In throwIf isRegistered tag was not being sent 14 | getAsync was not present in "BuildContext" extension 15 | 16 | ## 3.0.0-rc.4 17 | - Change pages and module to pagesRouter and moduleRouter to separate responsibilities for handling modules or simple pages. 18 | 19 | ## 3.0.0-rc.3 20 | - A special thank you to @lleoserrano and @brasizza, who worked so hard to make our package even better! 21 | 22 | - New component for internal routing using existing routes called FlutterGetItRouteOutlet. 23 | 24 | - **Breaking Change**: For existing users, please review the detailed in the documentation. 25 | 26 | ### Major Changes 27 | 28 | - Complete package rewrite to support modular architecture. 29 | 30 | ### Core Changes 31 | - Removed `FlutterGetItNavigatorObserver` on builder. 32 | - The `pages` now expect the new `FlutterGetItModuleRouter`. 33 | - New named constructor called `.navigator` to create a new instance of `FlutterGetIt` for navigator 2.0. 34 | 35 | ### Module Changes 36 | - The `FlutterGetItModule` now has a new method `onInit` that is called when the module is initialized and a new method `onDispose` that is called when the module is disposed. 37 | 38 | ### Binds Changes 39 | - News methods, as `singletonAsync`, `factoryAsync`, `lazySingletonAsync` 40 | - New system of factory named, able to create and identify the factory by name. 41 | - New `keepAlive` method to keep the instance alive even after the module is disposed. 42 | 43 | ### New mixin 44 | - `FlutterGetItModuleMixin` is a mixin that allows you to use the `onInit` and `onDispose` methods in your class. 45 | 46 | ### Widgets Changes 47 | - New `FlutterGetItView` to automatically inject the object into the widget. 48 | - New `FlutterGetItWidget` to create a widget with lifecycle methods as `onInit` and `onDispose`, and allow to inject the object into the widget. 49 | 50 | ## 2.0.0 51 | Aprimorando a apresentação e a clareza do texto da versão 2.0.0: 52 | 53 | ## Version 2.0.0 Highlights 54 | 55 | ### Major Changes 56 | - **Breaking Change**: For existing users, please review the detailed in the documentation. 57 | - Complete package rewrite to support modular architecture. 58 | 59 | ### Enhancements 60 | - `ApplicationBindings` are now included in the export list for improved integration. 61 | - A significant update to the documentation, including an English version for broader accessibility. 62 | - Revised the example to align with version 2.0 standards. 63 | 64 | ### Technical Improvements 65 | - Package description updated to comply with the 180-character limit rule. 66 | - Integration of `flutter_getit` into DevTools, allowing for effective visualization of existing instances. 67 | - Enhanced DevTools extension layout for better user experience. 68 | 69 | ### Fixes 70 | - Resolved an initialization failure caused by the absence of binding (either binding or bindingBuilder) in FlutterGetItConfig. 71 | - Eliminated redundant injector in routes, utilizing the existing context injector for efficiency. 72 | 73 | ### Documentation and Metadata 74 | - Expanded project documentation, focusing on clarity and comprehensiveness. 75 | - Enhanced pubspec.yaml with additional tags and topics to facilitate easier discovery on pub.dev. 76 | - License transitioned from Apache-2 to MIT, reflecting changes in licensing preferences. 77 | 78 | ### Development Tool Adjustments 79 | - Implemented `.pubignore` in DevTools for optimized performance. 80 | - Excluded the /build folder from the extension to streamline the development process. 81 | 82 | ### New Features 83 | - Introduced a new method for registering permanent bindings under a specific key (FlutterGetItBindingRegister), adding flexibility and control for developers. 84 | 85 | This comprehensive update in version 2.0.0 aims to enhance usability, streamline integration, and expand accessibility, reflecting our commitment to continuous. 86 | 87 | 88 | ## 2.0.0-dev.13 89 | - feat: Implement method for permanent binding registration under specific key (FlutterGetItBindingRegister) 90 | 91 | ## 2.0.0-dev.12 92 | - fix: remove injector in routes, injector already within the context 93 | 94 | ## 2.0.0-dev.11 95 | - feat: Add getter Injector in routes 96 | 97 | ## 2.0.0-dev.10 98 | - fix: Error due to no binding (either binding or bindingBuilder) being sent. The assertion in FlutterGetItConfig caused the initialization to fail 99 | 100 | ## 2.0.0-dev.9 101 | - feat: changed layout devtools extension 102 | 103 | ## 2.0.0-dev.8 104 | - fix: Exclude /build to extension 105 | 106 | ## 2.0.0-dev.7 107 | - fix: added .pubignore um devtools 108 | 109 | ## 2.0.0-dev.6 110 | - feat: Added `flutter_getit` to DevTools, enabling the visualization of existing instances through DevTools. 111 | 112 | ## 2.0.0-dev.5 113 | - chore: Added tags and topics in pubspec.yaml to facilitate the search in pub.dev. 114 | - chore: Change license from Apache-2 to MIT 115 | 116 | ## 2.0.0-dev.4 117 | - fix: updated package description to adhere to the rule of a maximum of 180 characters 118 | 119 | ## 2.0.0-dev.3 120 | - docs: Added documentation in English 121 | - docs: Improvements to the project documentation 122 | - fix: Changing example to version 2.0 123 | 124 | ## 2.0.0-dev.2 125 | - Fix: adicionado ApplicationBindings no export 126 | - docs: Documentação atualizada (Versao 1) 127 | 128 | ## 2.0.0-dev.1 129 | - Reescrita do package com suporte a módulos 130 | 131 | - **Break Change**: 132 | Leia a documentação e caso você já tenha implementado no seu projeto veja a documentação de migração da versão 1 para a versão 2 133 | 134 | ## 1.2.1 135 | 136 | * Suporte a secondary register, esse recurso permite que vc coloque no binding um objeto que já está registrado na arvore de componentes 137 | evitando assim a duplicidade e erro do getit Object is already registeres inside GetIt; 138 | 139 | 140 | ## 1.2.0 141 | 142 | * Adicionando FlutterGetItApplicationBinding 143 | 144 | ## 1.1.1 145 | 146 | * Removendo Warnings 147 | 148 | ## 1.1.0 149 | 150 | * Criação de 3 novos tipos de Widget (FlutterGetItPageRoute, FlutterGetItWidget, FlutterGetItPageBuilder) cada um com seu objetivo 151 | 152 | * Descontinuamos a classe GetItPageRoute deve ser substituida pela classe FlutterGetItPageRoute (**ATENÇÃO: Essa classe será removida na próxima versão**) 153 | 154 | * Refactory no Injector antes você precisava chama com Injector().get, agora deve ser utilizado com Injector.get. 155 | 156 | * Acerto no dartdoc 157 | 158 | * Acertos na documentação 159 | 160 | * Adicionado exemplo de implementação na documentação 161 | 162 | ## 1.0.0 163 | 164 | * Release 1.0.0 165 | 166 | ## 0.0.3 167 | 168 | * Change description and name project 169 | 170 | ## 0.0.2 171 | 172 | * Add documentation 173 | 174 | ## 0.0.1 175 | 176 | * Beta Version 177 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Rodrigo Rahman 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /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 17 | # https://dart-lang.github.io/linter/lints/index.html. 18 | # 19 | # Instead of disabling a lint rule for the entire project in the 20 | # section below, it can also be suppressed for a single line of code 21 | # or a specific dart file by using the `// ignore: name_of_lint` and 22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 23 | # producing the lint. 24 | rules: 25 | prefer_single_quotes: true 26 | prefer_relative_imports: true 27 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 28 | 29 | 30 | # Additional information about this file can be found at 31 | # https://dart.dev/guides/language/analysis-options 32 | -------------------------------------------------------------------------------- /devtools_options.yaml: -------------------------------------------------------------------------------- 1 | description: This file stores settings for Dart & Flutter DevTools. 2 | documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states 3 | extensions: 4 | -------------------------------------------------------------------------------- /example/.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 | .pub-cache/ 31 | .pub/ 32 | /build/ 33 | 34 | # Symbolication related 35 | app.*.symbols 36 | 37 | # Obfuscation related 38 | app.*.map.json 39 | 40 | # Android Studio will place build artifacts here 41 | /android/app/debug 42 | /android/app/profile 43 | /android/app/release 44 | -------------------------------------------------------------------------------- /example/.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: "b0850beeb25f6d5b10426284f506557f66181b36" 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: b0850beeb25f6d5b10426284f506557f66181b36 17 | base_revision: b0850beeb25f6d5b10426284f506557f66181b36 18 | - platform: windows 19 | create_revision: b0850beeb25f6d5b10426284f506557f66181b36 20 | base_revision: b0850beeb25f6d5b10426284f506557f66181b36 21 | 22 | # User provided section 23 | 24 | # List of Local paths (relative to this file) that should be 25 | # ignored by the migrate tool. 26 | # 27 | # Files that are not part of the templates will be ignored by default. 28 | unmanaged_files: 29 | - 'lib/main.dart' 30 | - 'ios/Runner.xcodeproj/project.pbxproj' 31 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # example 2 | 3 | A new Flutter project. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) 13 | 14 | For help getting started with Flutter development, view the 15 | [online documentation](https://docs.flutter.dev/), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/devtools_options.yaml: -------------------------------------------------------------------------------- 1 | description: This file stores settings for Dart & Flutter DevTools. 2 | documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states 3 | extensions: 4 | - flutter_getit: true -------------------------------------------------------------------------------- /example/lib/application/bindings/application_bindings.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/application/deep_link/my_deep_link.dart'; 2 | import 'package:flutter_getit/flutter_getit.dart'; 3 | import 'package:shared_preferences/shared_preferences.dart'; 4 | 5 | class MyApplicationBindings extends ApplicationBindings { 6 | @override 7 | List> bindings() => [ 8 | Bind.singletonAsync( 9 | (i) async => SharedPreferences.getInstance(), 10 | ), 11 | Bind.singletonAsync( 12 | (i) async => Future.delayed( 13 | const Duration(seconds: 1), 14 | () => AsyncTest(), 15 | ), 16 | ), 17 | Bind.singleton( 18 | (i) => MyDeepLink(i()), 19 | keepAlive: true, 20 | dependsOn: [ 21 | SharedPreferences, 22 | AsyncTest, 23 | ], 24 | ), 25 | ]; 26 | } 27 | 28 | class AsyncTest {} 29 | -------------------------------------------------------------------------------- /example/lib/application/bindings/navigator_bindings.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/src/home/home_controller.dart'; 2 | import 'package:example/src/nav_bar/my_nav_bar_helper_controller.dart'; 3 | import 'package:flutter_getit/flutter_getit.dart'; 4 | 5 | class MyNavigatorBindings extends ApplicationBindings { 6 | @override 7 | List> bindings() => [ 8 | Bind.singleton( 9 | (i) => HomeController(), 10 | keepAlive: true, 11 | tag: 'HomeController', 12 | ), 13 | Bind.lazySingleton( 14 | (i) => MyNavBarHelperController(), 15 | ), 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /example/lib/application/debug/my_debug_log.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_getit/flutter_getit.dart'; 2 | 3 | class MyDebugLog extends FGetItLoggerConfig { 4 | MyDebugLog() 5 | : super( 6 | colored: false, 7 | enable: false, 8 | gettingInstance: false, 9 | gettingAsyncInstance: false, 10 | allReady: false, 11 | disposeInstance: false, 12 | registerInstance: false, 13 | disposingInstance: false, 14 | enterAndExitModule: false, 15 | enterAndExitWidget: false, 16 | ); 17 | } 18 | -------------------------------------------------------------------------------- /example/lib/application/deep_link/my_deep_link.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_getit/flutter_getit.dart'; 2 | import 'package:shared_preferences/shared_preferences.dart'; 3 | 4 | class MyDeepLink with FlutterGetItMixin { 5 | final SharedPreferences sharedPreferences; 6 | 7 | MyDeepLink(this.sharedPreferences); 8 | @override 9 | void onDispose() {} 10 | 11 | @override 12 | void onInit() {} 13 | } 14 | -------------------------------------------------------------------------------- /example/lib/application/middleware/auth_middleware.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_getit/flutter_getit.dart'; 3 | 4 | class AuthMiddleware extends FlutterGetItAsyncMiddleware { 5 | @override 6 | Future execute(RouteSettings? route) async { 7 | await Future.delayed(const Duration(seconds: 1)); 8 | return route?.name == '/Landing/Presentation7AAA' 9 | ? MiddlewareResult.failure 10 | : MiddlewareResult.next; 11 | } 12 | 13 | @override 14 | Widget get onExecute => const Scaffold( 15 | body: Center( 16 | child: Icon( 17 | Icons.lock, 18 | color: Colors.red, 19 | size: 100, 20 | ), 21 | ), 22 | ); 23 | } 24 | -------------------------------------------------------------------------------- /example/lib/application/middleware/module_middleware.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_getit/flutter_getit.dart'; 3 | 4 | class ModuleMiddleware extends FlutterGetItSyncMiddleware { 5 | @override 6 | MiddlewareResult execute(RouteSettings? route) { 7 | // log("VINDO DO MODULO ===== ${route?.name ?? 'SEM ROTA'}"); 8 | return MiddlewareResult.next; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /example/lib/application/middleware/page_middleware.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_getit/flutter_getit.dart'; 5 | 6 | class PageMiddleware extends FlutterGetItAsyncMiddleware { 7 | @override 8 | Future execute(RouteSettings? route) async { 9 | // log("Vindo da Page! ===== ${route?.name ?? 'SEM ROTA'}"); 10 | return MiddlewareResult.next; 11 | } 12 | 13 | @override 14 | FutureOr onFail(RouteSettings? route, 15 | FlutterGetItMiddlewareContext fContext, MiddlewareResult result, 16 | {dynamic error}) async { 17 | super.onFail(route, fContext, result, error: error); 18 | await fContext.bottomSheet( 19 | builder: (_) => Scaffold(body: Center(child: Text(error.toString())))); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /example/lib/application/middleware/print_middleware.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_getit/flutter_getit.dart'; 3 | 4 | class PrintMiddleware extends FlutterGetItSyncMiddleware { 5 | @override 6 | MiddlewareResult execute(RouteSettings? route) { 7 | // log("DE APPLICATION! ===== ${route?.name ?? 'SEM ROTA'}"); 8 | 9 | if (executeWhen(route)) { 10 | return MiddlewareResult.next; 11 | } 12 | return MiddlewareResult.next; 13 | } 14 | 15 | @override 16 | bool executeWhen(RouteSettings? route) { 17 | if (route?.name == null) { 18 | return true; 19 | } else { 20 | if (route?.name?.contains('Register') ?? false) { 21 | return false; 22 | } 23 | return true; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /example/lib/application/session/model/user_model.dart: -------------------------------------------------------------------------------- 1 | class UserModel { 2 | final String name; 3 | 4 | UserModel({required this.name}); 5 | } 6 | -------------------------------------------------------------------------------- /example/lib/application/session/user_session.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter_getit/flutter_getit.dart'; 4 | 5 | import 'model/user_model.dart'; 6 | 7 | final class UserSession with FlutterGetItMixin { 8 | static final _me = StreamController.broadcast(); 9 | static Stream get me => _me.stream; 10 | late final Stream periodicReset; 11 | 12 | static void updateMe(UserModel? user) { 13 | _me.add(user); 14 | } 15 | 16 | @override 17 | void onDispose() { 18 | _me.close(); 19 | } 20 | 21 | @override 22 | void onInit() {} 23 | } 24 | -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/application/bindings/application_bindings.dart'; 2 | import 'package:example/application/middleware/print_middleware.dart'; 3 | import 'package:example/src/auth/repository/auth_repository.dart'; 4 | import 'package:example/src/auth/view/active_account/active_account_controller.dart'; 5 | import 'package:example/src/auth/view/active_account/active_account_page.dart'; 6 | import 'package:example/src/auth/view/active_account/validate_email_controller.dart'; 7 | import 'package:example/src/auth/view/login/login_controller.dart'; 8 | import 'package:example/src/auth/view/login/login_page.dart'; 9 | import 'package:example/src/auth/view/register/register_controller.dart'; 10 | import 'package:example/src/auth/view/register/register_page.dart'; 11 | import 'package:example/src/landing/landing_module.dart'; 12 | import 'package:example/src/loader/load_dependencies.dart'; 13 | import 'package:example/src/nav_bar/nav_bar_module.dart'; 14 | import 'package:example/src/products/products_module.dart'; 15 | import 'package:example/src/route_outlet_nav_bar/my_nav_bar.dart'; 16 | import 'package:example/src/splash/splash_page.dart'; 17 | import 'package:flutter/material.dart'; 18 | import 'package:flutter_getit/flutter_getit.dart'; 19 | 20 | void main() { 21 | runApp(const MyApp()); 22 | } 23 | 24 | class MyApp extends StatelessWidget { 25 | const MyApp({super.key}); 26 | 27 | @override 28 | Widget build(BuildContext context) { 29 | return FlutterGetIt( 30 | bindings: MyApplicationBindings(), 31 | middlewares: [ 32 | PrintMiddleware(), 33 | ], 34 | modules: [ 35 | LandingModule(), 36 | NavBarModule(), 37 | ProductsModule(), 38 | ], 39 | modulesRouter: [ 40 | FlutterGetItModuleRouter( 41 | name: '/outlet', 42 | pages: [ 43 | FlutterGetItPageRouter( 44 | name: '/', 45 | builderAsync: (context, isReady, loader) => switch (isReady) { 46 | true => const RouteOutletMyNavBar(), 47 | false => loader ?? const WidgetLoadDependencies(), 48 | }, 49 | bindings: [], 50 | ), 51 | ], 52 | ), 53 | FlutterGetItModuleRouter( 54 | name: '/Auth', 55 | onInit: (i) => debugPrint('hi by /Auth'), 56 | onDispose: (i) => debugPrint('bye by /Auth'), 57 | bindings: [ 58 | Bind.lazySingleton( 59 | (i) => AuthRepository(), 60 | ), 61 | ], 62 | pages: [ 63 | FlutterGetItPageRouter( 64 | name: '/Login', 65 | builderAsync: (context, isReady, loader) => switch (isReady) { 66 | true => LoginPage( 67 | controller: context.get(), 68 | ), 69 | false => loader ?? const WidgetLoadDependencies(), 70 | }, 71 | bindings: [ 72 | Bind.lazySingleton( 73 | (i) => LoginController( 74 | name: 'Login', 75 | authRepository: i(), 76 | ), 77 | ), 78 | ], 79 | ), 80 | FlutterGetItModuleRouter( 81 | name: '/Register', 82 | bindings: [ 83 | Bind.lazySingleton( 84 | (i) => RegisterController(), 85 | ), 86 | ], 87 | onInit: (i) => debugPrint('hi by /Register'), 88 | onDispose: (i) => debugPrint('bye by /Register'), 89 | pages: [ 90 | FlutterGetItPageRouter( 91 | name: '/Page', 92 | builderAsync: (context, isReady, loader) => switch (isReady) { 93 | true => RegisterPage( 94 | controller: context.get(), 95 | ), 96 | false => loader ?? const WidgetLoadDependencies(), 97 | }, 98 | bindings: [ 99 | Bind.lazySingleton( 100 | (i) => RegisterController(), 101 | ), 102 | ], 103 | ), 104 | FlutterGetItModuleRouter( 105 | name: '/ActiveAccount', 106 | bindings: [ 107 | Bind.lazySingleton( 108 | (i) => ( 109 | controller: ActiveAccountController(name: 'MyName'), 110 | validateEmailController: 111 | ValidateEmailController(email: 'fgetit@injector'), 112 | ), 113 | ), 114 | ], 115 | pages: [ 116 | FlutterGetItPageRouter( 117 | name: '/Page', 118 | builderAsync: (context, isReady, loader) => 119 | switch (isReady) { 120 | true => const ActiveAccountPage(), 121 | false => loader ?? const WidgetLoadDependencies(), 122 | }, 123 | bindings: [], 124 | ), 125 | ], 126 | ), 127 | ], 128 | ), 129 | ], 130 | ) 131 | ], 132 | // loggerConfig: MyDebugLog(), 133 | pagesRouter: [ 134 | FlutterGetItPageRouter( 135 | name: '/splash', builder: (context) => const SplashPage()), 136 | ], 137 | builder: (context, routes, isReady) { 138 | return MaterialApp( 139 | title: 'Flutter Demo', 140 | theme: ThemeData( 141 | colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), 142 | useMaterial3: true, 143 | ), 144 | initialRoute: '/splash', 145 | routes: routes, 146 | builder: (context, child) => switch (isReady) { 147 | true => child ?? const SizedBox.shrink(), 148 | false => const WidgetLoadDependencies(), 149 | }, 150 | ); 151 | }, 152 | ); 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /example/lib/src/auth/repository/auth_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_getit/flutter_getit.dart'; 2 | 3 | class AuthRepository with FlutterGetItMixin { 4 | @override 5 | void onDispose() {} 6 | 7 | @override 8 | void onInit() {} 9 | } 10 | -------------------------------------------------------------------------------- /example/lib/src/auth/view/active_account/active_account_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_getit/flutter_getit.dart'; 2 | 3 | class ActiveAccountController with FlutterGetItMixin { 4 | final String name; 5 | 6 | ActiveAccountController({required this.name}); 7 | @override 8 | void onDispose() {} 9 | 10 | @override 11 | void onInit() {} 12 | } 13 | -------------------------------------------------------------------------------- /example/lib/src/auth/view/active_account/active_account_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/src/auth/view/active_account/active_account_controller.dart'; 2 | import 'package:example/src/auth/view/active_account/validate_email_controller.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_getit/flutter_getit.dart'; 5 | 6 | typedef ActiveAccountPageDependencies = ({ 7 | ActiveAccountController controller, 8 | ValidateEmailController validateEmailController 9 | }); 10 | 11 | class ActiveAccountPage 12 | extends FlutterGetItView { 13 | const ActiveAccountPage({super.key}); 14 | 15 | @override 16 | Widget build(BuildContext context) { 17 | return Scaffold( 18 | appBar: AppBar( 19 | title: Text(fGetIt.controller.name), 20 | ), 21 | body: Center( 22 | child: Column( 23 | children: [ 24 | ElevatedButton( 25 | onPressed: () { 26 | Navigator.of(context).popUntil( 27 | (route) => route.settings.name == '/Home/Page', 28 | ); 29 | }, 30 | child: const Text('PopUntil - Home - Page'), 31 | ), 32 | const SizedBox( 33 | height: 16, 34 | ), 35 | ElevatedButton( 36 | onPressed: () { 37 | Navigator.of(context) 38 | .pushReplacementNamed('/Auth/Register/Page'); 39 | }, 40 | child: const Text('PushReplacementNamed - Register - Page'), 41 | ), 42 | const SizedBox( 43 | height: 16, 44 | ), 45 | ElevatedButton( 46 | onPressed: () { 47 | Navigator.of(context).pushNamed('/Auth/Register/Page'); 48 | }, 49 | child: const Text('PushNamed - Register - Page'), 50 | ), 51 | ], 52 | ), 53 | ), 54 | ); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /example/lib/src/auth/view/active_account/validate_email_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_getit/flutter_getit.dart'; 2 | 3 | class ValidateEmailController with FlutterGetItMixin { 4 | final String email; 5 | 6 | ValidateEmailController({required this.email}); 7 | @override 8 | void onDispose() {} 9 | 10 | @override 11 | void onInit() {} 12 | } 13 | -------------------------------------------------------------------------------- /example/lib/src/auth/view/login/login_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/src/auth/repository/auth_repository.dart'; 2 | import 'package:flutter_getit/flutter_getit.dart'; 3 | 4 | class LoginController with FlutterGetItMixin { 5 | final String name; 6 | final AuthRepository authRepository; 7 | LoginController({required this.name, required this.authRepository}); 8 | @override 9 | void onDispose() {} 10 | 11 | @override 12 | void onInit() {} 13 | } 14 | -------------------------------------------------------------------------------- /example/lib/src/auth/view/login/login_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/application/session/model/user_model.dart'; 2 | import 'package:example/application/session/user_session.dart'; 3 | import 'package:example/src/auth/view/login/login_controller.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | class LoginPage extends StatelessWidget { 7 | final LoginController controller; 8 | const LoginPage({super.key, required this.controller}); 9 | 10 | @override 11 | Widget build(BuildContext context) { 12 | return Scaffold( 13 | floatingActionButton: FloatingActionButton( 14 | onPressed: () { 15 | UserSession.updateMe( 16 | UserModel( 17 | name: 'Leo ${DateTime.now().second}', 18 | ), 19 | ); 20 | }, 21 | ), 22 | appBar: AppBar( 23 | title: Text(controller.name), 24 | ), 25 | body: Center( 26 | child: Column( 27 | children: [ 28 | ElevatedButton( 29 | onPressed: () { 30 | Navigator.of(context).pushNamed('/Auth/Register/Page'); 31 | }, 32 | child: const Text('PushNamed - Register - Page'), 33 | ), 34 | const SizedBox( 35 | height: 16, 36 | ), 37 | ElevatedButton( 38 | onPressed: () { 39 | Navigator.of(context) 40 | .pushReplacementNamed('/Auth/Register/Page'); 41 | }, 42 | child: const Text('PushReplacementNamed - Register - Page'), 43 | ), 44 | const SizedBox( 45 | height: 16, 46 | ), 47 | ElevatedButton( 48 | onPressed: () { 49 | Navigator.of(context) 50 | .pushReplacementNamed('/Auth/Register/ActiveAccount/Page'); 51 | }, 52 | child: const Text('PushReplacementNamed - ActiveAccount'), 53 | ), 54 | ], 55 | ), 56 | ), 57 | ); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /example/lib/src/auth/view/register/register_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_getit/flutter_getit.dart'; 2 | 3 | class RegisterController with FlutterGetItMixin { 4 | @override 5 | void onDispose() {} 6 | 7 | @override 8 | void onInit() {} 9 | } 10 | -------------------------------------------------------------------------------- /example/lib/src/auth/view/register/register_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/src/auth/view/register/register_controller.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | class RegisterPage extends StatelessWidget { 5 | final RegisterController controller; 6 | const RegisterPage({super.key, required this.controller}); 7 | 8 | @override 9 | Widget build(BuildContext context) { 10 | return Scaffold( 11 | appBar: AppBar( 12 | title: const Text('Register Page'), 13 | ), 14 | body: Center( 15 | child: Column( 16 | children: [ 17 | ElevatedButton( 18 | onPressed: () { 19 | Navigator.of(context) 20 | .pushReplacementNamed('/Auth/Register/ActiveAccount/Page'); 21 | }, 22 | child: const Text( 23 | 'PushReplacementNamed - ActiveAccount - Page', 24 | ), 25 | ), 26 | const SizedBox( 27 | height: 16, 28 | ), 29 | ElevatedButton( 30 | onPressed: () { 31 | Navigator.of(context).pushNamed('/Auth/Register/Page'); 32 | }, 33 | child: const Text('PushNamed - Register - Page'), 34 | ), 35 | ], 36 | ), 37 | ), 38 | ); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /example/lib/src/detail/detail_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_getit/flutter_getit.dart'; 2 | 3 | class DetailController with FlutterGetItMixin { 4 | @override 5 | void onDispose() {} 6 | 7 | @override 8 | void onInit() {} 9 | } 10 | -------------------------------------------------------------------------------- /example/lib/src/detail/detail_page.dart: -------------------------------------------------------------------------------- 1 | import 'dart:developer'; 2 | 3 | import 'package:example/src/detail/detail_controller.dart'; 4 | import 'package:example/src/home/home_controller.dart'; 5 | import 'package:flutter/material.dart'; 6 | import 'package:flutter_getit/flutter_getit.dart'; 7 | 8 | import 'widget/form_item.dart'; 9 | 10 | class DetailPage extends StatelessWidget { 11 | final DetailController controller; 12 | 13 | const DetailPage({super.key, required this.controller}); 14 | 15 | @override 16 | Widget build(BuildContext context) { 17 | final home1 = context.get(tag: 'HomeController2'); 18 | log('$home1'); 19 | return Scaffold( 20 | appBar: AppBar( 21 | title: const Text('Home detail'), 22 | ), 23 | body: Center( 24 | child: Column( 25 | children: [ 26 | const FormItem( 27 | id: '', 28 | ), 29 | const Divider(), 30 | const FormItem( 31 | id: 'FormItem2', 32 | ), 33 | const Divider(), 34 | const FormItem( 35 | id: 'FormItem3', 36 | ), 37 | const Divider(), 38 | ElevatedButton( 39 | onPressed: () { 40 | Navigator.of(context) 41 | .pushReplacementNamed('/Detail/Factories/Two'); 42 | }, 43 | child: const Text('Detail Two - pushReplacementNamed'), 44 | ), 45 | const Divider(), 46 | ElevatedButton( 47 | onPressed: () { 48 | Navigator.of(context).pushNamed('/Detail/Factories/Two'); 49 | }, 50 | child: const Text('Detail Two'), 51 | ), 52 | const Divider(), 53 | ElevatedButton( 54 | onPressed: () { 55 | Navigator.of(context) 56 | .pushNamed('/Detail/Factories/One/Internal/Page'); 57 | }, 58 | child: const Text('Detail Internal'), 59 | ), 60 | ], 61 | ), 62 | ), 63 | ); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /example/lib/src/detail/detail_repository.dart: -------------------------------------------------------------------------------- 1 | class DetailRepository {} 2 | -------------------------------------------------------------------------------- /example/lib/src/detail/detail_super_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_getit/flutter_getit.dart'; 2 | 3 | class DetailSuperController with FlutterGetItMixin { 4 | @override 5 | void onDispose() {} 6 | 7 | @override 8 | void onInit() {} 9 | } 10 | -------------------------------------------------------------------------------- /example/lib/src/detail/detail_super_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/src/detail/detail_super_controller.dart'; 2 | import 'package:example/src/detail/widget/form_item.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | class DetailSuperPage extends StatelessWidget { 6 | final DetailSuperController controller; 7 | const DetailSuperPage({super.key, required this.controller}); 8 | 9 | @override 10 | Widget build(BuildContext context) { 11 | return Scaffold( 12 | appBar: AppBar( 13 | title: const Text('Home detail Super'), 14 | ), 15 | body: const Center( 16 | child: Column( 17 | children: [ 18 | FormItem( 19 | id: 'FormItem4', 20 | ), 21 | Divider(), 22 | FormItem( 23 | id: 'FormItem5', 24 | ), 25 | Divider(), 26 | FormItem( 27 | id: 'FormItem6', 28 | ), 29 | ], 30 | )), 31 | ); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /example/lib/src/detail/internal/detail_internal_child.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/src/detail/internal/detail_internal_repository.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | class DetailInternalChild extends StatelessWidget { 5 | final DetailInternalRepository repository; 6 | const DetailInternalChild({super.key, required this.repository}); 7 | 8 | @override 9 | Widget build(BuildContext context) { 10 | return Scaffold( 11 | appBar: AppBar( 12 | title: const Text('DetailInternalChild'), 13 | ), 14 | body: Center( 15 | child: ElevatedButton( 16 | onPressed: () { 17 | Navigator.of(context) 18 | .pushReplacementNamed('/Detail/Factories/One/Internal/Page'); 19 | }, 20 | child: const Text('Detail Internal - pushReplacementNamed'), 21 | )), 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /example/lib/src/detail/internal/detail_internal_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/src/detail/internal/detail_internal_repository.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | class DetailInternalPage extends StatelessWidget { 5 | final DetailInternalRepository repository; 6 | const DetailInternalPage({super.key, required this.repository}); 7 | 8 | @override 9 | Widget build(BuildContext context) { 10 | return Scaffold( 11 | appBar: AppBar( 12 | title: const Text('DetailInternalPage'), 13 | ), 14 | body: Center( 15 | child: ElevatedButton( 16 | onPressed: () { 17 | Navigator.of(context) 18 | .pushNamed('/Detail/Factories/One/Internal/Page/Child'); 19 | }, 20 | child: const Text('Detail Internal Child'), 21 | )), 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /example/lib/src/detail/internal/detail_internal_repository.dart: -------------------------------------------------------------------------------- 1 | class DetailInternalRepository {} 2 | -------------------------------------------------------------------------------- /example/lib/src/detail/widget/form_item.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/src/detail/widget/form_item_controller.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_getit/flutter_getit.dart'; 4 | 5 | class FormItem extends StatelessWidget { 6 | final String id; 7 | const FormItem({super.key, required this.id}); 8 | 9 | @override 10 | Widget build(BuildContext context) { 11 | return FlutterGetItWidget( 12 | name: id + hashCode.toString(), 13 | binds: const [], 14 | onDispose: () { 15 | Injector.unRegisterFactoryByTag(id); 16 | }, 17 | builder: (context) { 18 | final fGetIt = context.get(factoryTag: id); 19 | return Column( 20 | children: [ 21 | Text(fGetIt.name), 22 | const SizedBox(height: 10), 23 | TextField( 24 | decoration: InputDecoration( 25 | labelText: fGetIt.name, 26 | border: const OutlineInputBorder(), 27 | ), 28 | ), 29 | ], 30 | ); 31 | }, 32 | ); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /example/lib/src/detail/widget/form_item_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_getit/flutter_getit.dart'; 2 | 3 | class FormItemController with FlutterGetItMixin { 4 | final String name; 5 | 6 | FormItemController({ 7 | required this.name, 8 | }); 9 | @override 10 | void onDispose() {} 11 | 12 | @override 13 | void onInit() {} 14 | } 15 | -------------------------------------------------------------------------------- /example/lib/src/home/home_controller.dart: -------------------------------------------------------------------------------- 1 | import 'dart:developer'; 2 | 3 | import 'package:flutter_getit/flutter_getit.dart'; 4 | import 'package:shared_preferences/shared_preferences.dart'; 5 | 6 | class HomeController with FlutterGetItMixin { 7 | HomeController(); 8 | 9 | @override 10 | void onDispose() {} 11 | 12 | @override 13 | void onInit() { 14 | final sp = Injector.get(); 15 | log(sp.toString()); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /example/lib/src/home/home_module.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/src/home/home_controller.dart'; 2 | import 'package:example/src/home/home_page.dart'; 3 | import 'package:example/src/loader/load_dependencies.dart'; 4 | import 'package:flutter_getit/flutter_getit.dart'; 5 | 6 | class HomeModule extends FlutterGetItModule { 7 | @override 8 | String get moduleRouteName => '/Home'; 9 | @override 10 | List> get bindings => []; 11 | 12 | @override 13 | List get pages => [ 14 | FlutterGetItPageRouter( 15 | name: '/Page', 16 | builderAsync: (context, isReady, loader) => switch (isReady) { 17 | true => HomePage(), 18 | false => loader ?? const WidgetLoadDependencies(), 19 | }, 20 | bindings: [ 21 | Bind.lazySingleton( 22 | (i) => HomeController(), 23 | ), 24 | ], 25 | ), 26 | ]; 27 | 28 | @override 29 | void onDispose(Injector i) {} 30 | 31 | @override 32 | void onInit(Injector i) {} 33 | } 34 | -------------------------------------------------------------------------------- /example/lib/src/home/home_page.dart: -------------------------------------------------------------------------------- 1 | import 'dart:developer'; 2 | 3 | import 'package:example/application/session/model/user_model.dart'; 4 | import 'package:example/application/session/user_session.dart'; 5 | import 'package:example/src/home/home_controller.dart'; 6 | import 'package:example/src/param_example/param_page.dart'; 7 | import 'package:flutter/material.dart'; 8 | import 'package:flutter_getit/flutter_getit.dart'; 9 | 10 | class HomePage extends StatelessWidget { 11 | HomePage({super.key}); 12 | 13 | final _home1 = Injector.get(tag: 'HomeController'); 14 | 15 | @override 16 | Widget build(BuildContext context) { 17 | log(_home1.toString()); 18 | log(context.any().toString()); 19 | 20 | return Scaffold( 21 | floatingActionButton: FloatingActionButton( 22 | onPressed: () { 23 | showModalBottomSheet( 24 | context: context, 25 | builder: (context) => FlutterGetItWidget( 26 | name: 'Test', 27 | builder: (context) { 28 | return const Center( 29 | child: Text('Test'), 30 | ); 31 | }, 32 | ), 33 | ); 34 | }, 35 | ), 36 | appBar: AppBar( 37 | title: const Text('HomePage'), 38 | ), 39 | body: Center( 40 | child: ListView( 41 | children: [ 42 | StreamBuilder( 43 | stream: UserSession.me, 44 | builder: (context, user) { 45 | return Text(user.data?.name ?? 'No User'); 46 | }, 47 | ), 48 | const Divider(), 49 | ElevatedButton( 50 | onPressed: () async { 51 | Navigator.of(context).pushNamed('/Auth/Login'); 52 | }, 53 | child: const Text( 54 | 'PushNamed - Login', 55 | ), 56 | ), 57 | const SizedBox( 58 | height: 16, 59 | ), 60 | ElevatedButton( 61 | onPressed: () async { 62 | Navigator.of(context).pushNamed('/Auth/Register/Page'); 63 | }, 64 | child: const Text( 65 | 'PushNamed - Register - Page', 66 | ), 67 | ), 68 | const SizedBox( 69 | height: 16, 70 | ), 71 | ElevatedButton( 72 | onPressed: () async { 73 | Navigator.of(context) 74 | .pushNamed('/Auth/Register/ActiveAccount/Page'); 75 | }, 76 | child: const Text( 77 | 'PushNamed - ActiveAccount - Page', 78 | ), 79 | ), 80 | const SizedBox( 81 | height: 16, 82 | ), 83 | ElevatedButton( 84 | onPressed: () async { 85 | Navigator.of(context).pushNamed('/Auth/Register/ActiveAccount'); 86 | }, 87 | child: const Text( 88 | 'PushNamed - Wrong page', 89 | ), 90 | ), 91 | const Divider(), 92 | ElevatedButton( 93 | onPressed: () async { 94 | Navigator.of(context).pushNamed('/Random/Page'); 95 | }, 96 | child: const Text( 97 | 'PushNamed - RandomPage', 98 | ), 99 | ), 100 | const Divider(), 101 | ElevatedButton( 102 | onPressed: () async { 103 | Navigator.of(context).pushNamed('/Detail/Factories/One'); 104 | }, 105 | child: const Text( 106 | 'Detail One Page', 107 | ), 108 | ), 109 | const SizedBox( 110 | height: 16, 111 | ), 112 | ElevatedButton( 113 | onPressed: () async { 114 | Navigator.of(context) 115 | .pushNamed('/Detail/Factories/One/Internal/Page'); 116 | }, 117 | child: const Text( 118 | 'Detail One Internal', 119 | ), 120 | ), 121 | const SizedBox( 122 | height: 16, 123 | ), 124 | ElevatedButton( 125 | onPressed: () async { 126 | Navigator.of(context) 127 | .pushNamed('/Detail/Factories/One/Internal/Page/Child'); 128 | }, 129 | child: const Text( 130 | 'Detail One Internal Child', 131 | ), 132 | ), 133 | const SizedBox( 134 | height: 16, 135 | ), 136 | ElevatedButton( 137 | onPressed: () async { 138 | Navigator.of(context).pushNamed('/Detail/Factories/Two'); 139 | }, 140 | child: const Text( 141 | 'Detail Two Page', 142 | ), 143 | ), 144 | const Divider(), 145 | const SizedBox( 146 | height: 16, 147 | ), 148 | ElevatedButton( 149 | onPressed: () async { 150 | ParamPageDto dto = ( 151 | name: 'FlutterGetIt', 152 | date: DateTime(2021), 153 | ); 154 | 155 | Navigator.of(context).pushNamed( 156 | '/Params/Page', 157 | arguments: dto, 158 | ); 159 | }, 160 | child: const Text( 161 | 'Page with Params', 162 | ), 163 | ), 164 | ], 165 | ), 166 | ), 167 | ); 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /example/lib/src/landing/initialize_bloc.dart: -------------------------------------------------------------------------------- 1 | class InitializeBloc {} 2 | -------------------------------------------------------------------------------- /example/lib/src/landing/initialize_controller.dart: -------------------------------------------------------------------------------- 1 | import 'dart:developer'; 2 | 3 | import 'package:example/application/bindings/application_bindings.dart'; 4 | import 'package:flutter_getit/flutter_getit.dart'; 5 | import 'package:shared_preferences/shared_preferences.dart'; 6 | 7 | import 'initialize_bloc.dart'; 8 | 9 | class InitializeController implements InitializeBloc, FlutterGetItMixin { 10 | InitializeController(); 11 | @override 12 | void onDispose() {} 13 | 14 | @override 15 | void onInit() async { 16 | final spByAsync = Injector.get(); 17 | final myTest = await Injector.getAsync(); 18 | log(spByAsync.toString()); 19 | log(myTest.toString()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /example/lib/src/landing/initialize_page.dart: -------------------------------------------------------------------------------- 1 | import 'dart:developer'; 2 | 3 | import 'package:example/application/deep_link/my_deep_link.dart'; 4 | import 'package:example/src/landing/initialize_controller.dart'; 5 | import 'package:flutter/material.dart'; 6 | import 'package:flutter_getit/flutter_getit.dart'; 7 | 8 | class InitializePage extends StatelessWidget { 9 | const InitializePage({super.key}); 10 | 11 | @override 12 | Widget build(BuildContext context) { 13 | final controller = Injector.get(); 14 | final deepLink = Injector.get(); 15 | log(controller.toString()); 16 | log(deepLink.toString()); 17 | return Scaffold( 18 | appBar: AppBar( 19 | title: const Text('Initialize page'), 20 | ), 21 | body: Center( 22 | child: Column( 23 | children: [ 24 | const FlutterLogo(), 25 | ElevatedButton( 26 | onPressed: () { 27 | Navigator.of(context).pushNamedAndRemoveUntil( 28 | '/Landing/Presentation', (route) => false); 29 | }, 30 | child: const Text('Ir a Presentation'), 31 | ), 32 | ], 33 | ), 34 | ), 35 | ); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /example/lib/src/landing/landing_module.dart: -------------------------------------------------------------------------------- 1 | import 'dart:developer'; 2 | 3 | import 'package:example/application/middleware/auth_middleware.dart'; 4 | import 'package:example/src/landing/initialize_controller.dart'; 5 | import 'package:example/src/landing/initialize_page.dart'; 6 | import 'package:example/src/landing/presentation_page.dart'; 7 | import 'package:example/src/loader/load_dependencies.dart'; 8 | import 'package:flutter_getit/flutter_getit.dart'; 9 | 10 | class LandingModule extends FlutterGetItModule { 11 | @override 12 | String get moduleRouteName => '/Landing'; 13 | 14 | @override 15 | List> get bindings => []; 16 | 17 | @override 18 | List get pages => [ 19 | FlutterGetItPageRouter( 20 | name: '/Initialize', 21 | builderAsync: (context, isReady, loader) => switch (isReady) { 22 | true => const InitializePage(), 23 | false => loader ?? const WidgetLoadDependencies(), 24 | }, 25 | bindings: [ 26 | Bind.lazySingleton( 27 | (i) => InitializeController(), 28 | ), 29 | ], 30 | ), 31 | FlutterGetItPageRouter( 32 | name: '/Presentation', 33 | builderAsync: (context, isReady, loader) => switch (isReady) { 34 | true => const PresentationPage(), 35 | false => loader ?? const WidgetLoadDependencies(), 36 | }, 37 | middlewares: [ 38 | AuthMiddleware(), 39 | ], 40 | bindings: [ 41 | Bind.singletonAsync( 42 | (i) => Future.delayed( 43 | const Duration(seconds: 1), 44 | () => PresentationRepository(), 45 | ), 46 | keepAlive: true, 47 | ), 48 | Bind.singleton( 49 | (i) => PresentationController( 50 | repository: i(), 51 | ), 52 | dependsOn: [PresentationRepository], 53 | ), 54 | Bind.lazySingletonAsync( 55 | (i) => Future.delayed( 56 | const Duration(seconds: 1), 57 | () => PresentationDatabase(), 58 | ), 59 | ), 60 | ], 61 | ), 62 | ]; 63 | 64 | @override 65 | void onDispose(Injector i) {} 66 | 67 | @override 68 | void onInit(Injector i) {} 69 | } 70 | 71 | class PresentationController with FlutterGetItMixin { 72 | final PresentationRepository repository; 73 | PresentationController({required this.repository}); 74 | 75 | @override 76 | void onDispose() {} 77 | 78 | @override 79 | void onInit() {} 80 | } 81 | 82 | class PresentationRepository {} 83 | 84 | class PresentationDatabase with FlutterGetItMixin { 85 | @override 86 | void onDispose() { 87 | log('Dispose PresentationDatabase'); 88 | } 89 | 90 | @override 91 | void onInit() { 92 | log('Init PresentationDatabase'); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /example/lib/src/landing/presentation_page.dart: -------------------------------------------------------------------------------- 1 | import 'dart:developer'; 2 | 3 | import 'package:example/src/landing/landing_module.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_getit/flutter_getit.dart'; 6 | 7 | class PresentationPage extends StatelessWidget { 8 | const PresentationPage({super.key}); 9 | 10 | @override 11 | Widget build(BuildContext context) { 12 | final controller = Injector.get(); 13 | log(controller.toString()); 14 | return Scaffold( 15 | appBar: AppBar( 16 | title: const Text('Presentation'), 17 | ), 18 | body: Center( 19 | child: Column( 20 | children: [ 21 | ElevatedButton( 22 | onPressed: () { 23 | Navigator.of(context).pushNamedAndRemoveUntil( 24 | '/RootNavBar/Root', 25 | (route) => false, 26 | ); 27 | }, 28 | child: const Text('Ir a RootNav'), 29 | ), 30 | const SizedBox(height: 20), 31 | ElevatedButton( 32 | onPressed: () { 33 | Navigator.of(context).pushNamedAndRemoveUntil( 34 | '/outlet/', 35 | (route) => false, 36 | ); 37 | }, 38 | child: const Text('Ir a RouteOutlet'), 39 | ), 40 | ], 41 | ), 42 | ), 43 | ); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /example/lib/src/loader/load_dependencies.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class WidgetLoadDependencies extends StatelessWidget { 4 | const WidgetLoadDependencies({super.key}); 5 | 6 | @override 7 | Widget build(BuildContext context) { 8 | return const Scaffold( 9 | body: Center( 10 | child: Text('⏰ - Loading dependencies...'), 11 | ), 12 | ); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /example/lib/src/nav_bar/my_nav_bar_helper_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_getit/flutter_getit.dart'; 2 | 3 | class MyNavBarHelperController with FlutterGetItMixin { 4 | @override 5 | void onDispose() {} 6 | 7 | @override 8 | void onInit() {} 9 | } 10 | -------------------------------------------------------------------------------- /example/lib/src/nav_bar/nav_bar_module.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/src/loader/load_dependencies.dart'; 2 | import 'package:example/src/nav_bar/my_nav_bar.dart'; 3 | import 'package:flutter_getit/flutter_getit.dart'; 4 | 5 | class NavBarModule extends FlutterGetItModule { 6 | @override 7 | String get moduleRouteName => '/RootNavBar'; 8 | 9 | @override 10 | List> get bindings => []; 11 | 12 | @override 13 | List get pages => [ 14 | FlutterGetItPageRouter( 15 | name: '/Root', 16 | builderAsync: (context, isReady, loader) => switch (isReady) { 17 | true => const MyNavBar(), 18 | false => loader ?? const WidgetLoadDependencies(), 19 | }, 20 | ), 21 | ]; 22 | 23 | @override 24 | void onDispose(Injector i) {} 25 | 26 | @override 27 | void onInit(Injector i) {} 28 | } 29 | -------------------------------------------------------------------------------- /example/lib/src/param_example/param_example_module.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/src/param_example/param_page.dart'; 2 | import 'package:example/src/param_example/param_page_controller.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_getit/flutter_getit.dart'; 5 | 6 | class ParamExampleModule extends FlutterGetItModule { 7 | @override 8 | String get moduleRouteName => '/Params'; 9 | 10 | @override 11 | void onDispose(Injector i) {} 12 | 13 | @override 14 | void onInit(Injector i) {} 15 | 16 | @override 17 | List get pages => [ 18 | FlutterGetItPageRouter( 19 | name: '/Page', 20 | bindings: [ 21 | Bind.singleton( 22 | (i) => ParamPageController(), 23 | ), 24 | ], 25 | builderAsync: (context, isReady, loader) { 26 | return switch (isReady) { 27 | true => const ParamPage(), 28 | false => loader ?? const CircularProgressIndicator(), 29 | }; 30 | }, 31 | ), 32 | ]; 33 | } 34 | -------------------------------------------------------------------------------- /example/lib/src/param_example/param_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/src/param_example/param_page_controller.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_getit/flutter_getit.dart'; 4 | 5 | typedef ParamPageDto = ({String name, DateTime date}); 6 | 7 | class ParamPage extends StatelessWidget { 8 | const ParamPage({super.key}); 9 | 10 | @override 11 | Widget build(BuildContext context) { 12 | final controller = Injector.get(); 13 | 14 | return Scaffold( 15 | appBar: AppBar( 16 | title: ValueListenableBuilder( 17 | valueListenable: controller.dtoByInjector, 18 | builder: (context, dtoByInjector, child) { 19 | return Text( 20 | switch (dtoByInjector) { 21 | null => 'null', 22 | _ => dtoByInjector.name, 23 | }, 24 | ); 25 | }, 26 | ), 27 | ), 28 | floatingActionButton: FloatingActionButton(onPressed: () { 29 | controller.setDtoByInjector(); 30 | }), 31 | body: Center( 32 | child: Column( 33 | children: [ 34 | const Text('Dto by injector'), 35 | ValueListenableBuilder( 36 | valueListenable: controller.dtoByInjector, 37 | builder: (context, dtoByInjector, child) { 38 | return Text( 39 | switch (dtoByInjector) { 40 | null => 'null', 41 | _ => dtoByInjector.date.toIso8601String() 42 | }, 43 | ); 44 | }, 45 | ), 46 | ], 47 | ), 48 | ), 49 | ); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /example/lib/src/param_example/param_page_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/src/param_example/param_page.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_getit/flutter_getit.dart'; 4 | 5 | class ParamPageController with FlutterGetItMixin { 6 | final dtoByInjector = ValueNotifier(null); 7 | 8 | ParamPageController(); 9 | 10 | @override 11 | void onDispose() {} 12 | 13 | @override 14 | void onInit() { 15 | dtoByInjector.value = Injector.arguments; 16 | } 17 | 18 | void setDtoByInjector() {} 19 | } 20 | -------------------------------------------------------------------------------- /example/lib/src/products/model/product_model.dart: -------------------------------------------------------------------------------- 1 | class ProductModel { 2 | final String name; 3 | 4 | ProductModel({required this.name}); 5 | 6 | static List get getFake => [ 7 | ProductModel(name: 'Camiseta'), 8 | ProductModel(name: 'Short'), 9 | ProductModel(name: 'Boné'), 10 | ProductModel(name: 'Calça'), 11 | ProductModel(name: 'Armario'), 12 | ]; 13 | } 14 | -------------------------------------------------------------------------------- /example/lib/src/products/product_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_getit/flutter_getit.dart'; 2 | 3 | class ProductController with FlutterGetItMixin { 4 | @override 5 | void onDispose() {} 6 | 7 | @override 8 | void onInit() async {} 9 | } 10 | -------------------------------------------------------------------------------- /example/lib/src/products/products_detail.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/src/products/model/product_model.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | class ProductsDetail extends StatelessWidget { 5 | const ProductsDetail({super.key}); 6 | 7 | @override 8 | Widget build(BuildContext context) { 9 | final product = ModalRoute.of(context)?.settings.arguments as ProductModel; 10 | return Scaffold( 11 | appBar: AppBar( 12 | title: Text('Product ${product.name}'), 13 | ), 14 | body: const Center( 15 | child: FlutterLogo(), 16 | ), 17 | ); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /example/lib/src/products/products_module.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/src/loader/load_dependencies.dart'; 2 | import 'package:example/src/products/product_controller.dart'; 3 | import 'package:example/src/products/products_detail.dart'; 4 | import 'package:example/src/products/products_page.dart'; 5 | import 'package:flutter_getit/flutter_getit.dart'; 6 | 7 | class ProductsModule extends FlutterGetItModule { 8 | @override 9 | String get moduleRouteName => '/Products'; 10 | 11 | @override 12 | List> get bindings => []; 13 | 14 | @override 15 | List get pages => [ 16 | FlutterGetItModuleRouter( 17 | name: "/Page", 18 | pages: [ 19 | FlutterGetItPageRouter( 20 | name: '/', 21 | builderAsync: (context, isReady, loader) => switch (isReady) { 22 | true => ProductsPage( 23 | ctrl: context.get(), 24 | ), 25 | false => loader ?? const WidgetLoadDependencies(), 26 | }, 27 | bindings: [ 28 | Bind.lazySingleton( 29 | (i) => ProductController(), 30 | ) 31 | ], 32 | ), 33 | FlutterGetItPageRouter( 34 | name: '/Detail', 35 | builderAsync: (context, isReady, loader) => switch (isReady) { 36 | true => const ProductsDetail(), 37 | false => loader ?? const WidgetLoadDependencies(), 38 | }, 39 | bindings: [], 40 | ), 41 | ], 42 | ), 43 | // FlutterGetItPageRouter( 44 | // name: '/Page', 45 | // builderAsync: (context, isReady, loader) => switch (isReady) { 46 | // true => ProductsPage( 47 | // ctrl: context.get(), 48 | // ), 49 | // false => loader ?? const WidgetLoadDependencies(), 50 | // }, 51 | // bindings: [ 52 | // Bind.lazySingleton( 53 | // (i) => ProductController(), 54 | // ) 55 | // ], 56 | // pages: [ 57 | // FlutterGetItPageRouter( 58 | // name: '/Detail', 59 | // builderAsync: (context, isReady, loader) => switch (isReady) { 60 | // true => const ProductsDetail(), 61 | // false => loader ?? const WidgetLoadDependencies(), 62 | // }, 63 | // bindings: [], 64 | // ), 65 | // ], 66 | // ), 67 | ]; 68 | 69 | @override 70 | void onDispose(Injector i) {} 71 | 72 | @override 73 | void onInit(Injector i) {} 74 | } 75 | -------------------------------------------------------------------------------- /example/lib/src/products/products_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/src/products/model/product_model.dart'; 2 | import 'package:example/src/products/product_controller.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | class ProductsPage extends StatelessWidget { 6 | final ProductController ctrl; 7 | const ProductsPage({super.key, required this.ctrl}); 8 | 9 | @override 10 | Widget build(BuildContext context) { 11 | return Scaffold( 12 | appBar: AppBar( 13 | title: const Text('Products'), 14 | ), 15 | body: ListView.builder( 16 | itemCount: ProductModel.getFake.length, 17 | itemBuilder: (context, index) => ListTile( 18 | title: Text('Product ${ProductModel.getFake[index].name}'), 19 | onTap: () => Navigator.of(context).pushNamed( 20 | '/Products/Page/Detail', 21 | arguments: ProductModel.getFake[index], 22 | ), 23 | ), 24 | ), 25 | ); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /example/lib/src/random/random_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_getit/flutter_getit.dart'; 2 | 3 | class RandomController with FlutterGetItMixin { 4 | final String title; 5 | 6 | RandomController(this.title); 7 | @override 8 | void onDispose() {} 9 | 10 | @override 11 | void onInit() {} 12 | } 13 | -------------------------------------------------------------------------------- /example/lib/src/random/random_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/src/random/random_controller.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_getit/flutter_getit.dart'; 4 | 5 | class RandomPage extends StatelessWidget { 6 | const RandomPage({super.key}); 7 | 8 | @override 9 | Widget build(BuildContext context) { 10 | return Scaffold( 11 | appBar: AppBar( 12 | title: Text(context.get().title), 13 | ), 14 | body: Center( 15 | child: ElevatedButton( 16 | onPressed: () { 17 | Navigator.of(context).pushNamed('/Random/Page2'); 18 | }, 19 | child: const Text('Random Page2 ')), 20 | ), 21 | ); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example/lib/src/route_outlet_nav_bar/my_nav_bar.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_getit/flutter_getit.dart'; 3 | 4 | final internalNav = GlobalKey(); 5 | final internalNav2 = GlobalKey(); 6 | 7 | class RouteOutletMyNavBar extends StatefulWidget { 8 | const RouteOutletMyNavBar({super.key}); 9 | 10 | @override 11 | State createState() => _RouteOutletMyNavBarState(); 12 | } 13 | 14 | class _RouteOutletMyNavBarState extends State { 15 | var _currentIndex = 0; 16 | @override 17 | Widget build(BuildContext context) { 18 | return Scaffold( 19 | body: FlutterGetItRouteOutlet( 20 | initialRoute: '/Auth/Login', 21 | navKey: internalNav, 22 | transitionsBuilder: (context, animation, secondaryAnimation, child) => 23 | ScaleTransition( 24 | scale: Tween(begin: 0.0, end: 1.0).animate(animation), 25 | child: child, 26 | ), 27 | ), 28 | bottomNavigationBar: BottomNavigationBar( 29 | currentIndex: _currentIndex, 30 | onTap: (value) { 31 | if (_currentIndex != value) { 32 | switch (value) { 33 | case 0: 34 | internalNav.currentState 35 | ?.pushNamedAndRemoveUntil('/Auth/Login', (_) => false); 36 | case 1: 37 | internalNav.currentState?.pushNamedAndRemoveUntil( 38 | '/Auth/Register/Page', (_) => false); 39 | case 2: 40 | internalNav.currentState 41 | ?.pushNamedAndRemoveUntil('/RootNavBar/Root', (_) => false); 42 | case 3: 43 | internalNav.currentState?.pushNamedAndRemoveUntil( 44 | '/Landing/Initialize', (_) => false); 45 | } 46 | setState(() { 47 | _currentIndex = value; 48 | }); 49 | } 50 | }, 51 | items: const [ 52 | BottomNavigationBarItem( 53 | icon: Icon( 54 | Icons.home, 55 | color: Colors.blueAccent, 56 | ), 57 | label: 'Login', 58 | ), 59 | BottomNavigationBarItem( 60 | icon: Icon( 61 | Icons.production_quantity_limits, 62 | color: Colors.blueAccent, 63 | ), 64 | label: 'Register', 65 | ), 66 | BottomNavigationBarItem( 67 | icon: Icon( 68 | Icons.home, 69 | color: Colors.blueAccent, 70 | ), 71 | label: 'Custom NavBar', 72 | ), 73 | BottomNavigationBarItem( 74 | icon: Icon( 75 | Icons.home, 76 | color: Colors.blueAccent, 77 | ), 78 | label: 'Presentation', 79 | ), 80 | ], 81 | ), 82 | ); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /example/lib/src/route_outlet_nav_bar/my_nav_bar_helper_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_getit/flutter_getit.dart'; 2 | 3 | class MyNavBarHelperController with FlutterGetItMixin { 4 | @override 5 | void onDispose() {} 6 | 7 | @override 8 | void onInit() {} 9 | } 10 | -------------------------------------------------------------------------------- /example/lib/src/route_outlet_nav_bar/nav_bar_module.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/src/loader/load_dependencies.dart'; 2 | import 'package:example/src/nav_bar/my_nav_bar.dart'; 3 | import 'package:flutter_getit/flutter_getit.dart'; 4 | 5 | class NavBarModule extends FlutterGetItModule { 6 | @override 7 | String get moduleRouteName => '/RootNavBar'; 8 | 9 | @override 10 | List> get bindings => []; 11 | 12 | @override 13 | List get pages => [ 14 | FlutterGetItPageRouter( 15 | name: '/Root', 16 | builderAsync: (context, isReady, loader) => switch (isReady) { 17 | true => const MyNavBar(), 18 | false => loader ?? const WidgetLoadDependencies(), 19 | }, 20 | ), 21 | ]; 22 | 23 | @override 24 | void onDispose(Injector i) {} 25 | 26 | @override 27 | void onInit(Injector i) {} 28 | } 29 | -------------------------------------------------------------------------------- /example/lib/src/splash/splash_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class SplashPage extends StatefulWidget { 4 | const SplashPage({super.key}); 5 | 6 | @override 7 | State createState() => _SplashPageState(); 8 | } 9 | 10 | class _SplashPageState extends State { 11 | double width = 0.0; 12 | double height = 0.0; 13 | 14 | @override 15 | void initState() { 16 | WidgetsBinding.instance.addPostFrameCallback((_) async { 17 | setState(() { 18 | width = 200; 19 | height = 200; 20 | }); 21 | await Future.delayed(const Duration(seconds: 2)); 22 | if (mounted) { 23 | Navigator.of(context).pushReplacementNamed('/Landing/Initialize'); 24 | } 25 | }); 26 | super.initState(); 27 | } 28 | 29 | @override 30 | Widget build(BuildContext context) { 31 | return Scaffold( 32 | appBar: AppBar( 33 | title: const Text('SplashPage'), 34 | ), 35 | body: Center( 36 | child: AnimatedContainer( 37 | duration: const Duration(seconds: 2), 38 | width: width, 39 | height: height, 40 | child: const FlutterLogo( 41 | size: 200, 42 | )), 43 | ), 44 | ); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /example/linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /example/linux/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.10) 3 | project(runner LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "example") 8 | # The unique GTK application identifier for this application. See: 9 | # https://wiki.gnome.org/HowDoI/ChooseApplicationID 10 | set(APPLICATION_ID "com.example.example") 11 | 12 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 13 | # versions of CMake. 14 | cmake_policy(SET CMP0063 NEW) 15 | 16 | # Load bundled libraries from the lib/ directory relative to the binary. 17 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 18 | 19 | # Root filesystem for cross-building. 20 | if(FLUTTER_TARGET_PLATFORM_SYSROOT) 21 | set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) 22 | set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) 23 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 24 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 25 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 26 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 27 | endif() 28 | 29 | # Define build configuration options. 30 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 31 | set(CMAKE_BUILD_TYPE "Debug" CACHE 32 | STRING "Flutter build mode" FORCE) 33 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 34 | "Debug" "Profile" "Release") 35 | endif() 36 | 37 | # Compilation settings that should be applied to most targets. 38 | # 39 | # Be cautious about adding new options here, as plugins use this function by 40 | # default. In most cases, you should add new options to specific targets instead 41 | # of modifying this function. 42 | function(APPLY_STANDARD_SETTINGS TARGET) 43 | target_compile_features(${TARGET} PUBLIC cxx_std_14) 44 | target_compile_options(${TARGET} PRIVATE -Wall -Werror) 45 | target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") 46 | target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") 47 | endfunction() 48 | 49 | # Flutter library and tool build rules. 50 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 51 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 52 | 53 | # System-level dependencies. 54 | find_package(PkgConfig REQUIRED) 55 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 56 | 57 | add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") 58 | 59 | # Define the application target. To change its name, change BINARY_NAME above, 60 | # not the value here, or `flutter run` will no longer work. 61 | # 62 | # Any new source files that you add to the application should be added here. 63 | add_executable(${BINARY_NAME} 64 | "main.cc" 65 | "my_application.cc" 66 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 67 | ) 68 | 69 | # Apply the standard set of build settings. This can be removed for applications 70 | # that need different build settings. 71 | apply_standard_settings(${BINARY_NAME}) 72 | 73 | # Add dependency libraries. Add any application-specific dependencies here. 74 | target_link_libraries(${BINARY_NAME} PRIVATE flutter) 75 | target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) 76 | 77 | # Run the Flutter tool portions of the build. This must not be removed. 78 | add_dependencies(${BINARY_NAME} flutter_assemble) 79 | 80 | # Only the install-generated bundle's copy of the executable will launch 81 | # correctly, since the resources must in the right relative locations. To avoid 82 | # people trying to run the unbundled copy, put it in a subdirectory instead of 83 | # the default top-level location. 84 | set_target_properties(${BINARY_NAME} 85 | PROPERTIES 86 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" 87 | ) 88 | 89 | 90 | # Generated plugin build rules, which manage building the plugins and adding 91 | # them to the application. 92 | include(flutter/generated_plugins.cmake) 93 | 94 | 95 | # === Installation === 96 | # By default, "installing" just makes a relocatable bundle in the build 97 | # directory. 98 | set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") 99 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 100 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 101 | endif() 102 | 103 | # Start with a clean build bundle directory every time. 104 | install(CODE " 105 | file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") 106 | " COMPONENT Runtime) 107 | 108 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 109 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") 110 | 111 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 112 | COMPONENT Runtime) 113 | 114 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 115 | COMPONENT Runtime) 116 | 117 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 118 | COMPONENT Runtime) 119 | 120 | foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) 121 | install(FILES "${bundled_library}" 122 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 123 | COMPONENT Runtime) 124 | endforeach(bundled_library) 125 | 126 | # Copy the native assets provided by the build.dart from all packages. 127 | set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") 128 | install(DIRECTORY "${NATIVE_ASSETS_DIR}" 129 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 130 | COMPONENT Runtime) 131 | 132 | # Fully re-copy the assets directory on each build to avoid having stale files 133 | # from a previous install. 134 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 135 | install(CODE " 136 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 137 | " COMPONENT Runtime) 138 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 139 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 140 | 141 | # Install the AOT library on non-Debug builds only. 142 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") 143 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 144 | COMPONENT Runtime) 145 | endif() 146 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/linux/my_application.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | #include 4 | #ifdef GDK_WINDOWING_X11 5 | #include 6 | #endif 7 | 8 | #include "flutter/generated_plugin_registrant.h" 9 | 10 | struct _MyApplication { 11 | GtkApplication parent_instance; 12 | char** dart_entrypoint_arguments; 13 | }; 14 | 15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) 16 | 17 | // Implements GApplication::activate. 18 | static void my_application_activate(GApplication* application) { 19 | MyApplication* self = MY_APPLICATION(application); 20 | GtkWindow* window = 21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 22 | 23 | // Use a header bar when running in GNOME as this is the common style used 24 | // by applications and is the setup most users will be using (e.g. Ubuntu 25 | // desktop). 26 | // If running on X and not using GNOME then just use a traditional title bar 27 | // in case the window manager does more exotic layout, e.g. tiling. 28 | // If running on Wayland assume the header bar will work (may need changing 29 | // if future cases occur). 30 | gboolean use_header_bar = TRUE; 31 | #ifdef GDK_WINDOWING_X11 32 | GdkScreen* screen = gtk_window_get_screen(window); 33 | if (GDK_IS_X11_SCREEN(screen)) { 34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 36 | use_header_bar = FALSE; 37 | } 38 | } 39 | #endif 40 | if (use_header_bar) { 41 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 42 | gtk_widget_show(GTK_WIDGET(header_bar)); 43 | gtk_header_bar_set_title(header_bar, "example"); 44 | gtk_header_bar_set_show_close_button(header_bar, TRUE); 45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 46 | } else { 47 | gtk_window_set_title(window, "example"); 48 | } 49 | 50 | gtk_window_set_default_size(window, 1280, 720); 51 | gtk_widget_show(GTK_WIDGET(window)); 52 | 53 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 54 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); 55 | 56 | FlView* view = fl_view_new(project); 57 | gtk_widget_show(GTK_WIDGET(view)); 58 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 59 | 60 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 61 | 62 | gtk_widget_grab_focus(GTK_WIDGET(view)); 63 | } 64 | 65 | // Implements GApplication::local_command_line. 66 | static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { 67 | MyApplication* self = MY_APPLICATION(application); 68 | // Strip out the first argument as it is the binary name. 69 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 70 | 71 | g_autoptr(GError) error = nullptr; 72 | if (!g_application_register(application, nullptr, &error)) { 73 | g_warning("Failed to register: %s", error->message); 74 | *exit_status = 1; 75 | return TRUE; 76 | } 77 | 78 | g_application_activate(application); 79 | *exit_status = 0; 80 | 81 | return TRUE; 82 | } 83 | 84 | // Implements GApplication::startup. 85 | static void my_application_startup(GApplication* application) { 86 | //MyApplication* self = MY_APPLICATION(object); 87 | 88 | // Perform any actions required at application startup. 89 | 90 | G_APPLICATION_CLASS(my_application_parent_class)->startup(application); 91 | } 92 | 93 | // Implements GApplication::shutdown. 94 | static void my_application_shutdown(GApplication* application) { 95 | //MyApplication* self = MY_APPLICATION(object); 96 | 97 | // Perform any actions required at application shutdown. 98 | 99 | G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application); 100 | } 101 | 102 | // Implements GObject::dispose. 103 | static void my_application_dispose(GObject* object) { 104 | MyApplication* self = MY_APPLICATION(object); 105 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 106 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 107 | } 108 | 109 | static void my_application_class_init(MyApplicationClass* klass) { 110 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 111 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; 112 | G_APPLICATION_CLASS(klass)->startup = my_application_startup; 113 | G_APPLICATION_CLASS(klass)->shutdown = my_application_shutdown; 114 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 115 | } 116 | 117 | static void my_application_init(MyApplication* self) {} 118 | 119 | MyApplication* my_application_new() { 120 | return MY_APPLICATION(g_object_new(my_application_get_type(), 121 | "application-id", APPLICATION_ID, 122 | "flags", G_APPLICATION_NON_UNIQUE, 123 | nullptr)); 124 | } 125 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /example/macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import shared_preferences_foundation 9 | 10 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 11 | SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) 12 | } 13 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/macos/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - FlutterMacOS (1.0.0) 3 | - shared_preferences_foundation (0.0.1): 4 | - Flutter 5 | - FlutterMacOS 6 | 7 | DEPENDENCIES: 8 | - FlutterMacOS (from `Flutter/ephemeral`) 9 | - shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`) 10 | 11 | EXTERNAL SOURCES: 12 | FlutterMacOS: 13 | :path: Flutter/ephemeral 14 | shared_preferences_foundation: 15 | :path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin 16 | 17 | SPEC CHECKSUMS: 18 | FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 19 | shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 20 | 21 | PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367 22 | 23 | COCOAPODS: 1.15.2 24 | -------------------------------------------------------------------------------- /example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 43 | 49 | 50 | 51 | 52 | 53 | 63 | 65 | 71 | 72 | 73 | 74 | 80 | 82 | 88 | 89 | 90 | 91 | 93 | 94 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /example/macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @main 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigorahman/getit_flutter/00b8661bda61317409b6c4b94f035168a426f4de/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigorahman/getit_flutter/00b8661bda61317409b6c4b94f035168a426f4de/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigorahman/getit_flutter/00b8661bda61317409b6c4b94f035168a426f4de/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigorahman/getit_flutter/00b8661bda61317409b6c4b94f035168a426f4de/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigorahman/getit_flutter/00b8661bda61317409b6c4b94f035168a426f4de/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigorahman/getit_flutter/00b8661bda61317409b6c4b94f035168a426f4de/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigorahman/getit_flutter/00b8661bda61317409b6c4b94f035168a426f4de/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /example/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 = example 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.example 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2024 com.example. All rights reserved. 15 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/macos/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 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 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: example 2 | description: "A new Flutter project." 3 | # The following line prevents the package from being accidentally published to 4 | # pub.dev using `flutter pub publish`. This is preferred for private packages. 5 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev 6 | 7 | # The following defines the version and build number for your application. 8 | # A version number is three numbers separated by dots, like 1.2.43 9 | # followed by an optional build number separated by a +. 10 | # Both the version and the builder number may be overridden in flutter 11 | # build by specifying --build-name and --build-number, respectively. 12 | # In Android, build-name is used as versionName while build-number used as versionCode. 13 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 14 | # In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. 15 | # Read more about iOS versioning at 16 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 17 | # In Windows, build-name is used as the major, minor, and patch parts 18 | # of the product and file versions while build-number is used as the build suffix. 19 | version: 1.0.0+1 20 | 21 | environment: 22 | sdk: '>=3.4.0 <4.0.0' 23 | 24 | # Dependencies specify other packages that your package needs in order to work. 25 | # To automatically upgrade your package dependencies to the latest versions 26 | # consider running `flutter pub upgrade --major-versions`. Alternatively, 27 | # dependencies can be manually updated by changing the version numbers below to 28 | # the latest version available on pub.dev. To see which dependencies have newer 29 | # versions available, run `flutter pub outdated`. 30 | dependencies: 31 | flutter: 32 | sdk: flutter 33 | 34 | 35 | # The following adds the Cupertino Icons font to your application. 36 | # Use with the CupertinoIcons class for iOS style icons. 37 | cupertino_icons: ^1.0.6 38 | shared_preferences: ^2.2.3 39 | flutter_getit: 40 | path: ../ 41 | 42 | dev_dependencies: 43 | flutter_test: 44 | sdk: flutter 45 | 46 | # The "flutter_lints" package below contains a set of recommended lints to 47 | # encourage good coding practices. The lint set provided by the package is 48 | # activated in the `analysis_options.yaml` file located at the root of your 49 | # package. See that file for information about deactivating specific lint 50 | # rules and activating additional ones. 51 | flutter_lints: ^3.0.0 52 | 53 | 54 | # For information on the generic Dart part of this file, see the 55 | # following page: https://dart.dev/tools/pub/pubspec 56 | 57 | # The following section is specific to Flutter packages. 58 | flutter: 59 | 60 | # The following line ensures that the Material Icons font is 61 | # included with your application, so that you can use the icons in 62 | # the material Icons class. 63 | uses-material-design: true 64 | 65 | # To add assets to your application, add an assets section, like this: 66 | # assets: 67 | # - images/a_dot_burr.jpeg 68 | # - images/a_dot_ham.jpeg 69 | 70 | # An image asset can refer to one or more resolution-specific "variants", see 71 | # https://flutter.dev/assets-and-images/#resolution-aware 72 | 73 | # For details regarding adding assets from package dependencies, see 74 | # https://flutter.dev/assets-and-images/#from-packages 75 | 76 | # To add custom fonts to your application, add a fonts section here, 77 | # in this "flutter" section. Each entry in this list should have a 78 | # "family" key with the font family name, and a "fonts" key with a 79 | # list giving the asset and other descriptors for the font. For 80 | # example: 81 | # fonts: 82 | # - family: Schyler 83 | # fonts: 84 | # - asset: fonts/Schyler-Regular.ttf 85 | # - asset: fonts/Schyler-Italic.ttf 86 | # style: italic 87 | # - family: Trajan Pro 88 | # fonts: 89 | # - asset: fonts/TrajanPro.ttf 90 | # - asset: fonts/TrajanPro_Bold.ttf 91 | # weight: 700 92 | # 93 | # For details regarding fonts from package dependencies, 94 | # see https://flutter.dev/custom-fonts/#from-packages 95 | -------------------------------------------------------------------------------- /example/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility in the flutter_test package. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter_test/flutter_test.dart'; 10 | 11 | import 'package:example/main.dart'; 12 | 13 | void main() { 14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 15 | // Build our app and trigger a frame. 16 | await tester.pumpWidget(const MyApp()); 17 | 18 | // Verify that our counter starts at 0. 19 | expect(find.text('0'), findsOneWidget); 20 | expect(find.text('1'), findsNothing); 21 | 22 | // Tap the '+' icon and trigger a frame. 23 | await tester.tap(find.byIcon(Icons.add)); 24 | await tester.pump(); 25 | 26 | // Verify that our counter has incremented. 27 | expect(find.text('0'), findsNothing); 28 | expect(find.text('1'), findsOneWidget); 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /example/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigorahman/getit_flutter/00b8661bda61317409b6c4b94f035168a426f4de/example/web/favicon.png -------------------------------------------------------------------------------- /example/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigorahman/getit_flutter/00b8661bda61317409b6c4b94f035168a426f4de/example/web/icons/Icon-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigorahman/getit_flutter/00b8661bda61317409b6c4b94f035168a426f4de/example/web/icons/Icon-512.png -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigorahman/getit_flutter/00b8661bda61317409b6c4b94f035168a426f4de/example/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigorahman/getit_flutter/00b8661bda61317409b6c4b94f035168a426f4de/example/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /example/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | example 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /example/web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "short_name": "example", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "A new Flutter project.", 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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.14) 3 | project(example LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "example") 8 | 9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 10 | # versions of CMake. 11 | cmake_policy(VERSION 3.14...3.25) 12 | 13 | # Define build configuration option. 14 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 15 | if(IS_MULTICONFIG) 16 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 17 | CACHE STRING "" FORCE) 18 | else() 19 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 20 | set(CMAKE_BUILD_TYPE "Debug" CACHE 21 | STRING "Flutter build mode" FORCE) 22 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 23 | "Debug" "Profile" "Release") 24 | endif() 25 | endif() 26 | # Define settings for the Profile build mode. 27 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 28 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 29 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 30 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 31 | 32 | # Use Unicode for all projects. 33 | add_definitions(-DUNICODE -D_UNICODE) 34 | 35 | # Compilation settings that should be applied to most targets. 36 | # 37 | # Be cautious about adding new options here, as plugins use this function by 38 | # default. In most cases, you should add new options to specific targets instead 39 | # of modifying this function. 40 | function(APPLY_STANDARD_SETTINGS TARGET) 41 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 42 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 43 | target_compile_options(${TARGET} PRIVATE /EHsc) 44 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 45 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 46 | endfunction() 47 | 48 | # Flutter library and tool build rules. 49 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 50 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 51 | 52 | # Application build; see runner/CMakeLists.txt. 53 | add_subdirectory("runner") 54 | 55 | 56 | # Generated plugin build rules, which manage building the plugins and adding 57 | # them to the application. 58 | include(flutter/generated_plugins.cmake) 59 | 60 | 61 | # === Installation === 62 | # Support files are copied into place next to the executable, so that it can 63 | # run in place. This is done instead of making a separate bundle (as on Linux) 64 | # so that building and running from within Visual Studio will work. 65 | set(BUILD_BUNDLE_DIR "$") 66 | # Make the "install" step default, as it's required to run. 67 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 68 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 69 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 70 | endif() 71 | 72 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 73 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 74 | 75 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 76 | COMPONENT Runtime) 77 | 78 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 79 | COMPONENT Runtime) 80 | 81 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 82 | COMPONENT Runtime) 83 | 84 | if(PLUGIN_BUNDLED_LIBRARIES) 85 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 86 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 87 | COMPONENT Runtime) 88 | endif() 89 | 90 | # Copy the native assets provided by the build.dart from all packages. 91 | set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") 92 | install(DIRECTORY "${NATIVE_ASSETS_DIR}" 93 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 94 | COMPONENT Runtime) 95 | 96 | # Fully re-copy the assets directory on each build to avoid having stale files 97 | # from a previous install. 98 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 99 | install(CODE " 100 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 101 | " COMPONENT Runtime) 102 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 103 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 104 | 105 | # Install the AOT library on non-Debug builds only. 106 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 107 | CONFIGURATIONS Profile;Release 108 | COMPONENT Runtime) 109 | -------------------------------------------------------------------------------- /example/windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.14) 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 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 12 | 13 | # Set fallback configurations for older versions of the flutter tool. 14 | if (NOT DEFINED FLUTTER_TARGET_PLATFORM) 15 | set(FLUTTER_TARGET_PLATFORM "windows-x64") 16 | endif() 17 | 18 | # === Flutter Library === 19 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 20 | 21 | # Published to parent scope for install step. 22 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 23 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 24 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 25 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 26 | 27 | list(APPEND FLUTTER_LIBRARY_HEADERS 28 | "flutter_export.h" 29 | "flutter_windows.h" 30 | "flutter_messenger.h" 31 | "flutter_plugin_registrar.h" 32 | "flutter_texture_registrar.h" 33 | ) 34 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 35 | add_library(flutter INTERFACE) 36 | target_include_directories(flutter INTERFACE 37 | "${EPHEMERAL_DIR}" 38 | ) 39 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 40 | add_dependencies(flutter flutter_assemble) 41 | 42 | # === Wrapper === 43 | list(APPEND CPP_WRAPPER_SOURCES_CORE 44 | "core_implementations.cc" 45 | "standard_codec.cc" 46 | ) 47 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 48 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 49 | "plugin_registrar.cc" 50 | ) 51 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 52 | list(APPEND CPP_WRAPPER_SOURCES_APP 53 | "flutter_engine.cc" 54 | "flutter_view_controller.cc" 55 | ) 56 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 57 | 58 | # Wrapper sources needed for a plugin. 59 | add_library(flutter_wrapper_plugin STATIC 60 | ${CPP_WRAPPER_SOURCES_CORE} 61 | ${CPP_WRAPPER_SOURCES_PLUGIN} 62 | ) 63 | apply_standard_settings(flutter_wrapper_plugin) 64 | set_target_properties(flutter_wrapper_plugin PROPERTIES 65 | POSITION_INDEPENDENT_CODE ON) 66 | set_target_properties(flutter_wrapper_plugin PROPERTIES 67 | CXX_VISIBILITY_PRESET hidden) 68 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 69 | target_include_directories(flutter_wrapper_plugin PUBLIC 70 | "${WRAPPER_ROOT}/include" 71 | ) 72 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 73 | 74 | # Wrapper sources needed for the runner. 75 | add_library(flutter_wrapper_app STATIC 76 | ${CPP_WRAPPER_SOURCES_CORE} 77 | ${CPP_WRAPPER_SOURCES_APP} 78 | ) 79 | apply_standard_settings(flutter_wrapper_app) 80 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 81 | target_include_directories(flutter_wrapper_app PUBLIC 82 | "${WRAPPER_ROOT}/include" 83 | ) 84 | add_dependencies(flutter_wrapper_app flutter_assemble) 85 | 86 | # === Flutter tool backend === 87 | # _phony_ is a non-existent file to force this command to run every time, 88 | # since currently there's no way to get a full input/output list from the 89 | # flutter tool. 90 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 91 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 92 | add_custom_command( 93 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 94 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 95 | ${CPP_WRAPPER_SOURCES_APP} 96 | ${PHONY_OUTPUT} 97 | COMMAND ${CMAKE_COMMAND} -E env 98 | ${FLUTTER_TOOL_ENVIRONMENT} 99 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 100 | ${FLUTTER_TARGET_PLATFORM} $ 101 | VERBATIM 102 | ) 103 | add_custom_target(flutter_assemble DEPENDS 104 | "${FLUTTER_LIBRARY}" 105 | ${FLUTTER_LIBRARY_HEADERS} 106 | ${CPP_WRAPPER_SOURCES_CORE} 107 | ${CPP_WRAPPER_SOURCES_PLUGIN} 108 | ${CPP_WRAPPER_SOURCES_APP} 109 | ) 110 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) 64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0,0 67 | #endif 68 | 69 | #if defined(FLUTTER_VERSION) 70 | #define VERSION_AS_STRING FLUTTER_VERSION 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "com.example" "\0" 93 | VALUE "FileDescription", "example" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "example" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2024 com.example. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "example.exe" "\0" 98 | VALUE "ProductName", "example" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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"example", 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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigorahman/getit_flutter/00b8661bda61317409b6c4b94f035168a426f4de/example/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | unsigned 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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/windows/runner/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates a win32 window with |title| that is positioned and sized using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size this function will scale the inputted width and height as 35 | // as appropriate for the default monitor. The window is invisible until 36 | // |Show| is called. Returns true if the window was created successfully. 37 | bool Create(const std::wstring& title, const Point& origin, const Size& size); 38 | 39 | // Show the current window. Returns true if the window was successfully shown. 40 | bool Show(); 41 | 42 | // Release OS resources associated with window. 43 | void Destroy(); 44 | 45 | // Inserts |content| into the window tree. 46 | void SetChildContent(HWND content); 47 | 48 | // Returns the backing Window handle to enable clients to set icon and other 49 | // window properties. Returns nullptr if the window has been destroyed. 50 | HWND GetHandle(); 51 | 52 | // If true, closing this window will quit the application. 53 | void SetQuitOnClose(bool quit_on_close); 54 | 55 | // Return a RECT representing the bounds of the current client area. 56 | RECT GetClientArea(); 57 | 58 | protected: 59 | // Processes and route salient window messages for mouse handling, 60 | // size change and DPI. Delegates handling of these to member overloads that 61 | // inheriting classes can handle. 62 | virtual LRESULT MessageHandler(HWND window, 63 | UINT const message, 64 | WPARAM const wparam, 65 | LPARAM const lparam) noexcept; 66 | 67 | // Called when CreateAndShow is called, allowing subclass window-related 68 | // setup. Subclasses should return false if setup fails. 69 | virtual bool OnCreate(); 70 | 71 | // Called when Destroy is called. 72 | virtual void OnDestroy(); 73 | 74 | private: 75 | friend class WindowClassRegistrar; 76 | 77 | // OS callback called by message pump. Handles the WM_NCCREATE message which 78 | // is passed when the non-client area is being created and enables automatic 79 | // non-client DPI scaling so that the non-client area automatically 80 | // responds to changes in DPI. All other messages are handled by 81 | // MessageHandler. 82 | static LRESULT CALLBACK WndProc(HWND const window, 83 | UINT const message, 84 | WPARAM const wparam, 85 | LPARAM const lparam) noexcept; 86 | 87 | // Retrieves a class instance pointer for |window| 88 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 89 | 90 | // Update the window frame's theme to match the system theme. 91 | static void UpdateTheme(HWND const window); 92 | 93 | bool quit_on_close_ = false; 94 | 95 | // window handle for top level window. 96 | HWND window_handle_ = nullptr; 97 | 98 | // window handle for hosted content. 99 | HWND child_content_ = nullptr; 100 | }; 101 | 102 | #endif // RUNNER_WIN32_WINDOW_H_ 103 | -------------------------------------------------------------------------------- /extension/devtools/.pubignore: -------------------------------------------------------------------------------- 1 | !./build -------------------------------------------------------------------------------- /extension/devtools/build/assets/AssetManifest.bin: -------------------------------------------------------------------------------- 1 | 2packages/cupertino_icons/assets/CupertinoIcons.ttf  asset2packages/cupertino_icons/assets/CupertinoIcons.ttf:packages/devtools_app_shared/fonts/Roboto/Roboto-Black.ttf  asset:packages/devtools_app_shared/fonts/Roboto/Roboto-Black.ttf9packages/devtools_app_shared/fonts/Roboto/Roboto-Bold.ttf  asset9packages/devtools_app_shared/fonts/Roboto/Roboto-Bold.ttf:packages/devtools_app_shared/fonts/Roboto/Roboto-Light.ttf  asset:packages/devtools_app_shared/fonts/Roboto/Roboto-Light.ttf;packages/devtools_app_shared/fonts/Roboto/Roboto-Medium.ttf  asset;packages/devtools_app_shared/fonts/Roboto/Roboto-Medium.ttfonmessage({data:data}));var fs=require("fs");Object.assign(global,{self:global,require:require,Module:Module,location:{href:__filename},Worker:nodeWorkerThreads.Worker,importScripts:f=>(0,eval)(fs.readFileSync(f,"utf8")+"//# sourceURL="+f),postMessage:msg=>parentPort.postMessage(msg),performance:global.performance||{now:Date.now}})}var initializedJS=false;function threadPrintErr(){var text=Array.prototype.slice.call(arguments).join(" ");if(ENVIRONMENT_IS_NODE){fs.writeSync(2,text+"\n");return}console.error(text)}function threadAlert(){var text=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:text,threadId:Module["_pthread_self"]()})}var err=threadPrintErr;self.alert=threadAlert;Module["instantiateWasm"]=(info,receiveInstance)=>{var module=Module["wasmModule"];Module["wasmModule"]=null;var instance=new WebAssembly.Instance(module,info);return receiveInstance(instance)};self.onunhandledrejection=e=>{throw e.reason??e};function handleMessage(e){try{if(e.data.cmd==="load"){let messageQueue=[];self.onmessage=e=>messageQueue.push(e);self.startWorker=instance=>{Module=instance;postMessage({"cmd":"loaded"});for(let msg of messageQueue){handleMessage(msg)}self.onmessage=handleMessage};Module["wasmModule"]=e.data.wasmModule;for(const handler of e.data.handlers){Module[handler]=(...args)=>{postMessage({cmd:"callHandler",handler:handler,args:args})}}Module["wasmMemory"]=e.data.wasmMemory;Module["buffer"]=Module["wasmMemory"].buffer;Module["ENVIRONMENT_IS_PTHREAD"]=true;if(typeof e.data.urlOrBlob=="string"){importScripts(e.data.urlOrBlob)}else{var objectUrl=URL.createObjectURL(e.data.urlOrBlob);importScripts(objectUrl);URL.revokeObjectURL(objectUrl)}skwasm(Module)}else if(e.data.cmd==="run"){Module["__emscripten_thread_init"](e.data.pthread_ptr,/*isMainBrowserThread=*/0,/*isMainRuntimeThread=*/0,/*canBlock=*/1);Module["__emscripten_thread_mailbox_await"](e.data.pthread_ptr);Module["establishStackSpace"]();Module["PThread"].receiveObjectTransfer(e.data);Module["PThread"].threadInitTLS();if(!initializedJS){initializedJS=true}try{Module["invokeEntryPoint"](e.data.start_routine,e.data.arg)}catch(ex){if(ex!="unwind"){throw ex}}}else if(e.data.cmd==="cancel"){if(Module["_pthread_self"]()){Module["__emscripten_thread_exit"](-1)}}else if(e.data.target==="setimmediate"){}else if(e.data.cmd==="checkMailbox"){if(initializedJS){Module["checkMailbox"]()}}else if(e.data.cmd){err("worker.js received unknown command "+e.data.cmd);err(e.data)}}catch(ex){if(Module["__emscripten_thread_crashed"]){Module["__emscripten_thread_crashed"]()}throw ex}}self.onmessage=handleMessage; 2 | -------------------------------------------------------------------------------- /extension/devtools/build/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigorahman/getit_flutter/00b8661bda61317409b6c4b94f035168a426f4de/extension/devtools/build/favicon.png -------------------------------------------------------------------------------- /extension/devtools/build/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigorahman/getit_flutter/00b8661bda61317409b6c4b94f035168a426f4de/extension/devtools/build/icons/Icon-192.png -------------------------------------------------------------------------------- /extension/devtools/build/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigorahman/getit_flutter/00b8661bda61317409b6c4b94f035168a426f4de/extension/devtools/build/icons/Icon-512.png -------------------------------------------------------------------------------- /extension/devtools/build/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigorahman/getit_flutter/00b8661bda61317409b6c4b94f035168a426f4de/extension/devtools/build/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /extension/devtools/build/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigorahman/getit_flutter/00b8661bda61317409b6c4b94f035168a426f4de/extension/devtools/build/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /extension/devtools/build/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | flutter_getit_devtools_extension 33 | 34 | 35 | 39 | 40 | 41 | 42 | 43 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /extension/devtools/build/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "flutter_getit_devtools_extension", 3 | "short_name": "flutter_getit_devtools_extension", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "A new Flutter project.", 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 | -------------------------------------------------------------------------------- /extension/devtools/build/version.json: -------------------------------------------------------------------------------- 1 | {"app_name":"flutter_getit_devtools_extension","version":"1.0.0","build_number":"1","package_name":"flutter_getit_devtools_extension"} -------------------------------------------------------------------------------- /extension/devtools/config.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_getit 2 | issueTracker: https://github.com/rodrigorahman/flutter_getit_devtools_extension/issues 3 | version: 1.0.0 4 | materialIconCodePoint: '0xf523' -------------------------------------------------------------------------------- /lib/flutter_getit.dart: -------------------------------------------------------------------------------- 1 | export 'src/config/flutter_getit_config.dart'; 2 | export 'src/core/flutter_getit_container_register.dart'; 3 | export 'src/debug/log/flutter_get_it_logger.dart'; 4 | export 'src/dependency_injector/binds/application_bindings.dart'; 5 | export 'src/dependency_injector/binds/bind.dart'; 6 | export 'src/dependency_injector/binds/flutter_get_it_binding_register.dart'; 7 | export 'src/dependency_injector/injector.dart'; 8 | export 'src/enum/middleware_result.dart'; 9 | export 'src/middleware/flutter_get_it_async_middleware.dart'; 10 | export 'src/middleware/flutter_get_it_middleware_context.dart'; 11 | export 'src/middleware/flutter_get_it_sync_middleware.dart'; 12 | export 'src/mixin/flutter_get_it_mixin.dart'; 13 | export 'src/routers/flutter_getit_module.dart'; 14 | export 'src/routers/flutter_getit_module_page_router.dart'; 15 | export 'src/widget/flutter_getit_route_outlet.dart'; 16 | export 'src/widget/flutter_getit_view.dart'; 17 | export 'src/widget/flutter_getit_widget.dart'; 18 | -------------------------------------------------------------------------------- /lib/src/core/flutter_getit_container_register.dart: -------------------------------------------------------------------------------- 1 | import '../../flutter_getit.dart'; 2 | import '../middleware/flutter_get_it_middleware.dart'; 3 | import 'model/binding_register.dart'; 4 | 5 | final class FlutterGetItContainerRegister { 6 | FlutterGetItContainerRegister(); 7 | 8 | /// The references that will be used in the [FlutterGetItContainerRegister]. 9 | /// Normally used to register the references that will be used or are in use throughout the application. 10 | /// 11 | final List _references = []; 12 | 13 | List middlewares(String id) => 14 | _references 15 | .cast() 16 | .firstWhere( 17 | (element) => element?.id == id, 18 | orElse: () => null, 19 | ) 20 | ?.middlewares ?? 21 | []; 22 | 23 | bool _contains(String id) => _references.any((element) => element.id == id); 24 | 25 | /// Register a reference in the [FlutterGetItContainerRegister]. 26 | /// Normally used to register the references that will be used or are in use throughout the application. 27 | /// If the reference is already registered, it will not be registered again. 28 | /// 29 | void register( 30 | String id, 31 | List bindings, { 32 | List middleware = const [], 33 | }) { 34 | switch (_contains(id)) { 35 | case true: 36 | incrementListener(id); 37 | break; 38 | case false: 39 | _references.add( 40 | RegisterModel( 41 | bindings: bindings, 42 | id: id, 43 | middlewares: middleware, 44 | ), 45 | ); 46 | break; 47 | } 48 | } 49 | 50 | /// Increment a listener in the reference. 51 | /// 52 | void incrementListener(String id) { 53 | final index = _references.indexWhere((element) => element.id == id); 54 | if (index != -1) { 55 | _references[index].addListener(); 56 | } 57 | } 58 | 59 | /// Decrement a listener in the reference. 60 | /// 61 | void decrementListener(String id) { 62 | final index = _references.indexWhere((element) => element.id == id); 63 | if (index != -1) { 64 | _references[index].removeListener(); 65 | } 66 | } 67 | 68 | /// Check if the reference is registered. 69 | /// 70 | bool isRegistered(String id) { 71 | var qntOfModuleId = 0; 72 | for (var register in _references) { 73 | if (register.id.contains(id) && register.listeners > 0) { 74 | qntOfModuleId++; 75 | } 76 | } 77 | return qntOfModuleId > 0; 78 | } 79 | 80 | /// Unregister a reference in the [FlutterGetItContainerRegister]. 81 | /// Normally used to unregister the references that will not be used throughout the application. 82 | /// If the reference is not registered, it will not be unregistered. 83 | /// If the reference has listeners, it will not be unregistered. 84 | /// 85 | void unRegister(String id) { 86 | final index = _references.indexWhere((element) => element.id == id); 87 | if (index != -1) { 88 | final otherReferences = [ 89 | ..._references.where((element) => element.id != id) 90 | ]; 91 | for (var bind in _references[index].bindings) { 92 | if (bind.loaded) { 93 | final indexBind = _references[index].bindings.indexOf(bind); 94 | 95 | final isUsed = otherReferences.any( 96 | (element) => element.bindings.any( 97 | (b) => 98 | b.bindingClassName == bind.bindingClassName && 99 | b.tag == bind.tag, 100 | ), 101 | ); 102 | if (!isUsed) { 103 | _references[index].bindings[indexBind] = bind.unRegister(); 104 | } else { 105 | _references[index].bindings[indexBind] = 106 | bind.copyWith(loaded: false); 107 | } 108 | } 109 | } 110 | 111 | if (!_references[index].bindings.any( 112 | (element) => element.loaded, 113 | )) _references.removeAt(index); 114 | } 115 | } 116 | 117 | /// Load a reference in the [FlutterGetItContainerRegister]. 118 | /// Normally used to load the references that will be used throughout the application. 119 | /// If the reference is not registered, it will not be loaded. 120 | /// 121 | void load(String id) { 122 | final index = _references.indexWhere((element) => element.id == id); 123 | if (index != -1) { 124 | for (var bind in _references[index].bindings) { 125 | if (!bind.loaded) { 126 | final indexBind = _references[index].bindings.indexOf(bind); 127 | final bindRegistered = bind.register(); 128 | 129 | if (bindRegistered != null) { 130 | _references[index].bindings[indexBind] = bindRegistered; 131 | } 132 | } 133 | } 134 | } 135 | } 136 | 137 | List references() { 138 | return _references; 139 | } 140 | 141 | /// Check if the reference has any dependents. 142 | /// 143 | bool anyCoreDependents(String id) { 144 | var qntOfModuleId = 0; 145 | for (var register in _references) { 146 | if (register.id.startsWith(id) && (register.listeners > 0)) { 147 | qntOfModuleId++; 148 | } 149 | } 150 | return qntOfModuleId > 0; 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /lib/src/core/model/binding_register.dart: -------------------------------------------------------------------------------- 1 | import '../../dependency_injector/binds/bind.dart'; 2 | import '../../middleware/flutter_get_it_middleware.dart'; 3 | 4 | final class RegisterModel { 5 | /// The bindings that will be used in the context, 6 | /// as [Bind.factory], [Bind.singleton], [Bind.lazySingleton], [Bind.factoryAsync], [Bind.singletonAsync], [Bind.lazySingletonAsync]. 7 | final List bindings; 8 | 9 | /// The middlewares that will be used in the context as 10 | /// [FlutterGetItAsyncMiddleware] or [FlutterGetItSyncMiddleware]. 11 | final List middlewares; 12 | 13 | /// The id of the context. 14 | final String id; 15 | 16 | /// The number of listeners that are using the context. 17 | int listeners; 18 | 19 | RegisterModel({ 20 | required this.bindings, 21 | this.middlewares = const [], 22 | required this.id, 23 | this.listeners = 1, 24 | }); 25 | 26 | @override 27 | String toString() { 28 | return 'RegisterModel{tag=$id,listeners=$listeners,bindings=$bindings,middlewares=$middlewares}'; 29 | } 30 | 31 | /// Add a listener to the context. 32 | /// 33 | void addListener() { 34 | listeners++; 35 | } 36 | 37 | /// Remove a listener from the context. 38 | /// 39 | void removeListener() { 40 | listeners--; 41 | } 42 | 43 | //copyWith 44 | RegisterModel copyWith({ 45 | List? bindings, 46 | List? middlewares, 47 | String? id, 48 | int? listeners, 49 | }) { 50 | return RegisterModel( 51 | bindings: bindings ?? this.bindings, 52 | middlewares: middlewares ?? this.middlewares, 53 | id: id ?? this.id, 54 | listeners: listeners ?? this.listeners, 55 | ); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /lib/src/debug/debug_device.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io' as io; 2 | 3 | String getPlatform() { 4 | if (io.Platform.isIOS) return 'iOS'; 5 | if (io.Platform.isAndroid) return 'Android'; 6 | return 'Other'; 7 | } 8 | -------------------------------------------------------------------------------- /lib/src/debug/debug_mode.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'dart:developer'; 3 | 4 | import 'package:flutter/foundation.dart'; 5 | 6 | import '../../flutter_getit.dart'; 7 | 8 | export 'debug_web.dart' if (dart.library.io) 'debug_device.dart'; 9 | 10 | const cyanColor = '\x1b[36m'; 11 | const redColor = '\x1b[31m'; 12 | const greenColor = '\x1b[32m'; 13 | const whiteColor = '\x1b[37m'; 14 | const yellowColor = '\x1b[33m'; 15 | const blueColor = '\x1b[34m'; 16 | 17 | final class DebugMode { 18 | late final FlutterGetItContainerRegister _register; 19 | static late final bool isEnable; 20 | 21 | DebugMode() { 22 | isEnable = true; 23 | _register = Injector.get(); 24 | registerExtension( 25 | 'ext.br.com.academiadoflutter.flutter_getit.listAll', 26 | (_, parameters) async { 27 | final dataDefault = readyReferences(); 28 | 29 | return ServiceExtensionResponse.result( 30 | jsonEncode({'data': dataDefault})); 31 | }, 32 | ); 33 | } 34 | void printRegister() { 35 | DebugMode.fGetItLog( 36 | const JsonEncoder.withIndent(' ').convert( 37 | readyReferences(), 38 | ), 39 | ); 40 | } 41 | 42 | Map>> readyReferences() { 43 | final references = _register.references(); 44 | 45 | var myMap = >>{}; 46 | 47 | for (var ref in references) { 48 | myMap[ref.id] = >[]; 49 | for (var bind in ref.bindings) { 50 | myMap[ref.id]!.add( 51 | { 52 | 'className': bind.bindingClassName, 53 | 'type': bind.type.name + (bind.keepAlive ? ' (keepAlive)' : ''), 54 | }, 55 | ); 56 | } 57 | } 58 | 59 | return myMap; 60 | } 61 | 62 | static fGetItLog(String data) { 63 | if (isEnable && !kReleaseMode) { 64 | // if (getPlatform() == 'iOS' || getPlatform() == 'Web') { 65 | log(data, name: 'FGetIt'); 66 | /* if (Platform.isIOS) { 67 | log(data, name: 'FGetIt'); 68 | 69 | } else { 70 | debugPrint(data); 71 | } */ 72 | // } 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /lib/src/debug/debug_web.dart: -------------------------------------------------------------------------------- 1 | String getPlatform() => 'Web'; 2 | -------------------------------------------------------------------------------- /lib/src/debug/extension/flutter_get_it_extension.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'dart:developer'; 3 | 4 | import 'package:flutter/material.dart'; 5 | 6 | import '../../../flutter_getit.dart'; 7 | 8 | @protected 9 | final class FlutterGetItExtension { 10 | final FlutterGetItContainerRegister _register; 11 | 12 | FlutterGetItExtension({ 13 | required FlutterGetItContainerRegister register, 14 | }) : _register = register { 15 | registerExtension( 16 | 'ext.br.com.academiadoflutter.flutter_getit.listAll', 17 | (_, parameters) async { 18 | final dataDefault = readyReferences(); 19 | 20 | return ServiceExtensionResponse.result( 21 | jsonEncode({'data': dataDefault})); 22 | }, 23 | ); 24 | } 25 | 26 | Map>> readyReferences() { 27 | final references = _register.references(); 28 | 29 | var myMap = >>{}; 30 | 31 | for (var ref in references) { 32 | myMap[ref.id] = >[]; 33 | for (var bind in ref.bindings) { 34 | myMap[ref.id]!.add( 35 | { 36 | 'className': bind.bindingClassName, 37 | 'type': bind.type.name, 38 | 'keepAlive': bind.keepAlive.toString(), 39 | 'loaded': bind.loaded.toString(), 40 | 'dependsOn': bind.dependsOn.map((e) => e.toString()).toList(), 41 | }, 42 | ); 43 | } 44 | } 45 | 46 | final allReferencesThaIsKeepAlive = references 47 | .where((element) => element.bindings.any((bind) => bind.keepAlive)) 48 | .toList(); 49 | myMap['permanent'] = >[]; 50 | for (var ref in allReferencesThaIsKeepAlive) { 51 | for (var bind in ref.bindings) { 52 | myMap['permanent']!.add( 53 | { 54 | 'className': bind.bindingClassName, 55 | 'type': bind.type.name, 56 | 'keepAlive': bind.keepAlive.toString(), 57 | 'loaded': bind.loaded.toString(), 58 | 'dependsOn': bind.dependsOn.map((e) => e.toString()).toList(), 59 | 'by': ref.id, 60 | }, 61 | ); 62 | } 63 | } 64 | 65 | return myMap; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /lib/src/dependency_injector/binds/application_bindings.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import '../../../flutter_getit.dart'; 4 | 5 | @protected 6 | abstract class FlutterGetItBindings { 7 | List bindings(); 8 | } 9 | 10 | abstract class ApplicationBindings extends FlutterGetItBindings { 11 | @override 12 | List bindings(); 13 | } 14 | -------------------------------------------------------------------------------- /lib/src/dependency_injector/binds/flutter_get_it_binding_register.dart: -------------------------------------------------------------------------------- 1 | /* import '../../../flutter_getit.dart'; 2 | 3 | final class FlutterGetItBindingRegister { 4 | FlutterGetItBindingRegister._(); 5 | 6 | /// This method simplifies the registration of permanent bindings, removing the 7 | /// need to incorporate them into the ApplicationBinding class. It ensures a 8 | /// constant application binding that remains active throughout the entire 9 | /// lifecycle of the application under a specific key. 10 | 11 | static void registerPermanentBinding( 12 | FlutterGetItContainerRegister container, List bindings) { 13 | container 14 | ..register('APPLICATION_PERMANENT', bindings) 15 | ..load('APPLICATION_PERMANENT'); 16 | } 17 | } 18 | */ 19 | -------------------------------------------------------------------------------- /lib/src/dependency_injector/flutter_get_it_binding_opened.dart: -------------------------------------------------------------------------------- 1 | import '../../flutter_getit.dart'; 2 | 3 | typedef FactoryRegister = ({Object obj, String? factoryTag}); 4 | 5 | final class FlutterGetItBindingOpened { 6 | static final _factory = >{}; 7 | static final _hashCodes = []; 8 | static dynamic argument; 9 | FlutterGetItBindingOpened._(); 10 | 11 | static bool contains(int hashCode) => _hashCodes.contains(hashCode); 12 | 13 | static void registerHashCodeOpened(int hashCode) { 14 | if (!_hashCodes.contains(hashCode)) { 15 | _hashCodes.addAll( 16 | [hashCode], 17 | ); 18 | } 19 | } 20 | 21 | static void unRegisterHashCodeOpened(int hashCode) { 22 | if (_hashCodes.contains(hashCode)) _hashCodes.remove(hashCode); 23 | } 24 | 25 | static void registerFactoryOpened(Object factory, String? factoryTag) { 26 | _factory[factory.runtimeType]!.add((obj: factory, factoryTag: factoryTag)); 27 | } 28 | 29 | static T? containsFactoryOpenedByTag(String factoryTag) { 30 | if (!_factory.containsKey(T)) return null; 31 | return _factory[T]! 32 | .cast() 33 | .firstWhere( 34 | (element) => element?.factoryTag == factoryTag, 35 | orElse: () => null, 36 | ) 37 | ?.obj as T?; 38 | } 39 | 40 | /* static void unRegisterFactoryOpened(Object factory) { 41 | final tst = _factory.containsKey(factory); 42 | if (_factory.containsKey(factory)) { 43 | _factory[factory]!.removeWhere( 44 | (element) { 45 | final isIt = element.hashCode == factory.hashCode; 46 | if (isIt && hasMixin(element)) { 47 | DebugMode.fGetItLog( 48 | '🚮$yellowColor Dispose: $element - ${element.hashCode}'); 49 | (element as FlutterGetItMixin).dispose(); 50 | } 51 | return isIt; 52 | }, 53 | ); 54 | } 55 | } */ 56 | 57 | static void registerFactoryDad() { 58 | if (!_factory.containsKey(T)) _factory[T] = []; 59 | } 60 | 61 | static void unRegisterFactories() { 62 | if (_factory.containsKey(T)) { 63 | final childFactory = _factory.remove(T)!; 64 | for (var factory in childFactory) { 65 | FGetItLogger.logUnregisterFactory( 66 | factory.factoryTag ?? 'No FactoryTag', 67 | factory.obj.hashCode.toString(), 68 | ); 69 | if (hasMixin(factory.obj)) { 70 | (factory.obj as FlutterGetItMixin).onDispose(); 71 | } 72 | } 73 | } 74 | } 75 | 76 | static void unRegisterFactoryByTag(String factoryTag) { 77 | if (_factory.containsKey(T)) { 78 | final childFactory = _factory[T]!.cast().firstWhere( 79 | (element) => element?.factoryTag == factoryTag, 80 | orElse: () => null, 81 | ); 82 | if (childFactory != null) { 83 | FGetItLogger.logUnregisterFactory( 84 | factoryTag, 85 | childFactory.obj.hashCode.toString(), 86 | ); 87 | if (hasMixin(childFactory.obj)) { 88 | (childFactory.obj as FlutterGetItMixin).onDispose(); 89 | } 90 | _factory[T]!.remove(childFactory); 91 | } 92 | } 93 | } 94 | 95 | static bool containsFactoryDad() { 96 | return _factory.containsKey(T); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /lib/src/dependency_injector/flutter_get_it_check_dependency.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/rendering.dart'; 2 | 3 | import '../../flutter_getit.dart'; 4 | 5 | final class FlutterGetItCheckDependency { 6 | static Set checkOnDependencies( 7 | {required List> bindings, 8 | required Set alreadyCheck}) { 9 | int totalBindsCheck = bindings 10 | .where((bind) => !alreadyCheck.contains(bind.bindingClassName)) 11 | .length; 12 | if (totalBindsCheck == 0) { 13 | return alreadyCheck; 14 | } 15 | final lazySingletonAsyncDeps = bindings 16 | .where((bind) => bind.type == RegisterType.lazySingletonAsync) 17 | .map((bind) => bind.bindingClassName) 18 | .toSet(); 19 | final allDependsOn = bindings 20 | .expand((bind) => bind.dependsOn.map((d) => d.toString())) 21 | .toSet(); 22 | final dependencyProblem = lazySingletonAsyncDeps 23 | .firstWhere(allDependsOn.contains, orElse: () => ''); 24 | if (dependencyProblem.isNotEmpty) { 25 | throw FlutterError.fromParts([ 26 | ErrorSummary('Misuse of LazySingletonAsync'), 27 | ErrorDescription( 28 | '$dependencyProblem cannot be LazySingletonAsync when it is a dependency of another bind\n'), 29 | ErrorHint('Ensure all binds are correctly configured.'), 30 | DiagnosticsProperty('Problematic Binding', dependencyProblem, 31 | style: DiagnosticsTreeStyle.errorProperty), 32 | DiagnosticsProperty( 33 | 'Recommendation', 'Change $dependencyProblem to SingletonAsync', 34 | style: DiagnosticsTreeStyle.errorProperty), 35 | ]); 36 | } 37 | 38 | return bindings.map((bind) => bind.bindingClassName).toSet(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /lib/src/dependency_injector/injector.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:get_it/get_it.dart'; 3 | 4 | import '../../flutter_getit.dart'; 5 | import '../helper/flutter_get_it_helper.dart'; 6 | import 'flutter_get_it_binding_opened.dart'; 7 | 8 | /// Classe responsável pelo encapsulamento da busca das instancias do GetIt 9 | class Injector { 10 | static void unRegisterFactoryByTag(String factoryTag) { 11 | FlutterGetItBindingOpened.unRegisterFactoryByTag(factoryTag); 12 | } 13 | 14 | static void unRegisterAllFactories() { 15 | FlutterGetItBindingOpened.unRegisterFactories(); 16 | } 17 | 18 | static bool isRegistered({String? tag}) { 19 | return GetIt.I.isRegistered(instanceName: tag); 20 | } 21 | 22 | static dynamic get arguments => FlutterGetItBindingOpened.argument; 23 | 24 | static bool any() { 25 | return GetIt.I.getAll().isNotEmpty; 26 | } 27 | 28 | /// Get para recupera a instancia do GetIt 29 | static T get({ 30 | String? tag, 31 | String? factoryTag, 32 | }) { 33 | try { 34 | final getIt = GetIt.I; 35 | FlutterGetItHelper.throwIfNot( 36 | getIt.isRegistered( 37 | instanceName: tag, 38 | ), 39 | FlutterError( 40 | 'The type $T is not registered in the GetIt injector, please check if it is registered in the module or in the main injector', 41 | ), 42 | ); 43 | 44 | if (factoryTag != null) { 45 | final factoryAlreadyRegistered = 46 | FlutterGetItBindingOpened.containsFactoryOpenedByTag(factoryTag); 47 | if (factoryAlreadyRegistered != null) { 48 | return factoryAlreadyRegistered; 49 | } 50 | } 51 | final obj = getIt.get(instanceName: tag); 52 | final containsFactoryDad = 53 | FlutterGetItBindingOpened.containsFactoryDad(); 54 | final containsHash = FlutterGetItBindingOpened.contains(obj.hashCode); 55 | if (!(T == FlutterGetItContainerRegister) && !containsHash) { 56 | FGetItLogger.logGettingInstance( 57 | tag: tag, 58 | factoryTag: factoryTag, 59 | ); 60 | } 61 | 62 | if (containsFactoryDad) { 63 | FlutterGetItBindingOpened.registerFactoryOpened(obj, factoryTag); 64 | } 65 | 66 | if (hasMixin(obj) && !containsHash) { 67 | (obj as dynamic).onInit(); 68 | } 69 | 70 | FlutterGetItBindingOpened.registerHashCodeOpened(obj.hashCode); 71 | return obj; 72 | } on AssertionError catch (e) { 73 | FGetItLogger.logErrorInGetInstance( 74 | e.toString(), 75 | tag: tag, 76 | factoryTag: factoryTag, 77 | ); 78 | rethrow; 79 | } 80 | } 81 | 82 | static Future getAsync( 83 | {String? tag, String? factoryTag}) async { 84 | try { 85 | FGetItLogger.logGettingAsyncInstance(tag: tag, factoryTag: factoryTag); 86 | 87 | return await GetIt.I.isReady(instanceName: tag).then((_) { 88 | FGetItLogger.logAsyncInstanceReady( 89 | tag: tag, 90 | factoryTag: factoryTag, 91 | ); 92 | 93 | return get(tag: tag, factoryTag: factoryTag); 94 | }); 95 | } on AssertionError catch (e) { 96 | FGetItLogger.logErrorInGetAsyncInstance( 97 | e.toString(), 98 | tag: tag, 99 | factoryTag: factoryTag, 100 | ); 101 | throw Exception('${T.toString()} not found in injector}'); 102 | } 103 | } 104 | 105 | static Future allReady() async { 106 | FGetItLogger.logWaitingAllReady(); 107 | 108 | await GetIt.I.allReady().then((value) { 109 | FGetItLogger.logWaitingAllReadyCompleted(); 110 | }); 111 | } 112 | 113 | /// Callable classe para facilitar a recuperação pela instancia e não pelo atributo de classe, podendo ser passado como parâmetro 114 | T call({String? tag, String? factoryTag}) => 115 | get(tag: tag, factoryTag: factoryTag); 116 | } 117 | 118 | /// Extension para adicionar o recurso do injection dentro do BuildContext 119 | extension InjectorContext on BuildContext { 120 | T get({String? tag, String? factoryTag}) => 121 | Injector.get(tag: tag, factoryTag: factoryTag); 122 | 123 | Future getAsync({String? tag, String? factoryTag}) => 124 | Injector.getAsync(tag: tag, factoryTag: factoryTag); 125 | 126 | bool isRegistered({String? tag}) => 127 | Injector.isRegistered(tag: tag); 128 | 129 | bool any() => Injector.any(); 130 | } 131 | -------------------------------------------------------------------------------- /lib/src/enum/middleware_result.dart: -------------------------------------------------------------------------------- 1 | enum MiddlewareResult { next, failure, complete } 2 | -------------------------------------------------------------------------------- /lib/src/helper/flutter_get_it_helper.dart: -------------------------------------------------------------------------------- 1 | sealed class FlutterGetItHelper { 2 | /// Two handy functions that help me to express my intention clearer and shorter to check for runtime 3 | /// errors 4 | static void throwIf(bool condition, Object error) { 5 | if (condition) throw error; 6 | } 7 | 8 | static void throwIfNot(bool condition, Object error) { 9 | if (!condition) throw error; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /lib/src/middleware/flutter_get_it_async_middleware.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/material.dart'; 4 | 5 | import '../enum/middleware_result.dart'; 6 | import 'flutter_get_it_middleware.dart'; 7 | 8 | abstract class FlutterGetItAsyncMiddleware extends FlutterGetItMiddleware { 9 | Future execute(RouteSettings? route); 10 | Widget onExecute = const Center(child: CircularProgressIndicator.adaptive()); 11 | } 12 | -------------------------------------------------------------------------------- /lib/src/middleware/flutter_get_it_middleware.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/material.dart'; 4 | 5 | import '../../flutter_getit.dart'; 6 | 7 | abstract class FlutterGetItMiddleware { 8 | bool executeWhen(RouteSettings? route) => true; 9 | FutureOr onFail(RouteSettings? route, 10 | FlutterGetItMiddlewareContext fContext, MiddlewareResult result, 11 | {dynamic error}) { 12 | if (fContext.canPop()) { 13 | fContext.pop(); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/src/middleware/flutter_get_it_middleware_context.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class FlutterGetItMiddlewareContext { 4 | final BuildContext _context; 5 | 6 | FlutterGetItMiddlewareContext(BuildContext context) : _context = context; 7 | 8 | bool canPop() { 9 | return Navigator.of(_context).canPop(); 10 | } 11 | 12 | Future pushReplacement(Route newRoute, {TO? result}) { 13 | return Navigator.of(_context).pushReplacement(newRoute, result: result); 14 | } 15 | 16 | Future pushReplacementNamed(String routeName, 17 | {TO? result, Object? arguments}) { 18 | return Navigator.of(_context) 19 | .pushReplacementNamed(routeName, result: result, arguments: arguments); 20 | } 21 | 22 | Future pushAndRemoveUntil( 23 | Route newRoute, bool Function(Route) predicate) { 24 | return Navigator.of(_context).pushAndRemoveUntil(newRoute, predicate); 25 | } 26 | 27 | Future pushNamedAndRemoveUntil( 28 | String routeName, bool Function(Route) predicate, 29 | {Object? arguments}) { 30 | return Navigator.of(_context) 31 | .pushNamedAndRemoveUntil(routeName, predicate, arguments: arguments); 32 | } 33 | 34 | void pop([T? result]) { 35 | Navigator.of(_context).pop(result); 36 | } 37 | 38 | // Show a modal 39 | Future dialog({ 40 | required WidgetBuilder builder, 41 | bool barrierDismissible = true, 42 | Color? barrierColor, 43 | String? barrierLabel, 44 | bool useSafeArea = true, 45 | bool useRootNavigator = true, 46 | RouteSettings? routeSettings, 47 | }) { 48 | return showDialog( 49 | context: _context, 50 | builder: builder, 51 | barrierDismissible: barrierDismissible, 52 | barrierColor: barrierColor, 53 | barrierLabel: barrierLabel, 54 | useSafeArea: useSafeArea, 55 | useRootNavigator: useRootNavigator, 56 | routeSettings: routeSettings, 57 | ); 58 | } 59 | 60 | // Show a snackbar 61 | void showSnackBar(SnackBar snackBar) { 62 | ScaffoldMessenger.of(_context).showSnackBar(snackBar); 63 | } 64 | 65 | // Show a modal bottom sheet 66 | Future bottomSheet({ 67 | required WidgetBuilder builder, 68 | bool isScrollControlled = false, 69 | bool useRootNavigator = false, 70 | bool isDismissible = true, 71 | bool enableDrag = true, 72 | Color? backgroundColor, 73 | double? elevation, 74 | ShapeBorder? shape, 75 | Clip? clipBehavior, 76 | BoxConstraints? constraints, 77 | }) { 78 | return showModalBottomSheet( 79 | context: _context, 80 | builder: builder, 81 | isScrollControlled: isScrollControlled, 82 | useRootNavigator: useRootNavigator, 83 | isDismissible: isDismissible, 84 | enableDrag: enableDrag, 85 | backgroundColor: backgroundColor, 86 | elevation: elevation, 87 | shape: shape, 88 | clipBehavior: clipBehavior, 89 | constraints: constraints, 90 | ); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /lib/src/middleware/flutter_get_it_sync_middleware.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import '../../flutter_getit.dart'; 4 | import 'flutter_get_it_middleware.dart'; 5 | 6 | abstract class FlutterGetItSyncMiddleware extends FlutterGetItMiddleware { 7 | MiddlewareResult execute(RouteSettings? route) { 8 | return MiddlewareResult.next; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /lib/src/mixin/flutter_get_it_mixin.dart: -------------------------------------------------------------------------------- 1 | mixin FlutterGetItMixin on Object { 2 | void onDispose(); 3 | 4 | void onInit(); 5 | } 6 | 7 | bool hasMixin(Object object) { 8 | return object is T; 9 | } 10 | -------------------------------------------------------------------------------- /lib/src/routers/flutter_get_it_route_params_extractor.dart: -------------------------------------------------------------------------------- 1 | class FlutterGetItRouteParamsExtractor { 2 | final String routePattern; 3 | final String actualRoute; 4 | 5 | FlutterGetItRouteParamsExtractor(this.routePattern, this.actualRoute); 6 | 7 | Map extract() { 8 | final patternSegments = _splitSegments(routePattern); 9 | final routeSegments = _splitSegments(actualRoute); 10 | 11 | return _extractParams(patternSegments, routeSegments); 12 | } 13 | 14 | Map _extractParams( 15 | List patternSegments, 16 | List routeSegments, 17 | ) { 18 | final Map params = {}; 19 | 20 | // Itera sobre os segmentos dos padrões e da rota 21 | for (int i = 0; i < patternSegments.length; i++) { 22 | final patternSegment = patternSegments[i]; 23 | final routeSegment = routeSegments.length > i ? routeSegments[i] : null; 24 | 25 | if (routeSegment == null) 26 | break; // Se não houver mais segmentos, sair do loop 27 | 28 | if (_isDynamicSegment(patternSegment)) { 29 | final paramName = _createParamName(patternSegments, i, patternSegment); 30 | params[paramName] = routeSegment; 31 | } 32 | } 33 | 34 | return params; 35 | } 36 | 37 | String _createParamName( 38 | List patternSegments, int index, String dynamicSegment) { 39 | // Obtem o segmento estático anterior ao dinâmico, ou "param" como fallback 40 | final previousSegment = index > 0 ? patternSegments[index - 1] : ''; 41 | 42 | // Remove qualquer caractere especial 43 | final cleanSegment = previousSegment.replaceAll(RegExp(r'[^\w]'), ''); 44 | 45 | // Cria o nome do parâmetro com base no segmento anterior e no próprio nome dinâmico 46 | return '${cleanSegment}_${_extractParamName(dynamicSegment)}'; 47 | } 48 | 49 | List _splitSegments(String path) { 50 | return path.split('/').where((segment) => segment.isNotEmpty).toList(); 51 | } 52 | 53 | bool _isDynamicSegment(String segment) { 54 | return segment.startsWith(':'); 55 | } 56 | 57 | String _extractParamName(String segment) { 58 | return segment.substring(1); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /lib/src/routers/flutter_getit_module_page_router.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import '../../flutter_getit.dart'; 4 | import '../middleware/flutter_get_it_middleware.dart'; 5 | 6 | typedef WidgetBuilderAsync = Widget Function( 7 | BuildContext context, 8 | bool isReady, 9 | Widget? loader, 10 | ); 11 | 12 | class FlutterGetItPageRouter { 13 | /// The name of the PageRouter. 14 | /// 15 | final String name; 16 | 17 | /// Use this builder if you want to create a page that is not async 18 | /// and you don't need to wait for the dependencies to be ready 19 | /// before building the page. 20 | /// 21 | /// If you need to wait for the dependencies to be ready before building the page 22 | /// use [builderAsync]. 23 | /// 24 | /// If you need to show a loader while the dependencies are being loaded 25 | /// use [builderAsync] and pass a loader widget through the middleware [FlutterGetItMiddleware] 26 | /// 27 | final WidgetBuilder? builder; 28 | 29 | /// Use this builder if you want to create a page that is async 30 | /// and you need to wait for the dependencies to be ready, as [Bind.factoryAsync] or [Bind.singletonAsync] or [Bind.lazySingletonAsync] 31 | /// or even if you're using [Injector.arguments] you need to wait for the arguments to be ready 32 | /// before building the page. 33 | /// 34 | /// If you need to show a loader while the dependencies are being loaded 35 | /// pass a loader widget through the middleware [FlutterGetItMiddleware]. 36 | /// 37 | /// If you don't need to wait for the dependencies to be ready before building the page 38 | /// use [builder]. 39 | /// 40 | /// ```dart 41 | /// FlutterGetItPageRouter( 42 | /// name: '/Page', 43 | /// builderAsync: (context, isReady, loader) { 44 | /// return switch (isReady) { 45 | /// true => const ParamPage(), 46 | /// false => loader ?? const CircularProgressIndicator(), 47 | /// }; 48 | /// ``` 49 | /// 50 | final WidgetBuilderAsync? builderAsync; 51 | 52 | /// The bindings that will be used in this page, like 53 | /// [Bind.factory], [Bind.singleton], [Bind.lazySingleton], [Bind.factoryAsync], [Bind.singletonAsync], [Bind.lazySingletonAsync]. 54 | /// 55 | /// If you need to use the same bindings in all pages of the module 56 | /// use the [FlutterGetItModuleRouter.bindings]. 57 | /// 58 | /// ```dart 59 | /// class MyModule extends FlutterGetItModule { 60 | /// @override 61 | /// List get bindings => [ 62 | /// Bind.factory((i) => MyController()), 63 | /// ]; 64 | /// ....the rest of the module 65 | /// ``` 66 | /// 67 | final List bindings; 68 | 69 | /// The middlewares that will be used in this page as 70 | /// [FlutterGetItAsyncMiddleware] or [FlutterGetItSyncMiddleware]. 71 | /// 72 | final List middlewares; 73 | 74 | FlutterGetItPageRouter({ 75 | required this.name, 76 | this.builder, 77 | this.builderAsync, 78 | this.bindings = const [], 79 | this.middlewares = const [], 80 | }); 81 | 82 | FlutterGetItPageRouter copyWith({ 83 | String? name, 84 | WidgetBuilder? builder, 85 | WidgetBuilderAsync? builderAsync, 86 | List? bindings, 87 | List? pages, 88 | List? middlewares, 89 | }) { 90 | return FlutterGetItPageRouter( 91 | name: name ?? this.name, 92 | builder: builder ?? this.builder, 93 | bindings: bindings ?? this.bindings, 94 | middlewares: middlewares ?? this.middlewares, 95 | ); 96 | } 97 | } 98 | 99 | class FlutterGetItModuleRouter extends FlutterGetItPageRouter { 100 | /// The function that will be called when the module is disposed. 101 | /// 102 | /// The module is disposed when all subPages or subModules are disposed 103 | /// and the module is not being used anymore. 104 | /// 105 | final void Function(Injector i)? onDispose; 106 | 107 | /// The function that will be called when the module is initialized. 108 | /// 109 | /// The module is initialized when some of the subPages or subModules build the module for the first time. 110 | /// 111 | final void Function(Injector i)? onInit; 112 | 113 | /// Here you can define the pages that will be used as subPages or subModules of this page like 114 | /// [FlutterGetItPageRouter] or [FlutterGetItModuleRouter]. 115 | /// 116 | final List pages; 117 | 118 | FlutterGetItModuleRouter({ 119 | /// The name of the ModuleRouter. 120 | /// 121 | required super.name, 122 | 123 | /// The bindings that will be used in this page, like 124 | /// [Bind.factory], [Bind.singleton], [Bind.lazySingleton], [Bind.factoryAsync], [Bind.singletonAsync], [Bind.lazySingletonAsync]. 125 | /// 126 | /// If you need to use the same bindings in all pages of the module 127 | /// use the [FlutterGetItModuleRouter.bindings]. 128 | /// 129 | /// ```dart 130 | /// class MyModule extends FlutterGetItModule { 131 | /// @override 132 | /// List get bindings => [ 133 | /// Bind.factory((i) => MyController()), 134 | /// ]; 135 | /// ....the rest of the module 136 | /// ``` 137 | /// 138 | super.bindings, 139 | 140 | /// The middlewares that will be used in this page as 141 | /// [FlutterGetItAsyncMiddleware] or [FlutterGetItSyncMiddleware]. 142 | /// 143 | required this.pages, 144 | 145 | /// The middlewares that will be used in this page as 146 | /// [FlutterGetItAsyncMiddleware] or [FlutterGetItSyncMiddleware]. 147 | /// 148 | super.middlewares, 149 | this.onDispose, 150 | this.onInit, 151 | }) : super( 152 | builder: (context) => const SizedBox.shrink(), 153 | builderAsync: (context, isReady, loader) => const SizedBox.shrink(), 154 | ); 155 | 156 | @override 157 | FlutterGetItModuleRouter copyWith({ 158 | String? name, 159 | WidgetBuilder? builder, 160 | WidgetBuilderAsync? builderAsync, 161 | List? bindings, 162 | List? middlewares, 163 | List? pages, 164 | void Function(Injector i)? onDispose, 165 | void Function(Injector i)? onInit, 166 | }) { 167 | return FlutterGetItModuleRouter( 168 | name: name ?? this.name, 169 | bindings: bindings ?? this.bindings, 170 | pages: pages ?? this.pages, 171 | onDispose: onDispose ?? this.onDispose, 172 | onInit: onInit ?? this.onInit, 173 | middlewares: middlewares ?? this.middlewares, 174 | ); 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /lib/src/types/flutter_getit_typedefs.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | 3 | import '../dependency_injector/binds/bind.dart'; 4 | import '../dependency_injector/injector.dart'; 5 | 6 | typedef ApplicationBindingsBuilder = List Function(); 7 | 8 | typedef BindBuilder = Bind Function(); 9 | 10 | typedef BindRegister = T Function(Injector i); 11 | typedef BindAsyncRegister = Future Function(Injector i); 12 | typedef ApplicationBuilder = Widget Function( 13 | BuildContext context, 14 | Map routes, 15 | bool isReady, 16 | ); 17 | 18 | typedef ApplicationBuilderPath = Widget Function( 19 | BuildContext context, bool isReady, RouteFactory onGenerateRoute); 20 | -------------------------------------------------------------------------------- /lib/src/widget/flutter_getit_route_outlet.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import '../../flutter_getit.dart'; 4 | 5 | typedef FlutterGetItRouteOutletTransitionBuilder = Widget Function( 6 | BuildContext context, 7 | Animation animation, 8 | Animation secondaryAnimation, 9 | Widget child); 10 | 11 | class FlutterGetItRouteOutlet extends StatelessWidget { 12 | final String initialRoute; 13 | final GlobalKey navKey; 14 | final Widget routeNotFound; 15 | final FlutterGetItContextType contextType; 16 | final FlutterGetItRouteOutletTransitionBuilder? transitionsBuilder; 17 | 18 | const FlutterGetItRouteOutlet({ 19 | super.key, 20 | required this.initialRoute, 21 | required this.navKey, 22 | this.routeNotFound = const PageNotFound(), 23 | this.contextType = FlutterGetItContextType.main, 24 | this.transitionsBuilder, 25 | }); 26 | 27 | @override 28 | Widget build(BuildContext context) { 29 | return Navigator( 30 | key: navKey, 31 | initialRoute: initialRoute, 32 | onGenerateRoute: (settings) { 33 | final pages = context.get>( 34 | tag: 'RoutesMap_${contextType.key}', 35 | ); 36 | final widget = pages[settings.name]; 37 | if (widget != null) { 38 | PageRouteBuilder builder = PageRouteBuilder( 39 | settings: settings, 40 | pageBuilder: (context, animation, secondaryAnimation) => 41 | widget(context), 42 | transitionsBuilder: 43 | (context, animation, secondaryAnimation, child) { 44 | if (transitionsBuilder != null) { 45 | return transitionsBuilder!( 46 | context, animation, secondaryAnimation, child); 47 | } 48 | return child; 49 | }, 50 | ); 51 | return builder; 52 | } 53 | return MaterialPageRoute(builder: (context) => routeNotFound); 54 | }, 55 | ); 56 | } 57 | } 58 | 59 | class PageNotFound extends StatelessWidget { 60 | const PageNotFound({super.key}); 61 | 62 | @override 63 | Widget build(BuildContext context) { 64 | return const Scaffold( 65 | body: Center( 66 | child: Text('Page not found'), 67 | ), 68 | ); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /lib/src/widget/flutter_getit_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import '../../flutter_getit.dart'; 4 | 5 | class FlutterGetItView extends StatelessWidget { 6 | T get fGetIt => Injector.get(); 7 | const FlutterGetItView({super.key}); 8 | 9 | @override 10 | Widget build(BuildContext context) { 11 | return const Placeholder(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /lib/src/widget/flutter_getit_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import '../../flutter_getit.dart'; 4 | 5 | class FlutterGetItWidget extends StatefulWidget { 6 | const FlutterGetItWidget({ 7 | super.key, 8 | this.name = '', 9 | required this.builder, 10 | this.binds = const [], 11 | this.onDispose, 12 | this.onInit, 13 | }); 14 | 15 | /// The name of the widget 16 | /// 17 | final String name; 18 | 19 | /// The widget builder 20 | /// 21 | final WidgetBuilder builder; 22 | 23 | /// The binds of the widget 24 | /// 25 | final List binds; 26 | 27 | /// The onDispose of the widget 28 | /// 29 | final void Function()? onDispose; 30 | 31 | /// The onInit of the widget 32 | /// 33 | final void Function()? onInit; 34 | 35 | @override 36 | State createState() => _FlutterGetItWidgetState(); 37 | } 38 | 39 | class _FlutterGetItWidgetState extends State { 40 | late final String id; 41 | late final FlutterGetItContainerRegister containerRegister; 42 | 43 | @override 44 | void initState() { 45 | super.initState(); 46 | final FlutterGetItWidget( 47 | :name, 48 | :binds, 49 | ) = widget; 50 | containerRegister = Injector.get(); 51 | 52 | id = '/WIDGET-${name.isEmpty ? widget.hashCode : name}'; 53 | 54 | final moduleAlreadyRegistered = containerRegister.isRegistered(id); 55 | 56 | if (moduleAlreadyRegistered) { 57 | throw Exception('Widget $id already registered'); 58 | } 59 | 60 | containerRegister 61 | ..register( 62 | id, 63 | binds, 64 | ) 65 | ..load(id); 66 | 67 | if (!moduleAlreadyRegistered) { 68 | FGetItLogger.logEnterOnWidget(id); 69 | widget.onInit?.call(); 70 | } 71 | } 72 | 73 | @override 74 | Widget build(BuildContext context) { 75 | return widget.builder(context); 76 | } 77 | 78 | @override 79 | void dispose() { 80 | containerRegister.decrementListener(id); 81 | FGetItLogger.logDisposeWidget( 82 | id, 83 | ); 84 | widget.onDispose?.call(); 85 | containerRegister.unRegister(id); 86 | super.dispose(); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_getit 2 | description: Integrating with 'get_it,' it efficiently manages Flutter project 3 | dependencies, providing robust page control, route management, and module 4 | flexibility 5 | version: 3.0.1 6 | repository: https://github.com/rodrigorahman/getit_flutter 7 | issue_tracker: https://github.com/rodrigorahman/getit_flutter/issues 8 | tags: 9 | - dependency 10 | - package 11 | - version 12 | - pubspec 13 | - management 14 | - dev_dependencies 15 | - dependencies 16 | - pub.dev 17 | - routes 18 | - navigation 19 | - modules 20 | - modularity 21 | 22 | topics: 23 | - dependency-injection 24 | - di 25 | - injection 26 | - router 27 | - routing 28 | 29 | environment: 30 | sdk: ">=3.2.3 <4.0.0" 31 | flutter: ">=3.16.0" 32 | 33 | dependencies: 34 | flutter: 35 | sdk: flutter 36 | get_it: ^7.7.0 37 | 38 | dev_dependencies: 39 | flutter_lints: ^4.0.0 40 | flutter_test: 41 | sdk: flutter 42 | --------------------------------------------------------------------------------