├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── analysis_options.yaml ├── example └── chat_app │ ├── .fvm │ └── fvm_config.json │ ├── .gitignore │ ├── .metadata │ ├── .vscode │ ├── extensions.json │ ├── launch.json │ ├── settings.json │ └── tasks.json │ ├── Makefile │ ├── README.md │ ├── analysis_options.yaml │ ├── android │ ├── .gitignore │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── kotlin │ │ │ │ └── dev │ │ │ │ │ └── plugfox │ │ │ │ │ └── chat │ │ │ │ │ ├── chat_app │ │ │ │ │ └── MainActivity.kt │ │ │ │ │ └── chatapp │ │ │ │ │ └── MainActivity.kt │ │ │ └── res │ │ │ │ ├── drawable-v21 │ │ │ │ └── launch_background.xml │ │ │ │ ├── drawable │ │ │ │ └── launch_background.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── values-night │ │ │ │ └── styles.xml │ │ │ │ └── values │ │ │ │ └── styles.xml │ │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── settings.gradle │ ├── build.yaml │ ├── config │ └── development.json │ ├── ios │ ├── .gitignore │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ └── Release.xcconfig │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ │ └── WorkspaceSettings.xcsettings │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ ├── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ │ ├── Icon-App-20x20@1x.png │ │ │ │ ├── Icon-App-20x20@2x.png │ │ │ │ ├── Icon-App-20x20@3x.png │ │ │ │ ├── Icon-App-29x29@1x.png │ │ │ │ ├── Icon-App-29x29@2x.png │ │ │ │ ├── Icon-App-29x29@3x.png │ │ │ │ ├── Icon-App-40x40@1x.png │ │ │ │ ├── Icon-App-40x40@2x.png │ │ │ │ ├── Icon-App-40x40@3x.png │ │ │ │ ├── Icon-App-60x60@2x.png │ │ │ │ ├── Icon-App-60x60@3x.png │ │ │ │ ├── Icon-App-76x76@1x.png │ │ │ │ ├── Icon-App-76x76@2x.png │ │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ │ └── LaunchImage.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── LaunchImage.png │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ └── README.md │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── Runner-Bridging-Header.h │ └── RunnerTests │ │ └── RunnerTests.swift │ ├── lib │ ├── main.dart │ └── src │ │ ├── common │ │ ├── constant │ │ │ └── pubspec.yaml.g.dart │ │ ├── controller │ │ │ ├── controller.dart │ │ │ ├── controller_observer.dart │ │ │ ├── droppable_controller_concurrency.dart │ │ │ ├── sequential_controller_concurrency.dart │ │ │ ├── state_consumer.dart │ │ │ └── state_controller.dart │ │ ├── localization │ │ │ ├── generated │ │ │ │ ├── intl │ │ │ │ │ ├── messages_all.dart │ │ │ │ │ └── messages_en.dart │ │ │ │ └── l10n.dart │ │ │ ├── intl_en.arb │ │ │ └── localization.dart │ │ ├── util │ │ │ ├── error_util.dart │ │ │ ├── logger_util.dart │ │ │ └── platform │ │ │ │ ├── error_util_js.dart │ │ │ │ └── error_util_vm.dart │ │ └── widget │ │ │ ├── app.dart │ │ │ ├── radial_progress_indicator.dart │ │ │ └── window_scope.dart │ │ └── feature │ │ └── dependencies │ │ ├── initialization │ │ ├── initialization.dart │ │ ├── initialize_dependencies.dart │ │ └── platform │ │ │ ├── initialization_js.dart │ │ │ └── initialization_vm.dart │ │ ├── model │ │ └── dependencies.dart │ │ └── widget │ │ ├── dependencies_scope.dart │ │ └── initialization_splash_screen.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 │ ├── 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 │ ├── tool │ └── makefile │ │ ├── pub.mk │ │ ├── setup.mk │ │ └── test.mk │ ├── 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 ├── lib └── chat.dart ├── pubspec.lock ├── pubspec.yaml └── test └── test.dart /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | **/doc/api/ 26 | **/ios/Flutter/.last_build_id 27 | .dart_tool/ 28 | .flutter-plugins 29 | .flutter-plugins-dependencies 30 | .packages 31 | .pub-cache/ 32 | .pub/ 33 | /build/ 34 | 35 | # Symbolication related 36 | app.*.symbols 37 | 38 | # Obfuscation related 39 | app.*.map.json 40 | 41 | # Android Studio will place build artifacts here 42 | /android/app/debug 43 | /android/app/profile 44 | /android/app/release 45 | 46 | # Databases 47 | .sqlite 48 | .db 49 | .lock 50 | 51 | # Logs 52 | log.txt 53 | 54 | # Emulator 55 | emulator/ 56 | 57 | # Temporary files 58 | temp/ 59 | .temp/ 60 | 61 | # Env 62 | .env* 63 | 64 | # Test 65 | coverage/ 66 | 67 | # Flutter Version Manager 68 | .fvm/flutter_sdk 69 | 70 | # Generated files 71 | 72 | # Screenshots 73 | integration_test/screenshots/ 74 | 75 | # Firebase 76 | .firebase/ -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.0.1-dev.placeholder 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Dual License Agreement 2 | 3 | This software ("The Package") is dual-licensed under both an open-source license and a commercial license. 4 | 5 | 1. Open-Source License 6 | 7 | For open-source projects that are distributed free of charge, The Package may be used under the terms of the MIT License, a copy of which can be found at https://opensource.org/licenses/MIT. By using The Package in an open-source project, you agree to the terms and conditions of the MIT License. 8 | 9 | 2. Commercial License 10 | 11 | For commercial projects, a separate commercial license must be purchased from the author. Commercial use of The Package without obtaining a valid commercial license from the author is strictly prohibited. To inquire about purchasing a commercial license, please contact the author at plugfox@gmail.com. 12 | 13 | The author reserves the right to change the terms of this dual license agreement at any time, without prior notice. By using The Package, you agree to be bound by the terms of this dual license agreement. 14 | 15 | Copyright (c) 2023 Matiunin Mikhail. All rights reserved. 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Chat 2 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | #include: package:flutter_lints/flutter.yaml 2 | 3 | # Analyzer options 4 | analyzer: 5 | # Exclude files from analysis. Must be relative to the root of the package. 6 | exclude: 7 | # Build 8 | - "build/**" 9 | # Tests 10 | - "test/**.mocks.dart" 11 | - ".test_coverage.dart" 12 | - "coverage/**" 13 | # Assets 14 | - "assets/**" 15 | # Flutter Version Manager 16 | - ".fvm/**" 17 | # Tools 18 | #- "tool/**" 19 | - "scripts/**" 20 | - ".dart_tool/**" 21 | # Platform 22 | - "ios/**" 23 | - "android/**" 24 | - "web/**" 25 | - "macos/**" 26 | - "windows/**" 27 | - "linux/**" 28 | 29 | 30 | # Enable the following options to enable strong mode. 31 | language: 32 | strict-casts: true 33 | strict-raw-types: true 34 | strict-inference: true 35 | 36 | # Enable the following options to enable new language features. 37 | #enable-experiment: 38 | # - patterns 39 | # - sealed-class 40 | # - records 41 | # - class-modifiers 42 | # - macros 43 | # - const-functions 44 | # - extension-types 45 | # - inference-update-2 46 | # - inline-class 47 | # - value-class 48 | # - variance 49 | 50 | # Set the following options to true to enable additional analysis. 51 | errors: 52 | # Info 53 | directives_ordering: info 54 | always_declare_return_types: info 55 | 56 | # Warning 57 | unsafe_html: warning 58 | no_logic_in_create_state: warning 59 | empty_catches: warning 60 | close_sinks: warning 61 | 62 | # Error 63 | always_use_package_imports: error 64 | avoid_relative_lib_imports: error 65 | avoid_slow_async_io: error 66 | avoid_types_as_parameter_names: error 67 | cancel_subscriptions: error 68 | valid_regexps: error 69 | always_require_non_null_named_parameters: error 70 | 71 | # Disable rules 72 | 73 | # Lint rules 74 | linter: 75 | rules: 76 | # Public packages 77 | public_member_api_docs: false 78 | lines_longer_than_80_chars: false 79 | 80 | # Enabling rules 81 | always_use_package_imports: true 82 | avoid_relative_lib_imports: true 83 | 84 | # Disable rules 85 | sort_pub_dependencies: false 86 | prefer_relative_imports: false 87 | curly_braces_in_flow_control_structures: false -------------------------------------------------------------------------------- /example/chat_app/.fvm/fvm_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "flutterSdkVersion": "3.10.5", 3 | "flavors": {} 4 | } 5 | -------------------------------------------------------------------------------- /example/chat_app/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | **/doc/api/ 26 | **/ios/Flutter/.last_build_id 27 | .dart_tool/ 28 | .flutter-plugins 29 | .flutter-plugins-dependencies 30 | .packages 31 | .pub-cache/ 32 | .pub/ 33 | /build/ 34 | 35 | # Symbolication related 36 | app.*.symbols 37 | 38 | # Obfuscation related 39 | app.*.map.json 40 | 41 | # Android Studio will place build artifacts here 42 | /android/app/debug 43 | /android/app/profile 44 | /android/app/release 45 | 46 | # Databases 47 | .sqlite 48 | .db 49 | .lock 50 | 51 | # Logs 52 | log.txt 53 | 54 | # Emulator 55 | emulator/ 56 | 57 | # Temporary files 58 | temp/ 59 | .temp/ 60 | 61 | # Env 62 | .env* 63 | 64 | # Test 65 | coverage/ 66 | 67 | # Flutter Version Manager 68 | .fvm/flutter_sdk 69 | 70 | # Generated files 71 | 72 | # Screenshots 73 | integration_test/screenshots/ 74 | 75 | # Firebase 76 | .firebase/ 77 | 78 | -------------------------------------------------------------------------------- /example/chat_app/.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. 5 | 6 | version: 7 | revision: 74e4b092e5212ebf8292dde2a48d3da960c0920b 8 | channel: beta 9 | 10 | project_type: app 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: 74e4b092e5212ebf8292dde2a48d3da960c0920b 17 | base_revision: 74e4b092e5212ebf8292dde2a48d3da960c0920b 18 | - platform: android 19 | create_revision: 74e4b092e5212ebf8292dde2a48d3da960c0920b 20 | base_revision: 74e4b092e5212ebf8292dde2a48d3da960c0920b 21 | - platform: ios 22 | create_revision: 74e4b092e5212ebf8292dde2a48d3da960c0920b 23 | base_revision: 74e4b092e5212ebf8292dde2a48d3da960c0920b 24 | - platform: linux 25 | create_revision: 74e4b092e5212ebf8292dde2a48d3da960c0920b 26 | base_revision: 74e4b092e5212ebf8292dde2a48d3da960c0920b 27 | - platform: macos 28 | create_revision: 74e4b092e5212ebf8292dde2a48d3da960c0920b 29 | base_revision: 74e4b092e5212ebf8292dde2a48d3da960c0920b 30 | - platform: web 31 | create_revision: 74e4b092e5212ebf8292dde2a48d3da960c0920b 32 | base_revision: 74e4b092e5212ebf8292dde2a48d3da960c0920b 33 | - platform: windows 34 | create_revision: 74e4b092e5212ebf8292dde2a48d3da960c0920b 35 | base_revision: 74e4b092e5212ebf8292dde2a48d3da960c0920b 36 | 37 | # User provided section 38 | 39 | # List of Local paths (relative to this file) that should be 40 | # ignored by the migrate tool. 41 | # 42 | # Files that are not part of the templates will be ignored by default. 43 | unmanaged_files: 44 | - 'lib/main.dart' 45 | - 'ios/Runner.xcodeproj/project.pbxproj' 46 | -------------------------------------------------------------------------------- /example/chat_app/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": ["dart-code.dart-code", "Dart-Code.flutter"] 3 | } 4 | -------------------------------------------------------------------------------- /example/chat_app/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "develop", 6 | "program": "lib/main.dart", 7 | "request": "launch", 8 | "type": "dart", 9 | "flutterMode": "debug", 10 | "env": { 11 | "ENVIRONMENT": "develop" 12 | }, 13 | "args": [ 14 | "--dart-define-from-file=config/development.json", 15 | /* "--enable-experiment=sealed-class,records,patterns,class-modifiers", */ 16 | "--dart-define=ENVIRONMENT=development", 17 | "--web-renderer=html" 18 | ] 19 | } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /example/chat_app/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "[dart]": { 3 | "editor.insertSpaces": true, 4 | "editor.tabSize": 2, 5 | "editor.suggest.snippetsPreventQuickSuggestions": false, 6 | "editor.suggestSelection": "first", 7 | "editor.tabCompletion": "onlySnippets", 8 | "editor.wordBasedSuggestions": false, 9 | "editor.selectionHighlight": false, 10 | "editor.defaultFormatter": "Dart-Code.dart-code", 11 | "editor.formatOnSave": true, 12 | "editor.formatOnType": true, 13 | "editor.formatOnPaste": true, 14 | "editor.codeActionsOnSave": { 15 | "source.fixAll": true, 16 | "source.organizeImports": true 17 | }, 18 | "editor.quickSuggestions": { 19 | "comments": "on", 20 | "strings": "on", 21 | "other": "on" 22 | }, 23 | "editor.links": true, 24 | "editor.rulers": [120] 25 | }, 26 | "dart.lineLength": 120, 27 | "dart.doNotFormat": ["**.g.dart", "**.config.dart", "**.mocks.dart"], 28 | 29 | // Flutter Version Manager 30 | "dart.flutterSdkPath": ".fvm/flutter_sdk", 31 | 32 | // Remove .fvm files from search 33 | "search.exclude": { 34 | //"**/.fvm": true, 35 | ".dart_tool": true, 36 | "coverage": true, 37 | "build": true 38 | }, 39 | 40 | // Remove from file watching 41 | "files.watcherExclude": { 42 | "**/.fvm": true, 43 | ".dart_tool": true, 44 | "coverage": true, 45 | "build": true 46 | }, 47 | 48 | // Causes the debug view to automatically appear when a breakpoint is hit. This 49 | // setting is global and not configurable per-language. 50 | "debug.openDebug": "openOnDebugBreak", 51 | "explorer.fileNesting.enabled": true, 52 | "explorer.fileNesting.expand": false, 53 | "explorer.fileNesting.patterns": { 54 | "pubspec.yaml": ".flutter-plugins, .packages, .dart_tool, .flutter-plugins-dependencies, .metadata, .packages, pubspec.lock, build.yaml, analysis_options.yaml, all_lint_rules.yaml, dart*.yaml, flutter*.yaml, icons_launcher.yaml", 55 | ".gitignore": ".gitattributes, .gitmodules, .gitmessage, .mailmap, .git-blame*", 56 | "readme.*": "authors, backers.md, changelog*, citation*, code_of_conduct.md, codeowners, contributing.md, contributors, copying, credits, governance.md, history.md, license*, maintainers, readme*, security.md, sponsors.md", 57 | "*.dart": "$(capture).g.dart, $(capture).freezed.dart, $(capture).config.dart" 58 | }, 59 | "files.associations": { 60 | "*.drift": "sql" 61 | }, 62 | "highlight.regexes": { 63 | "(\"@\\s*.+\":\\s{0,1}{},)": { 64 | "filterFileRegex": ".*\\.arb", 65 | "decorations": [ 66 | { 67 | "overviewRulerColor": "#d19a66", 68 | "backgroundColor": "#d19a66", 69 | "color": "#282c34", 70 | "fontWeight": "bold" 71 | } 72 | ] 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /example/chat_app/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "windows": {}, 4 | "tasks": [ 5 | { 6 | "label": "Dependencies", 7 | "type": "shell", 8 | "command": ["fvm flutter pub get"], 9 | "group": { 10 | "kind": "none", 11 | "isDefault": true 12 | }, 13 | "problemMatcher": [] 14 | }, 15 | { 16 | "label": "Codegeneration", 17 | "type": "shell", 18 | "dependsOn": ["Dependencies"], 19 | "command": [ 20 | "fvm flutter pub run build_runner build --delete-conflicting-outputs" 21 | ], 22 | "group": { 23 | "kind": "none", 24 | "isDefault": true 25 | }, 26 | "problemMatcher": [] 27 | } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /example/chat_app/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: help 2 | 3 | # Script description and usage through `make` or `make help` commands 4 | help: 5 | @echo "Let's make something good" 6 | @fvm flutter --version 7 | 8 | -include tool/makefile/pub.mk tool/makefile/test.mk tool/makefile/setup.mk -------------------------------------------------------------------------------- /example/chat_app/README.md: -------------------------------------------------------------------------------- 1 | # Chat App 2 | 3 | ## Code generation 4 | 5 | ```bash 6 | $ make codegen 7 | ``` 8 | 9 | ## Localization 10 | 11 | ```bash 12 | $ code lib/src/common/localization/intl_en.arb 13 | $ make intl 14 | ``` 15 | 16 | ## Recreating the project 17 | 18 | **! Warning: This will overwrite all files in the current directory.** 19 | 20 | ```bash 21 | fvm spawn beta create --overwrite -t app --project-name "chatapp" --org "dev.plugfox.chat" --description "The Chat App" --platforms ios,android,windows,linux,macos,web . 22 | ``` 23 | -------------------------------------------------------------------------------- /example/chat_app/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:flutter_lints/flutter.yaml 2 | 3 | # Analyzer options 4 | analyzer: 5 | # Exclude files from analysis. Must be relative to the root of the package. 6 | exclude: 7 | # Build 8 | - "build/**" 9 | # Tests 10 | - "test/**.mocks.dart" 11 | - ".test_coverage.dart" 12 | - "coverage/**" 13 | # Assets 14 | - "assets/**" 15 | # Generated 16 | - "lib/src/common/localization/generated/**" 17 | - "lib/src/common/constants/pubspec.yaml.g.dart" 18 | - "lib/src/common/model/generated/**" 19 | - "**.g.dart" 20 | - "**.gql.dart" 21 | - "**.freezed.dart" 22 | - "**.config.dart" 23 | - "**.mocks.dart" 24 | - "**.gen.dart" 25 | - "**.pb.dart" 26 | - "**.pbenum.dart" 27 | - "**.pbjson.dart" 28 | # Flutter Version Manager 29 | - ".fvm/**" 30 | # Tools 31 | #- "tool/**" 32 | - "scripts/**" 33 | - ".dart_tool/**" 34 | # Platform 35 | - "ios/**" 36 | - "android/**" 37 | - "web/**" 38 | - "macos/**" 39 | - "windows/**" 40 | - "linux/**" 41 | 42 | 43 | # Enable the following options to enable strong mode. 44 | language: 45 | strict-casts: true 46 | strict-raw-types: true 47 | strict-inference: true 48 | 49 | # Enable the following options to enable new language features. 50 | #enable-experiment: 51 | # - patterns 52 | # - sealed-class 53 | # - records 54 | # - class-modifiers 55 | # - macros 56 | # - const-functions 57 | # - extension-types 58 | # - inference-update-2 59 | # - inline-class 60 | # - value-class 61 | # - variance 62 | 63 | # Set the following options to true to enable additional analysis. 64 | errors: 65 | # Info 66 | directives_ordering: info 67 | always_declare_return_types: info 68 | 69 | # Warning 70 | unsafe_html: warning 71 | no_logic_in_create_state: warning 72 | empty_catches: warning 73 | close_sinks: warning 74 | 75 | # Error 76 | always_use_package_imports: error 77 | avoid_relative_lib_imports: error 78 | avoid_slow_async_io: error 79 | avoid_types_as_parameter_names: error 80 | cancel_subscriptions: error 81 | valid_regexps: error 82 | always_require_non_null_named_parameters: error 83 | 84 | # Disable rules 85 | 86 | # Lint rules 87 | linter: 88 | rules: 89 | # Public packages 90 | public_member_api_docs: false 91 | lines_longer_than_80_chars: false 92 | 93 | # Enabling rules 94 | always_use_package_imports: true 95 | avoid_relative_lib_imports: true 96 | 97 | # Disable rules 98 | sort_pub_dependencies: false 99 | prefer_relative_imports: false 100 | curly_braces_in_flow_control_structures: false -------------------------------------------------------------------------------- /example/chat_app/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /example/chat_app/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "com.android.application" 3 | id "kotlin-android" 4 | id "dev.flutter.flutter-gradle-plugin" 5 | } 6 | 7 | def localProperties = new Properties() 8 | def localPropertiesFile = rootProject.file('local.properties') 9 | if (localPropertiesFile.exists()) { 10 | localPropertiesFile.withReader('UTF-8') { reader -> 11 | localProperties.load(reader) 12 | } 13 | } 14 | 15 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 16 | if (flutterVersionCode == null) { 17 | flutterVersionCode = '1' 18 | } 19 | 20 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 21 | if (flutterVersionName == null) { 22 | flutterVersionName = '1.0' 23 | } 24 | 25 | android { 26 | namespace "dev.plugfox.chat.chatapp" 27 | compileSdkVersion flutter.compileSdkVersion 28 | ndkVersion flutter.ndkVersion 29 | 30 | compileOptions { 31 | sourceCompatibility JavaVersion.VERSION_1_8 32 | targetCompatibility JavaVersion.VERSION_1_8 33 | } 34 | 35 | kotlinOptions { 36 | jvmTarget = '1.8' 37 | } 38 | 39 | sourceSets { 40 | main.java.srcDirs += 'src/main/kotlin' 41 | } 42 | 43 | defaultConfig { 44 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 45 | applicationId "dev.plugfox.chat.chatapp" 46 | // You can update the following values to match your application needs. 47 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. 48 | minSdkVersion flutter.minSdkVersion 49 | targetSdkVersion flutter.targetSdkVersion 50 | versionCode flutterVersionCode.toInteger() 51 | versionName flutterVersionName 52 | } 53 | 54 | buildTypes { 55 | release { 56 | // TODO: Add your own signing config for the release build. 57 | // Signing with the debug keys for now, so `flutter run --release` works. 58 | signingConfig signingConfigs.debug 59 | } 60 | } 61 | } 62 | 63 | flutter { 64 | source '../..' 65 | } 66 | 67 | dependencies { 68 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 69 | } 70 | -------------------------------------------------------------------------------- /example/chat_app/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/chat_app/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 14 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | 29 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /example/chat_app/android/app/src/main/kotlin/dev/plugfox/chat/chat_app/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package dev.plugfox.chat.chatapp 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /example/chat_app/android/app/src/main/kotlin/dev/plugfox/chat/chatapp/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package dev.plugfox.chat.chatapp 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /example/chat_app/android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/chat_app/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/chat_app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/chat_app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/chat_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/chat_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/chat_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/chat_app/android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/chat_app/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/chat_app/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/chat_app/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.7.10' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.3.0' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | mavenCentral() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | tasks.register("clean", Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /example/chat_app/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /example/chat_app/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip 6 | -------------------------------------------------------------------------------- /example/chat_app/android/settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | def flutterSdkPath = { 3 | def properties = new Properties() 4 | file("local.properties").withInputStream { properties.load(it) } 5 | def flutterSdkPath = properties.getProperty("flutter.sdk") 6 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 7 | return flutterSdkPath 8 | } 9 | settings.ext.flutterSdkPath = flutterSdkPath() 10 | 11 | includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle") 12 | 13 | plugins { 14 | id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false 15 | } 16 | } 17 | 18 | include ":app" 19 | 20 | apply from: "${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle/app_plugin_loader.gradle" 21 | -------------------------------------------------------------------------------- /example/chat_app/build.yaml: -------------------------------------------------------------------------------- 1 | targets: 2 | $default: 3 | sources: 4 | - $package$ 5 | - lib/** 6 | - pubspec.yaml 7 | - test/** 8 | builders: 9 | pubspec_generator: 10 | options: 11 | output: lib/src/common/constant/pubspec.yaml.g.dart 12 | -------------------------------------------------------------------------------- /example/chat_app/config/development.json: -------------------------------------------------------------------------------- 1 | { 2 | "ENVIRONMENT": "development" 3 | } 4 | -------------------------------------------------------------------------------- /example/chat_app/ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /example/chat_app/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 11.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/chat_app/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/chat_app/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/chat_app/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/chat_app/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/chat_app/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/chat_app/ios/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/chat_app/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/chat_app/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/chat_app/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/chat_app/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /example/chat_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example/chat_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/chat_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/chat_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/chat_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /example/chat_app/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /example/chat_app/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/chat_app/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Chat App 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | chatapp 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UIViewControllerBasedStatusBarAppearance 45 | 46 | CADisableMinimumFrameDurationOnPhone 47 | 48 | UIApplicationSupportsIndirectInputEvents 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /example/chat_app/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /example/chat_app/ios/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /example/chat_app/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:chatapp/src/common/util/logger_util.dart'; 4 | import 'package:chatapp/src/common/widget/app.dart'; 5 | import 'package:chatapp/src/feature/dependencies/initialization/initialization.dart'; 6 | import 'package:chatapp/src/feature/dependencies/widget/dependencies_scope.dart'; 7 | import 'package:chatapp/src/feature/dependencies/widget/initialization_splash_screen.dart'; 8 | import 'package:flutter/widgets.dart'; 9 | import 'package:l/l.dart'; 10 | 11 | void main() => l.capture( 12 | () => runZonedGuarded( 13 | () { 14 | final initialization = InitializationExecutor(); 15 | runApp( 16 | DependenciesScope( 17 | initialization: initialization(), 18 | splashScreen: InitializationSplashScreen( 19 | progress: initialization, 20 | ), 21 | child: const App(), 22 | ), 23 | ); 24 | }, 25 | l.e, 26 | ), 27 | const LogOptions( 28 | handlePrint: true, 29 | messageFormatting: LoggerUtil.messageFormatting, 30 | outputInRelease: false, 31 | printColors: true, 32 | ), 33 | ); 34 | -------------------------------------------------------------------------------- /example/chat_app/lib/src/common/controller/controller.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/foundation.dart' show Listenable, ChangeNotifier; 4 | import 'package:meta/meta.dart'; 5 | 6 | /// {@template controller} 7 | /// The controller responsible for processing the logic, 8 | /// the connection of widgets and the date of the layer. 9 | /// {@endtemplate} 10 | abstract interface class IController implements Listenable { 11 | /// Whether the controller is currently handling a requests 12 | bool get isProcessing; 13 | 14 | /// Discards any resources used by the object. 15 | /// 16 | /// This method should only be called by the object's owner. 17 | void dispose(); 18 | } 19 | 20 | /// Controller observer 21 | abstract interface class IControllerObserver { 22 | /// Called when the controller is created. 23 | void onCreate(IController controller); 24 | 25 | /// Called when the controller is disposed. 26 | void onDispose(IController controller); 27 | 28 | /// Called on any state change in the controller. 29 | void onStateChanged(IController controller, Object prevState, Object nextState); 30 | 31 | /// Called on any error in the controller. 32 | void onError(IController controller, Object error, StackTrace stackTrace); 33 | } 34 | 35 | /// {@template controller} 36 | abstract base class Controller with ChangeNotifier implements IController { 37 | Controller() { 38 | runZonedGuarded( 39 | () => Controller.observer?.onCreate(this), 40 | (error, stackTrace) {/* ignore */}, 41 | ); 42 | } 43 | 44 | /// Controller observer 45 | static IControllerObserver? observer; 46 | 47 | bool get isDisposed => _$isDisposed; 48 | bool _$isDisposed = false; 49 | 50 | @protected 51 | void onError(Object error, StackTrace stackTrace) => runZonedGuarded( 52 | () => Controller.observer?.onError(this, error, stackTrace), 53 | (error, stackTrace) {/* ignore */}, 54 | ); 55 | 56 | @protected 57 | void handle(FutureOr Function() handler); 58 | 59 | @override 60 | @mustCallSuper 61 | void dispose() { 62 | _$isDisposed = true; 63 | runZonedGuarded( 64 | () => Controller.observer?.onDispose(this), 65 | (error, stackTrace) {/* ignore */}, 66 | ); 67 | super.dispose(); 68 | } 69 | 70 | @protected 71 | @nonVirtual 72 | @override 73 | void notifyListeners() => super.notifyListeners(); 74 | } 75 | -------------------------------------------------------------------------------- /example/chat_app/lib/src/common/controller/controller_observer.dart: -------------------------------------------------------------------------------- 1 | import 'package:chatapp/src/common/controller/controller.dart'; 2 | import 'package:l/l.dart'; 3 | 4 | class ControllerObserver implements IControllerObserver { 5 | @override 6 | void onCreate(IController controller) { 7 | l.v6('Controller | ${controller.runtimeType} | Created'); 8 | } 9 | 10 | @override 11 | void onDispose(IController controller) { 12 | l.v5('Controller | ${controller.runtimeType} | Disposed'); 13 | } 14 | 15 | @override 16 | void onStateChanged(IController controller, Object prevState, Object nextState) { 17 | l.d('Controller | ${controller.runtimeType} | $prevState -> $nextState'); 18 | } 19 | 20 | @override 21 | void onError(IController controller, Object error, StackTrace stackTrace) { 22 | l.w('Controller | ${controller.runtimeType} | $error', stackTrace); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /example/chat_app/lib/src/common/controller/droppable_controller_concurrency.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:chatapp/src/common/controller/controller.dart'; 4 | import 'package:meta/meta.dart'; 5 | 6 | base mixin DroppableControllerConcurrency on Controller { 7 | @override 8 | @nonVirtual 9 | bool get isProcessing => _$processingCalls > 0; 10 | int _$processingCalls = 0; 11 | 12 | @override 13 | @protected 14 | @mustCallSuper 15 | void handle( 16 | FutureOr Function() handler, [ 17 | FutureOr Function()? errorHandler, 18 | FutureOr Function()? doneHandler, 19 | ]) => 20 | runZonedGuarded( 21 | () async { 22 | if (isDisposed || isProcessing) return; 23 | _$processingCalls++; 24 | try { 25 | await handler(); 26 | } on Object catch (error, stackTrace) { 27 | onError(error, stackTrace); 28 | await Future(() async { 29 | await errorHandler?.call(); 30 | }).catchError(onError); 31 | } finally { 32 | await Future(() async { 33 | await doneHandler?.call(); 34 | }).catchError(onError); 35 | _$processingCalls--; 36 | } 37 | }, 38 | onError, 39 | ); 40 | } 41 | -------------------------------------------------------------------------------- /example/chat_app/lib/src/common/controller/sequential_controller_concurrency.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:collection'; 3 | 4 | import 'package:chatapp/src/common/controller/controller.dart'; 5 | import 'package:meta/meta.dart'; 6 | 7 | base mixin SequentialControllerConcurrency on Controller { 8 | final _ControllerEventQueue _eventQueue = _ControllerEventQueue(); 9 | 10 | @override 11 | @nonVirtual 12 | bool get isProcessing => _eventQueue.length > 0; 13 | 14 | @override 15 | @protected 16 | @mustCallSuper 17 | void handle( 18 | FutureOr Function() handler, [ 19 | FutureOr Function()? errorHandler, 20 | FutureOr Function()? doneHandler, 21 | ]) => 22 | _eventQueue.push( 23 | () { 24 | final completer = Completer(); 25 | runZonedGuarded( 26 | () async { 27 | if (isDisposed) return; 28 | try { 29 | await handler(); 30 | } on Object catch (error, stackTrace) { 31 | onError(error, stackTrace); 32 | await Future(() async { 33 | await errorHandler?.call(); 34 | }).catchError(onError); 35 | } finally { 36 | await Future(() async { 37 | await doneHandler?.call(); 38 | }).catchError(onError); 39 | completer.complete(); 40 | } 41 | }, 42 | onError, 43 | ); 44 | return completer.future; 45 | }, 46 | ); 47 | } 48 | 49 | /// {@nodoc} 50 | final class _ControllerEventQueue { 51 | /// {@nodoc} 52 | _ControllerEventQueue(); 53 | 54 | final DoubleLinkedQueue<_SequentialTask> _queue = DoubleLinkedQueue<_SequentialTask>(); 55 | Future? _processing; 56 | bool _isClosed = false; 57 | 58 | /// Event queue length. 59 | /// {@nodoc} 60 | int get length => _queue.length; 61 | 62 | /// Push it at the end of the queue. 63 | /// {@nodoc} 64 | Future push(FutureOr Function() fn) { 65 | final task = _SequentialTask(fn); 66 | _queue.add(task); 67 | _exec(); 68 | return task.future; 69 | } 70 | 71 | /// Mark the queue as closed. 72 | /// The queue will be processed until it's empty. 73 | /// But all new and current events will be rejected with [WSClientClosed]. 74 | /// {@nodoc} 75 | FutureOr close() async { 76 | _isClosed = true; 77 | await _processing; 78 | } 79 | 80 | /// Execute the queue. 81 | /// {@nodoc} 82 | void _exec() => _processing ??= Future.doWhile(() async { 83 | final event = _queue.first; 84 | try { 85 | if (_isClosed) { 86 | event.reject(StateError('Controller\'s event queue are disposed'), StackTrace.current); 87 | } else { 88 | await event(); 89 | } 90 | } on Object catch (error, stackTrace) { 91 | /* warning( 92 | error, 93 | stackTrace, 94 | 'Error while processing event "${event.id}"', 95 | ); */ 96 | Future.sync(() => event.reject(error, stackTrace)).ignore(); 97 | } 98 | _queue.removeFirst(); 99 | final isEmpty = _queue.isEmpty; 100 | if (isEmpty) _processing = null; 101 | return !isEmpty; 102 | }); 103 | } 104 | 105 | /// {@nodoc} 106 | class _SequentialTask { 107 | /// {@nodoc} 108 | _SequentialTask(FutureOr Function() fn) 109 | : _fn = fn, 110 | _completer = Completer(); 111 | 112 | /// {@nodoc} 113 | final Completer _completer; 114 | 115 | /// {@nodoc} 116 | final FutureOr Function() _fn; 117 | 118 | /// {@nodoc} 119 | Future get future => _completer.future; 120 | 121 | /// {@nodoc} 122 | FutureOr call() async { 123 | final result = await _fn(); 124 | if (!_completer.isCompleted) { 125 | _completer.complete(result); 126 | } 127 | return result; 128 | } 129 | 130 | /// {@nodoc} 131 | void reject(Object error, [StackTrace? stackTrace]) { 132 | if (_completer.isCompleted) return; 133 | _completer.completeError(error, stackTrace); 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /example/chat_app/lib/src/common/controller/state_consumer.dart: -------------------------------------------------------------------------------- 1 | import 'package:chatapp/src/common/controller/state_controller.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter/scheduler.dart'; 4 | import 'package:flutter/src/foundation/diagnostics.dart'; 5 | 6 | /// Fire when the state changes. 7 | typedef StateConsumerListener = void Function(BuildContext context, S previous, S current); 8 | 9 | /// Build when the method returns true. 10 | typedef StateConsumerCondition = bool Function(S previous, S current); 11 | 12 | /// Rebuild the widget when the state changes. 13 | typedef StateConsumerBuilder = Widget Function(BuildContext context, S state, Widget? child); 14 | 15 | /// {@template state_consumer} 16 | /// StateBuilder widget. 17 | /// {@endtemplate} 18 | class StateConsumer extends StatefulWidget { 19 | /// {@macro state_builder} 20 | const StateConsumer({ 21 | required this.controller, 22 | this.listener, 23 | this.buildWhen, 24 | this.builder, 25 | this.child, 26 | super.key, 27 | }); 28 | 29 | /// The controller responsible for processing the logic, 30 | final IStateController controller; 31 | 32 | /// Takes the `BuildContext` along with the `state` 33 | /// and is responsible for executing in response to `state` changes. 34 | final StateConsumerListener? listener; 35 | 36 | /// Takes the previous `state` and the current `state` and is responsible for 37 | /// returning a [bool] which determines whether or not to trigger 38 | /// [builder] with the current `state`. 39 | final StateConsumerCondition? buildWhen; 40 | 41 | /// The [builder] function which will be invoked on each widget build. 42 | /// The [builder] takes the `BuildContext` and current `state` and 43 | /// must return a widget. 44 | /// This is analogous to the [builder] function in [StreamBuilder]. 45 | final StateConsumerBuilder? builder; 46 | 47 | /// The child widget which will be passed to the [builder]. 48 | final Widget? child; 49 | 50 | @override 51 | State> createState() => _StateConsumerState(); 52 | } 53 | 54 | class _StateConsumerState extends State> { 55 | late IStateController _controller; 56 | late S _previousState; 57 | 58 | @override 59 | void initState() { 60 | super.initState(); 61 | _controller = widget.controller; 62 | _previousState = _controller.state; 63 | _subscribe(); 64 | } 65 | 66 | @override 67 | void didUpdateWidget(StateConsumer oldWidget) { 68 | super.didUpdateWidget(oldWidget); 69 | final oldController = oldWidget.controller, newController = widget.controller; 70 | if (identical(oldController, newController) || oldController == newController) return; 71 | _unsubscribe(); 72 | _controller = newController; 73 | _previousState = newController.state; 74 | _subscribe(); 75 | } 76 | 77 | @override 78 | void dispose() { 79 | _unsubscribe(); 80 | super.dispose(); 81 | } 82 | 83 | void _subscribe() => _controller.addListener(_valueChanged); 84 | 85 | void _unsubscribe() => _controller.removeListener(_valueChanged); 86 | 87 | void _valueChanged() { 88 | final oldState = _previousState, newState = _controller.state; 89 | if (!mounted || identical(oldState, newState)) return; 90 | _previousState = newState; 91 | widget.listener?.call(context, oldState, newState); 92 | if (widget.buildWhen?.call(oldState, newState) ?? true) { 93 | // Rebuild the widget when the state changes. 94 | switch (SchedulerBinding.instance.schedulerPhase) { 95 | case SchedulerPhase.idle: 96 | case SchedulerPhase.transientCallbacks: 97 | case SchedulerPhase.postFrameCallbacks: 98 | setState(() {}); 99 | case SchedulerPhase.persistentCallbacks: 100 | case SchedulerPhase.midFrameMicrotasks: 101 | SchedulerBinding.instance.addPostFrameCallback((_) { 102 | if (!mounted) return; 103 | setState(() {}); 104 | }); 105 | } 106 | } 107 | } 108 | 109 | @override 110 | void debugFillProperties(DiagnosticPropertiesBuilder properties) => super.debugFillProperties(properties 111 | ..add(DiagnosticsProperty>('Controller', _controller)) 112 | ..add(DiagnosticsProperty('State', _controller.state)) 113 | ..add(FlagProperty('isProcessing', value: _controller.isProcessing, ifTrue: 'Processing', ifFalse: 'Idle'))); 114 | 115 | @override 116 | Widget build(BuildContext context) => 117 | widget.builder?.call(context, _controller.state, widget.child) ?? widget.child ?? const SizedBox.shrink(); 118 | } 119 | -------------------------------------------------------------------------------- /example/chat_app/lib/src/common/controller/state_controller.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:chatapp/src/common/controller/controller.dart'; 4 | import 'package:flutter/foundation.dart'; 5 | 6 | /// State controller 7 | abstract interface class IStateController implements IController { 8 | /// The current state of the controller. 9 | State get state; 10 | } 11 | 12 | /// State controller 13 | abstract base class StateController extends Controller implements IStateController { 14 | /// State controller 15 | StateController({required State initialState}) : _$state = initialState; 16 | 17 | @override 18 | @nonVirtual 19 | State get state => _$state; 20 | State _$state; 21 | 22 | @protected 23 | @nonVirtual 24 | void setState(State state) { 25 | runZonedGuarded( 26 | () => Controller.observer?.onStateChanged(this, _$state, state), 27 | (error, stackTrace) {/* ignore */}, 28 | ); 29 | _$state = state; 30 | if (isDisposed) return; 31 | notifyListeners(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /example/chat_app/lib/src/common/localization/generated/intl/messages_all.dart: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. This is code generated via package:intl/generate_localized.dart 2 | // This is a library that looks up messages for specific locales by 3 | // delegating to the appropriate library. 4 | 5 | // Ignore issues from commonly used lints in this file. 6 | // ignore_for_file:implementation_imports, file_names, unnecessary_new 7 | // ignore_for_file:unnecessary_brace_in_string_interps, directives_ordering 8 | // ignore_for_file:argument_type_not_assignable, invalid_assignment 9 | // ignore_for_file:prefer_single_quotes, prefer_generic_function_type_aliases 10 | // ignore_for_file:comment_references 11 | 12 | import 'dart:async'; 13 | 14 | import 'package:flutter/foundation.dart'; 15 | import 'package:intl/intl.dart'; 16 | import 'package:intl/message_lookup_by_library.dart'; 17 | import 'package:intl/src/intl_helpers.dart'; 18 | 19 | import 'messages_en.dart' as messages_en; 20 | 21 | typedef Future LibraryLoader(); 22 | Map _deferredLibraries = { 23 | 'en': () => new SynchronousFuture(null), 24 | }; 25 | 26 | MessageLookupByLibrary? _findExact(String localeName) { 27 | switch (localeName) { 28 | case 'en': 29 | return messages_en.messages; 30 | default: 31 | return null; 32 | } 33 | } 34 | 35 | /// User programs should call this before using [localeName] for messages. 36 | Future initializeMessages(String localeName) { 37 | var availableLocale = Intl.verifiedLocale( 38 | localeName, (locale) => _deferredLibraries[locale] != null, 39 | onFailure: (_) => null); 40 | if (availableLocale == null) { 41 | return new SynchronousFuture(false); 42 | } 43 | var lib = _deferredLibraries[availableLocale]; 44 | lib == null ? new SynchronousFuture(false) : lib(); 45 | initializeInternalMessageLookup(() => new CompositeMessageLookup()); 46 | messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor); 47 | return new SynchronousFuture(true); 48 | } 49 | 50 | bool _messagesExistFor(String locale) { 51 | try { 52 | return _findExact(locale) != null; 53 | } catch (e) { 54 | return false; 55 | } 56 | } 57 | 58 | MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) { 59 | var actualLocale = 60 | Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null); 61 | if (actualLocale == null) return null; 62 | return _findExact(actualLocale); 63 | } 64 | -------------------------------------------------------------------------------- /example/chat_app/lib/src/common/localization/generated/intl/messages_en.dart: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. This is code generated via package:intl/generate_localized.dart 2 | // This is a library that provides messages for a en locale. All the 3 | // messages from the main program should be duplicated here with the same 4 | // function name. 5 | 6 | // Ignore issues from commonly used lints in this file. 7 | // ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new 8 | // ignore_for_file:prefer_single_quotes,comment_references, directives_ordering 9 | // ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases 10 | // ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes 11 | // ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes 12 | 13 | import 'package:intl/intl.dart'; 14 | import 'package:intl/message_lookup_by_library.dart'; 15 | 16 | final messages = new MessageLookup(); 17 | 18 | typedef String MessageIfAbsent(String messageStr, List args); 19 | 20 | class MessageLookup extends MessageLookupByLibrary { 21 | String get localeName => 'en'; 22 | 23 | final messages = _notInlinedMessages(_notInlinedMessages); 24 | static Map _notInlinedMessages(_) => { 25 | "addButton": MessageLookupByLibrary.simpleMessage("Add"), 26 | "addToStarredButton": 27 | MessageLookupByLibrary.simpleMessage("Add to starred"), 28 | "apiDomain": MessageLookupByLibrary.simpleMessage("API domain"), 29 | "appLabel": MessageLookupByLibrary.simpleMessage("App"), 30 | "applicationInformationLabel": 31 | MessageLookupByLibrary.simpleMessage("Application information"), 32 | "applicationLabel": MessageLookupByLibrary.simpleMessage("Application"), 33 | "applicationVersionLabel": 34 | MessageLookupByLibrary.simpleMessage("Application version"), 35 | "authenticateLabel": 36 | MessageLookupByLibrary.simpleMessage("Authenticate"), 37 | "authenticatedLabel": 38 | MessageLookupByLibrary.simpleMessage("Authenticated"), 39 | "authenticationLabel": 40 | MessageLookupByLibrary.simpleMessage("Authentication"), 41 | "backButton": MessageLookupByLibrary.simpleMessage("Back"), 42 | "cancelButton": MessageLookupByLibrary.simpleMessage("Cancel"), 43 | "conectedDevicesLabel": 44 | MessageLookupByLibrary.simpleMessage("Connected devices"), 45 | "confirmButton": MessageLookupByLibrary.simpleMessage("Confirm"), 46 | "continueButton": MessageLookupByLibrary.simpleMessage("Continue"), 47 | "copiedLabel": MessageLookupByLibrary.simpleMessage("Copied"), 48 | "copyButton": MessageLookupByLibrary.simpleMessage("Copy"), 49 | "createButton": MessageLookupByLibrary.simpleMessage("Create"), 50 | "currentLabel": MessageLookupByLibrary.simpleMessage("Current"), 51 | "currentUserLabel": 52 | MessageLookupByLibrary.simpleMessage("Current user"), 53 | "currentVersionLabel": 54 | MessageLookupByLibrary.simpleMessage("Current version"), 55 | "databaseLabel": MessageLookupByLibrary.simpleMessage("Database"), 56 | "dateLabel": MessageLookupByLibrary.simpleMessage("Date"), 57 | "deleteButton": MessageLookupByLibrary.simpleMessage("Delete"), 58 | "downloadButton": MessageLookupByLibrary.simpleMessage("Download"), 59 | "editButton": MessageLookupByLibrary.simpleMessage("Edit"), 60 | "emailLabel": MessageLookupByLibrary.simpleMessage("Email"), 61 | "errAnErrorHasOccurred": 62 | MessageLookupByLibrary.simpleMessage("An error has occurred"), 63 | "errAnExceptionHasOccurred": 64 | MessageLookupByLibrary.simpleMessage("An exception has occurred"), 65 | "errAnUnknownErrorWasReceivedFromTheServer": 66 | MessageLookupByLibrary.simpleMessage( 67 | "An unknown error was received from the server"), 68 | "errAssertionError": 69 | MessageLookupByLibrary.simpleMessage("Assertion error"), 70 | "errBadGateway": MessageLookupByLibrary.simpleMessage("Bad gateway"), 71 | "errBadRequest": MessageLookupByLibrary.simpleMessage("Bad request"), 72 | "errBadStateError": 73 | MessageLookupByLibrary.simpleMessage("Bad state error"), 74 | "errError": MessageLookupByLibrary.simpleMessage("Error"), 75 | "errException": MessageLookupByLibrary.simpleMessage("Exception"), 76 | "errFileSystemException": 77 | MessageLookupByLibrary.simpleMessage("File system error"), 78 | "errForbidden": MessageLookupByLibrary.simpleMessage("Forbidden"), 79 | "errGatewayTimeout": 80 | MessageLookupByLibrary.simpleMessage("Gateway timeout"), 81 | "errInternalServerError": 82 | MessageLookupByLibrary.simpleMessage("Internal server error"), 83 | "errInvalidCredentials": 84 | MessageLookupByLibrary.simpleMessage("Invalid credentials"), 85 | "errInvalidFormat": 86 | MessageLookupByLibrary.simpleMessage("Invalid format"), 87 | "errNotAcceptable": 88 | MessageLookupByLibrary.simpleMessage("Not acceptable"), 89 | "errNotFound": MessageLookupByLibrary.simpleMessage("Not found"), 90 | "errNotImplementedYet": 91 | MessageLookupByLibrary.simpleMessage("Not implemented yet"), 92 | "errRequestTimeout": 93 | MessageLookupByLibrary.simpleMessage("Request timeout"), 94 | "errServiceUnavailable": 95 | MessageLookupByLibrary.simpleMessage("Service unavailable"), 96 | "errSomethingWentWrong": 97 | MessageLookupByLibrary.simpleMessage("Something went wrong"), 98 | "errTimeOutExceeded": 99 | MessageLookupByLibrary.simpleMessage("Time out exceeded"), 100 | "errTooManyRequests": 101 | MessageLookupByLibrary.simpleMessage("Too many requests"), 102 | "errTryAgainLater": 103 | MessageLookupByLibrary.simpleMessage("Please try again later."), 104 | "errUnauthorized": MessageLookupByLibrary.simpleMessage("Unauthorized"), 105 | "errUnimplemented": 106 | MessageLookupByLibrary.simpleMessage("Unimplemented"), 107 | "errUnknownServerError": 108 | MessageLookupByLibrary.simpleMessage("Unknown server error"), 109 | "errUnsupportedOperation": 110 | MessageLookupByLibrary.simpleMessage("Unsupported operation"), 111 | "exitButton": MessageLookupByLibrary.simpleMessage("Exit"), 112 | "helpLabel": MessageLookupByLibrary.simpleMessage("Help"), 113 | "language": MessageLookupByLibrary.simpleMessage("English"), 114 | "languageCode": MessageLookupByLibrary.simpleMessage("en"), 115 | "languageSelectionLabel": 116 | MessageLookupByLibrary.simpleMessage("Language selection"), 117 | "latestVersionLabel": 118 | MessageLookupByLibrary.simpleMessage("Latest version"), 119 | "localeName": MessageLookupByLibrary.simpleMessage("en_US"), 120 | "logInButton": MessageLookupByLibrary.simpleMessage("Log In"), 121 | "logOutButton": MessageLookupByLibrary.simpleMessage("Log Out"), 122 | "logOutDescription": MessageLookupByLibrary.simpleMessage( 123 | "You will be logged out from your account"), 124 | "moveButton": MessageLookupByLibrary.simpleMessage("Move"), 125 | "moveToTrashButton": 126 | MessageLookupByLibrary.simpleMessage("Move to trash"), 127 | "nameLabel": MessageLookupByLibrary.simpleMessage("Name"), 128 | "navigationLabel": MessageLookupByLibrary.simpleMessage("Navigation"), 129 | "removeFromStarredButton": 130 | MessageLookupByLibrary.simpleMessage("Remove from starred"), 131 | "renameButton": MessageLookupByLibrary.simpleMessage("Rename"), 132 | "renewalDateLabel": 133 | MessageLookupByLibrary.simpleMessage("Renewal date"), 134 | "restoreButton": MessageLookupByLibrary.simpleMessage("Restore"), 135 | "saveButton": MessageLookupByLibrary.simpleMessage("Save"), 136 | "selectedLabel": MessageLookupByLibrary.simpleMessage("Selected"), 137 | "shareButton": MessageLookupByLibrary.simpleMessage("Share"), 138 | "shareLinkButton": MessageLookupByLibrary.simpleMessage("Share link"), 139 | "signInButton": MessageLookupByLibrary.simpleMessage("Sign In"), 140 | "signUpButton": MessageLookupByLibrary.simpleMessage("Sign Up"), 141 | "sizeLabel": MessageLookupByLibrary.simpleMessage("Size"), 142 | "statusLabel": MessageLookupByLibrary.simpleMessage("Status"), 143 | "storageLabel": MessageLookupByLibrary.simpleMessage("Storage"), 144 | "surnameLabel": MessageLookupByLibrary.simpleMessage("Surname"), 145 | "timeLabel": MessageLookupByLibrary.simpleMessage("Time"), 146 | "title": MessageLookupByLibrary.simpleMessage("Chat App"), 147 | "typeLabel": MessageLookupByLibrary.simpleMessage("Type"), 148 | "upgradeLabel": MessageLookupByLibrary.simpleMessage("Upgrade"), 149 | "uploadButton": MessageLookupByLibrary.simpleMessage("Upload"), 150 | "usefulLinksLabel": 151 | MessageLookupByLibrary.simpleMessage("Useful links"), 152 | "versionLabel": MessageLookupByLibrary.simpleMessage("Version") 153 | }; 154 | } 155 | -------------------------------------------------------------------------------- /example/chat_app/lib/src/common/localization/intl_en.arb: -------------------------------------------------------------------------------- 1 | { 2 | "@@locale": "en", 3 | "localeName": "en_US", 4 | "languageCode": "en", 5 | "language": "English", 6 | "@ Title": {}, 7 | "title": "Chat App", 8 | "@ ############# Errors #############": {}, 9 | "errSomethingWentWrong": "Something went wrong", 10 | "errError": "Error", 11 | "errException": "Exception", 12 | "errAnErrorHasOccurred": "An error has occurred", 13 | "errAnExceptionHasOccurred": "An exception has occurred", 14 | "errTryAgainLater": "Please try again later.", 15 | "errInvalidFormat": "Invalid format", 16 | "errTimeOutExceeded": "Time out exceeded", 17 | "errInvalidCredentials": "Invalid credentials", 18 | "errUnimplemented": "Unimplemented", 19 | "errNotImplementedYet": "Not implemented yet", 20 | "errUnsupportedOperation": "Unsupported operation", 21 | "errFileSystemException": "File system error", 22 | "errAssertionError": "Assertion error", 23 | "errBadStateError": "Bad state error", 24 | "errBadRequest": "Bad request", 25 | "errUnauthorized": "Unauthorized", 26 | "errForbidden": "Forbidden", 27 | "errNotFound": "Not found", 28 | "errNotAcceptable": "Not acceptable", 29 | "errRequestTimeout": "Request timeout", 30 | "errTooManyRequests": "Too many requests", 31 | "errInternalServerError": "Internal server error", 32 | "errBadGateway": "Bad gateway", 33 | "errServiceUnavailable": "Service unavailable", 34 | "errGatewayTimeout": "Gateway timeout", 35 | "errUnknownServerError": "Unknown server error", 36 | "errAnUnknownErrorWasReceivedFromTheServer": "An unknown error was received from the server", 37 | "@ ############# Buttons #############": {}, 38 | "logOutButton": "Log Out", 39 | "logInButton": "Log In", 40 | "exitButton": "Exit", 41 | "signUpButton": "Sign Up", 42 | "signInButton": "Sign In", 43 | "backButton": "Back", 44 | "cancelButton": "Cancel", 45 | "confirmButton": "Confirm", 46 | "continueButton": "Continue", 47 | "saveButton": "Save", 48 | "createButton": "Create", 49 | "deleteButton": "Delete", 50 | "editButton": "Edit", 51 | "addButton": "Add", 52 | "copyButton": "Copy", 53 | "moveButton": "Move", 54 | "renameButton": "Rename", 55 | "uploadButton": "Upload", 56 | "downloadButton": "Download", 57 | "shareButton": "Share", 58 | "shareLinkButton": "Share link", 59 | "removeFromStarredButton": "Remove from starred", 60 | "addToStarredButton": "Add to starred", 61 | "moveToTrashButton": "Move to trash", 62 | "restoreButton": "Restore", 63 | "@ ############# Labels #############": {}, 64 | "emailLabel": "Email", 65 | "nameLabel": "Name", 66 | "surnameLabel": "Surname", 67 | "languageSelectionLabel": "Language selection", 68 | "upgradeLabel": "Upgrade", 69 | "appLabel": "App", 70 | "applicationLabel": "Application", 71 | "authenticateLabel": "Authenticate", 72 | "authenticatedLabel": "Authenticated", 73 | "authenticationLabel": "Authentication", 74 | "navigationLabel": "Navigation", 75 | "databaseLabel": "Database", 76 | "copiedLabel": "Copied", 77 | "usefulLinksLabel": "Useful links", 78 | "currentVersionLabel": "Current version", 79 | "latestVersionLabel": "Latest version", 80 | "versionLabel": "Version", 81 | "sizeLabel": "Size", 82 | "typeLabel": "Type", 83 | "dateLabel": "Date", 84 | "timeLabel": "Time", 85 | "statusLabel": "Status", 86 | "currentLabel": "Current", 87 | "currentUserLabel": "Current user", 88 | "applicationVersionLabel": "Application version", 89 | "applicationInformationLabel": "Application information", 90 | "conectedDevicesLabel": "Connected devices", 91 | "renewalDateLabel": "Renewal date", 92 | "apiDomain": "API domain", 93 | "storageLabel": "Storage", 94 | "helpLabel": "Help", 95 | "selectedLabel": "Selected", 96 | "@ ############# Descriptions #############": {}, 97 | "logOutDescription": "You will be logged out from your account" 98 | } -------------------------------------------------------------------------------- /example/chat_app/lib/src/common/localization/localization.dart: -------------------------------------------------------------------------------- 1 | import 'package:chatapp/src/common/localization/generated/l10n.dart' as generated 2 | show GeneratedLocalization, AppLocalizationDelegate; 3 | import 'package:flutter/widgets.dart'; 4 | import 'package:meta/meta.dart'; 5 | 6 | /// Localization. 7 | final class Localization extends generated.GeneratedLocalization { 8 | Localization._(this.locale); 9 | 10 | final Locale locale; 11 | 12 | /// Localization delegate. 13 | static const LocalizationsDelegate delegate = _LocalizationView(generated.AppLocalizationDelegate()); 14 | 15 | /// Current localization instance. 16 | static Localization get current => _current; 17 | static late Localization _current; 18 | 19 | /// Get localization instance for the widget structure. 20 | static Localization of(BuildContext context) => switch (Localizations.of(context, Localization)) { 21 | Localization localization => localization, 22 | _ => throw ArgumentError( 23 | 'Out of scope, not found inherited widget ' 24 | 'a Localization of the exact type', 25 | 'out_of_scope', 26 | ), 27 | }; 28 | 29 | /// Get language by code. 30 | static ({String name, String nativeName})? getLanguageByCode(String code) => switch (_isoLangs[code]) { 31 | (String, String) lang => (name: lang.$1, nativeName: lang.$2), 32 | _ => null, 33 | }; 34 | 35 | /// Get supported locales. 36 | static List get supportedLocales => const generated.AppLocalizationDelegate().supportedLocales; 37 | } 38 | 39 | @immutable 40 | final class _LocalizationView extends LocalizationsDelegate { 41 | @literal 42 | const _LocalizationView( 43 | LocalizationsDelegate delegate, 44 | ) : _delegate = delegate; 45 | 46 | final LocalizationsDelegate _delegate; 47 | 48 | @override 49 | bool isSupported(Locale locale) => _delegate.isSupported(locale); 50 | 51 | @override 52 | Future load(Locale locale) => generated.GeneratedLocalization.load(locale) 53 | .then((localization) => Localization._current = Localization._(locale)); 54 | 55 | @override 56 | bool shouldReload(covariant _LocalizationView old) => _delegate.shouldReload(old._delegate); 57 | } 58 | 59 | const Map _isoLangs = { 60 | "ab": ('Abkhaz', 'аҧсуа'), 61 | "aa": ('Afar', 'Afaraf'), 62 | "af": ('Afrikaans', 'Afrikaans'), 63 | "ak": ('Akan', 'Akan'), 64 | "sq": ('Albanian', 'Shqip'), 65 | "am": ('Amharic', 'አማርኛ'), 66 | "ar": ('Arabic', 'العربية'), 67 | "an": ('Aragonese', 'Aragonés'), 68 | "hy": ('Armenian', 'Հայերեն'), 69 | "as": ('Assamese', 'অসমীয়া'), 70 | "av": ('Avaric', 'авар мацӀ, магӀарул мацӀ'), 71 | "ae": ('Avestan', 'avesta'), 72 | "ay": ('Aymara', 'aymar aru'), 73 | "az": ('Azerbaijani', 'azərbaycan dili'), 74 | "bm": ('Bambara', 'bamanankan'), 75 | "ba": ('Bashkir', 'башҡорт теле'), 76 | "eu": ('Basque', 'euskara, euskera'), 77 | "be": ('Belarusian', 'Беларуская'), 78 | "bn": ('Bengali', 'বাংলা'), 79 | "bh": ('Bihari', 'भोजपुरी'), 80 | "bi": ('Bislama', 'Bislama'), 81 | "bs": ('Bosnian', 'bosanski jezik'), 82 | "br": ('Breton', 'brezhoneg'), 83 | "bg": ('Bulgarian', 'български език'), 84 | "my": ('Burmese', 'ဗမာစာ'), 85 | "ca": ('Catalan, Valencian', 'Català'), 86 | "ch": ('Chamorro', 'Chamoru'), 87 | "ce": ('Chechen', 'нохчийн мотт'), 88 | "ny": ('Chichewa, Chewa, Nyanja', 'chiCheŵa, chinyanja'), 89 | "zh": ('Chinese', '中文 (Zhōngwén), 汉语, 漢語'), 90 | "cv": ('Chuvash', 'чӑваш чӗлхи'), 91 | "kw": ('Cornish', 'Kernewek'), 92 | "co": ('Corsican', 'corsu, lingua corsa'), 93 | "cr": ('Cree', 'ᓀᐦᐃᔭᐍᐏᐣ'), 94 | "hr": ('Croatian', 'hrvatski'), 95 | "cs": ('Czech', 'česky, čeština'), 96 | "da": ('Danish', 'dansk'), 97 | "dv": ('Divehi, Dhivehi, Maldivian;', 'ދިވެހި'), 98 | "nl": ('Dutch', 'Nederlands, Vlaams'), 99 | "en": ('English', 'English'), 100 | "eo": ('Esperanto', 'Esperanto'), 101 | "et": ('Estonian', 'eesti, eesti keel'), 102 | "fo": ('Faroese', 'føroyskt'), 103 | "fj": ('Fijian', 'vosa Vakaviti'), 104 | "fi": ('Finnish', 'suomi, suomen kieli'), 105 | "fr": ('French', 'Français'), 106 | "ff": ('Fula, Fulah, Pulaar, Pular', 'Fulfulde, Pulaar, Pular'), 107 | "gl": ('Galician', 'Galego'), 108 | "ka": ('Georgian', 'ქართული'), 109 | "de": ('German', 'Deutsch'), 110 | "el": ('Greek, Modern', 'Ελληνικά'), 111 | "gn": ('Guaraní', 'Avañeẽ'), 112 | "gu": ('Gujarati', 'ગુજરાતી'), 113 | "ht": ('Haitian, Haitian Creole', 'Kreyòl ayisyen'), 114 | "ha": ('Hausa', 'Hausa, هَوُسَ'), 115 | "he": ('Hebrew (modern)', 'עברית'), 116 | "hz": ('Herero', 'Otjiherero'), 117 | "hi": ('Hindi', 'हिन्दी, हिंदी'), 118 | "ho": ('Hiri Motu', 'Hiri Motu'), 119 | "hu": ('Hungarian', 'Magyar'), 120 | "ia": ('Interlingua', 'Interlingua'), 121 | "id": ('Indonesian', 'Bahasa Indonesia'), 122 | "ie": ('Interlingue', 'Interlingue'), 123 | "ga": ('Irish', 'Gaeilge'), 124 | "ig": ('Igbo', 'Asụsụ Igbo'), 125 | "ik": ('Inupiaq', 'Iñupiaq, Iñupiatun'), 126 | "io": ('Ido', 'Ido'), 127 | "is": ('Icelandic', 'Íslenska'), 128 | "it": ('Italian', 'Italiano'), 129 | "iu": ('Inuktitut', 'ᐃᓄᒃᑎᑐᑦ'), 130 | "ja": ('Japanese', '日本語 (にほんご/にっぽんご)'), 131 | "jv": ('Javanese', 'basa Jawa'), 132 | "kl": ('Kalaallisut, Greenlandic', 'kalaallisut, kalaallit oqaasii'), 133 | "kn": ('Kannada', 'ಕನ್ನಡ'), 134 | "kr": ('Kanuri', 'Kanuri'), 135 | "kk": ('Kazakh', 'Қазақ тілі'), 136 | "km": ('Khmer', 'ភាសាខ្មែរ'), 137 | "ki": ('Kikuyu, Gikuyu', 'Gĩkũyũ'), 138 | "rw": ('Kinyarwanda', 'Ikinyarwanda'), 139 | "ky": ('Kirghiz, Kyrgyz', 'кыргыз тили'), 140 | "kv": ('Komi', 'коми кыв'), 141 | "kg": ('Kongo', 'KiKongo'), 142 | "ko": ('Korean', '한국어 (韓國語), 조선말 (朝鮮語)'), 143 | "kj": ('Kwanyama, Kuanyama', 'Kuanyama'), 144 | "la": ('Latin', 'latine, lingua latina'), 145 | "lb": ('Luxembourgish', 'Lëtzebuergesch'), 146 | "lg": ('Luganda', 'Luganda'), 147 | "li": ('Limburgish, Limburgan, Limburger', 'Limburgs'), 148 | "ln": ('Lingala', 'Lingála'), 149 | "lo": ('Lao', 'ພາສາລາວ'), 150 | "lt": ('Lithuanian', 'lietuvių kalba'), 151 | "lu": ('Luba-Katanga', ''), 152 | "lv": ('Latvian', 'latviešu valoda'), 153 | "gv": ('Manx', 'Gaelg, Gailck'), 154 | "mk": ('Macedonian', 'македонски јазик'), 155 | "mg": ('Malagasy', 'Malagasy fiteny'), 156 | "ml": ('Malayalam', 'മലയാളം'), 157 | "mt": ('Maltese', 'Malti'), 158 | "mi": ('Māori', 'te reo Māori'), 159 | "mr": ('Marathi (Marāṭhī)', 'मराठी'), 160 | "mh": ('Marshallese', 'Kajin M̧ajeļ'), 161 | "mn": ('Mongolian', 'монгол'), 162 | "na": ('Nauru', 'Ekakairũ Naoero'), 163 | "nb": ('Norwegian Bokmål', 'Norsk bokmål'), 164 | "nd": ('North Ndebele', 'isiNdebele'), 165 | "ne": ('Nepali', 'नेपाली'), 166 | "ng": ('Ndonga', 'Owambo'), 167 | "nn": ('Norwegian Nynorsk', 'Norsk nynorsk'), 168 | "no": ('Norwegian', 'Norsk'), 169 | "ii": ('Nuosu', 'ꆈꌠ꒿ Nuosuhxop'), 170 | "nr": ('South Ndebele', 'isiNdebele'), 171 | "oc": ('Occitan', 'Occitan'), 172 | "oj": ('Ojibwe, Ojibwa', 'ᐊᓂᔑᓈᐯᒧᐎᓐ'), 173 | "om": ('Oromo', 'Afaan Oromoo'), 174 | "or": ('Oriya', 'ଓଡ଼ିଆ'), 175 | "pi": ('Pāli', 'पाऴि'), 176 | "fa": ('Persian', 'فارسی'), 177 | "pl": ('Polish', 'Polski'), 178 | "ps": ('Pashto, Pushto', 'پښتو'), 179 | "pt": ('Portuguese', 'Português'), 180 | "qu": ('Quechua', 'Runa Simi, Kichwa'), 181 | "rm": ('Romansh', 'rumantsch grischun'), 182 | "rn": ('Kirundi', 'kiRundi'), 183 | "ro": ('Romanian, Moldavian, Moldovan', 'română'), 184 | "ru": ('Russian', 'Русский'), 185 | "sa": ('Sanskrit (Saṁskṛta)', 'संस्कृतम्'), 186 | "sc": ('Sardinian', 'sardu'), 187 | "se": ('Northern Sami', 'Davvisámegiella'), 188 | "sm": ('Samoan', 'gagana faa Samoa'), 189 | "sg": ('Sango', 'yângâ tî sängö'), 190 | "sr": ('Serbian', 'српски језик'), 191 | "gd": ('Scottish Gaelic, Gaelic', 'Gàidhlig'), 192 | "sn": ('Shona', 'chiShona'), 193 | "si": ('Sinhala, Sinhalese', 'සිංහල'), 194 | "sk": ('Slovak', 'slovenčina'), 195 | "sl": ('Slovene', 'slovenščina'), 196 | "so": ('Somali', 'Soomaaliga, af Soomaali'), 197 | "st": ('Southern Sotho', 'Sesotho'), 198 | "es": ('Spanish', 'Español'), 199 | "su": ('Sundanese', 'Basa Sunda'), 200 | "sw": ('Swahili', 'Kiswahili'), 201 | "ss": ('Swati', 'SiSwati'), 202 | "sv": ('Swedish', 'svenska'), 203 | "ta": ('Tamil', 'தமிழ்'), 204 | "te": ('Telugu', 'తెలుగు'), 205 | "th": ('Thai', 'ไทย'), 206 | "ti": ('Tigrinya', 'ትግርኛ'), 207 | "bo": ('Tibetan', 'བོད་ཡིག'), 208 | "tk": ('Turkmen', 'Türkmen, Түркмен'), 209 | "tn": ('Tswana', 'Setswana'), 210 | "to": ('Tonga (Tonga Islands)', 'faka Tonga'), 211 | "tr": ('Turkish', 'Türkçe'), 212 | "ts": ('Tsonga', 'Xitsonga'), 213 | "tw": ('Twi', 'Twi'), 214 | "ty": ('Tahitian', 'Reo Tahiti'), 215 | "uk": ('Ukrainian', 'українська'), 216 | "ur": ('Urdu', 'اردو'), 217 | "ve": ('Venda', 'Tshivenḓa'), 218 | "vi": ('Vietnamese', 'Tiếng Việt'), 219 | "vo": ('Volapük', 'Volapük'), 220 | "wa": ('Walloon', 'Walon'), 221 | "cy": ('Welsh', 'Cymraeg'), 222 | "wo": ('Wolof', 'Wollof'), 223 | "fy": ('Western Frisian', 'Frysk'), 224 | "xh": ('Xhosa', 'isiXhosa'), 225 | "yi": ('Yiddish', 'ייִדיש'), 226 | "yo": ('Yoruba', 'Yorùbá'), 227 | }; 228 | -------------------------------------------------------------------------------- /example/chat_app/lib/src/common/util/error_util.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:io'; 3 | 4 | import 'package:chatapp/src/common/localization/localization.dart'; 5 | import 'package:chatapp/src/common/util/platform/error_util_vm.dart' 6 | // ignore: uri_does_not_exist 7 | if (dart.library.html) 'package:chatapp/src/common/util/platform/error_util_js.dart'; 8 | import 'package:flutter/material.dart' show BuildContext, Colors, ScaffoldMessenger, SnackBar, Text; 9 | import 'package:l/l.dart'; 10 | 11 | /// Error util. 12 | sealed class ErrorUtil { 13 | /// Log the error to the console and to Crashlytics. 14 | static Future logError( 15 | Object exception, 16 | StackTrace stackTrace, { 17 | String? hint, 18 | bool fatal = false, 19 | }) async { 20 | try { 21 | if (exception is String) { 22 | return await logMessage( 23 | exception, 24 | stackTrace: stackTrace, 25 | hint: hint, 26 | warning: true, 27 | ); 28 | } 29 | $captureException(exception, stackTrace, hint, fatal).ignore(); 30 | l.e(exception, stackTrace); 31 | } on Object catch (error, stackTrace) { 32 | l.e( 33 | 'Error while logging error "$error" inside ErrorUtil.logError', 34 | stackTrace, 35 | ); 36 | } 37 | } 38 | 39 | /// Logs a message to the console and to Crashlytics. 40 | static Future logMessage( 41 | String message, { 42 | StackTrace? stackTrace, 43 | String? hint, 44 | bool warning = false, 45 | }) async { 46 | try { 47 | l.e(message, stackTrace ?? StackTrace.current); 48 | $captureMessage(message, stackTrace, hint, warning).ignore(); 49 | } on Object catch (error, stackTrace) { 50 | l.e( 51 | 'Error while logging error "$error" inside ErrorUtil.logMessage', 52 | stackTrace, 53 | ); 54 | } 55 | } 56 | 57 | /// Rethrows the error with the stack trace. 58 | static Never throwWithStackTrace(Object error, StackTrace stackTrace) => Error.throwWithStackTrace(error, stackTrace); 59 | 60 | @pragma('vm:prefer-inline') 61 | static String _localizedError(String fallback, String Function(Localization l) localize) { 62 | try { 63 | return localize(Localization.current); 64 | } on Object { 65 | return fallback; 66 | } 67 | } 68 | 69 | // Also we can add current localization to this method 70 | static String formatMessage( 71 | Object error, [ 72 | String fallback = 'An error has occurred', 73 | ]) => 74 | switch (error) { 75 | String e => e, 76 | FormatException _ => _localizedError('Invalid format', (l) => l.errInvalidFormat), 77 | TimeoutException _ => _localizedError('Timeout exceeded', (l) => l.errTimeOutExceeded), 78 | UnimplementedError _ => _localizedError('Not implemented yet', (l) => l.errNotImplementedYet), 79 | UnsupportedError _ => _localizedError('Unsupported operation', (l) => l.errUnsupportedOperation), 80 | FileSystemException _ => _localizedError('File system error', (l) => l.errFileSystemException), 81 | AssertionError _ => _localizedError('Assertion error', (l) => l.errAssertionError), 82 | Error _ => _localizedError('An error has occurred', (l) => l.errAnErrorHasOccurred), 83 | Exception _ => _localizedError('An exception has occurred', (l) => l.errAnExceptionHasOccurred), 84 | _ => fallback, 85 | }; 86 | 87 | /// Shows a error snackbar with the given message. 88 | static void showSnackBar(BuildContext context, Object message) => ScaffoldMessenger.of(context).showSnackBar( 89 | SnackBar( 90 | content: Text(formatMessage(message)), 91 | backgroundColor: Colors.red, 92 | ), 93 | ); 94 | } 95 | -------------------------------------------------------------------------------- /example/chat_app/lib/src/common/util/logger_util.dart: -------------------------------------------------------------------------------- 1 | import 'package:l/l.dart'; 2 | 3 | sealed class LoggerUtil { 4 | /// Formats the log message. 5 | static Object messageFormatting(Object message, LogLevel logLevel, DateTime now) => '${timeFormat(now)} | $message'; 6 | 7 | /// Formats the time. 8 | static String timeFormat(DateTime time) => '${time.hour}:${time.minute.toString().padLeft(2, '0')}'; 9 | } 10 | -------------------------------------------------------------------------------- /example/chat_app/lib/src/common/util/platform/error_util_js.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: avoid_positional_boolean_parameters 2 | 3 | Future $captureException( 4 | Object exception, 5 | StackTrace stackTrace, 6 | String? hint, 7 | bool fatal, 8 | ) => 9 | Future.value(null); 10 | 11 | Future $captureMessage( 12 | String message, 13 | StackTrace? stackTrace, 14 | String? hint, 15 | bool warning, 16 | ) => 17 | Future.value(null); 18 | -------------------------------------------------------------------------------- /example/chat_app/lib/src/common/util/platform/error_util_vm.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: avoid_positional_boolean_parameters 2 | //import 'package:firebase_crashlytics/firebase_crashlytics.dart'; 3 | 4 | /* 5 | * Sentry.captureException(exception, stackTrace: stackTrace, hint: hint); 6 | * FirebaseCrashlytics.instance 7 | * .recordError(exception, stackTrace ?? StackTrace.current, reason: hint, fatal: fatal); 8 | * */ 9 | Future $captureException( 10 | Object exception, 11 | StackTrace stackTrace, 12 | String? hint, 13 | bool fatal, 14 | ) => 15 | Future.value(); 16 | // FirebaseCrashlytics.instance.recordError(exception, stackTrace, reason: hint, fatal: fatal); 17 | 18 | /* 19 | * Sentry.captureMessage( 20 | * message, 21 | * level: warning ? SentryLevel.warning : SentryLevel.info, 22 | * hint: hint, 23 | * params: [ 24 | * ...?params, 25 | * if (stackTrace != null) 'StackTrace: $stackTrace', 26 | * ], 27 | * ); 28 | * (warning || stackTrace != null) 29 | * ? FirebaseCrashlytics.instance.recordError(message, stackTrace ?? StackTrace.current); 30 | * : FirebaseCrashlytics.instance.log('$message${hint != null ? '\r\n$hint' : ''}'); 31 | * */ 32 | Future $captureMessage( 33 | String message, 34 | StackTrace? stackTrace, 35 | String? hint, 36 | bool warning, 37 | ) => 38 | Future.value(); 39 | /* warning || stackTrace != null 40 | ? FirebaseCrashlytics.instance.recordError( 41 | message, 42 | stackTrace ?? StackTrace.current, 43 | reason: hint, 44 | fatal: false, 45 | ) 46 | : FirebaseCrashlytics.instance.log('$message' 47 | '${stackTrace != null ? '\nHint: $hint' : ''}'); */ 48 | -------------------------------------------------------------------------------- /example/chat_app/lib/src/common/widget/app.dart: -------------------------------------------------------------------------------- 1 | import 'package:chatapp/src/common/localization/localization.dart'; 2 | import 'package:chatapp/src/common/widget/window_scope.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_localizations/flutter_localizations.dart'; 5 | 6 | /// {@template app} 7 | /// App widget. 8 | /// {@endtemplate} 9 | class App extends StatelessWidget { 10 | /// {@macro app} 11 | const App({super.key}); 12 | 13 | @override 14 | Widget build(BuildContext context) => MaterialApp( 15 | title: 'Chat App', 16 | debugShowCheckedModeBanner: false, 17 | localizationsDelegates: const >[ 18 | GlobalMaterialLocalizations.delegate, 19 | GlobalWidgetsLocalizations.delegate, 20 | GlobalCupertinoLocalizations.delegate, 21 | Localization.delegate, 22 | ], 23 | theme: View.of(context).platformDispatcher.platformBrightness == Brightness.dark 24 | ? ThemeData.dark(useMaterial3: true) 25 | : ThemeData.light(useMaterial3: true), // TODO(plugfox): implement theme 26 | home: const Placeholder(), 27 | supportedLocales: Localization.supportedLocales, 28 | locale: const Locale('en', 'US'), // TODO(plugfox): implement locale 29 | builder: (context, child) => MediaQuery( 30 | data: MediaQuery.of(context).copyWith(textScaleFactor: 1), 31 | child: WindowScope( 32 | title: Localization.of(context).title, 33 | child: child ?? const SizedBox.shrink(), 34 | ), 35 | ), 36 | ); 37 | } 38 | -------------------------------------------------------------------------------- /example/chat_app/lib/src/common/widget/radial_progress_indicator.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math' as math; 2 | 3 | import 'package:flutter/material.dart'; 4 | 5 | /// {@template radial_progress_indicator} 6 | /// RadialProgressIndicator widget 7 | /// {@endtemplate} 8 | class RadialProgressIndicator extends StatefulWidget { 9 | /// {@macro radial_progress_indicator} 10 | const RadialProgressIndicator({ 11 | this.size = 64, 12 | this.child, 13 | super.key, 14 | }); 15 | 16 | /// The size of the progress indicator 17 | final double size; 18 | 19 | /// The child widget 20 | final Widget? child; 21 | 22 | @override 23 | State createState() => _RadialProgressIndicatorState(); 24 | } 25 | 26 | class _RadialProgressIndicatorState extends State with SingleTickerProviderStateMixin { 27 | late final AnimationController _sweepController; 28 | late final Animation _curvedAnimation; 29 | 30 | @override 31 | void initState() { 32 | super.initState(); 33 | _sweepController = AnimationController( 34 | vsync: this, 35 | duration: const Duration(milliseconds: 1000), 36 | )..repeat(); 37 | _curvedAnimation = CurvedAnimation( 38 | parent: _sweepController, 39 | curve: Curves.ease, 40 | ); 41 | } 42 | 43 | @override 44 | void dispose() { 45 | _sweepController.dispose(); 46 | super.dispose(); 47 | } 48 | 49 | @override 50 | Widget build(BuildContext context) => Center( 51 | child: SizedBox.square( 52 | dimension: widget.size, 53 | child: RepaintBoundary( 54 | child: CustomPaint( 55 | painter: _RadialProgressIndicatorPainter( 56 | animation: _curvedAnimation, 57 | color: Theme.of(context).indicatorColor, 58 | ), 59 | child: Center( 60 | child: widget.child, 61 | ), 62 | ), 63 | ), 64 | ), 65 | ); 66 | } 67 | 68 | class _RadialProgressIndicatorPainter extends CustomPainter { 69 | _RadialProgressIndicatorPainter({ 70 | required Animation animation, 71 | Color color = Colors.blue, 72 | }) : _animation = animation, 73 | _arcPaint = Paint() 74 | ..strokeCap = StrokeCap.round 75 | ..style = PaintingStyle.stroke 76 | ..color = color, 77 | super(repaint: animation); 78 | 79 | final Animation _animation; 80 | final Paint _arcPaint; 81 | 82 | @override 83 | void paint(Canvas canvas, Size size) { 84 | _arcPaint.strokeWidth = size.shortestSide / 8; 85 | final progress = _animation.value; 86 | final rect = Rect.fromCircle( 87 | center: size.center(Offset.zero), 88 | radius: size.shortestSide / 2 - _arcPaint.strokeWidth / 2, 89 | ); 90 | final rotate = math.pow(progress, 2) * math.pi * 2; 91 | final sweep = math.sin(progress * math.pi) * 3 + math.pi * .25; 92 | 93 | canvas.drawArc(rect, rotate, sweep, false, _arcPaint); 94 | } 95 | 96 | @override 97 | bool shouldRepaint(covariant _RadialProgressIndicatorPainter oldDelegate) => 98 | _animation.value != oldDelegate._animation.value; 99 | 100 | @override 101 | bool shouldRebuildSemantics(covariant _RadialProgressIndicatorPainter oldDelegate) => false; 102 | } 103 | -------------------------------------------------------------------------------- /example/chat_app/lib/src/common/widget/window_scope.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io' as io; 2 | 3 | import 'package:flutter/foundation.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:window_manager/window_manager.dart'; 6 | 7 | /// {@template window_scope} 8 | /// WindowScope widget. 9 | /// {@endtemplate} 10 | class WindowScope extends StatefulWidget { 11 | /// {@macro window_scope} 12 | const WindowScope({ 13 | required this.title, 14 | required this.child, 15 | super.key, 16 | }); 17 | 18 | /// Title of the window. 19 | final String title; 20 | 21 | /// The widget below this widget in the tree. 22 | final Widget child; 23 | 24 | @override 25 | State createState() => _WindowScopeState(); 26 | } 27 | 28 | class _WindowScopeState extends State { 29 | @override 30 | Widget build(BuildContext context) => kIsWeb || io.Platform.isAndroid || io.Platform.isIOS 31 | ? widget.child 32 | : Column( 33 | mainAxisSize: MainAxisSize.max, 34 | mainAxisAlignment: MainAxisAlignment.start, 35 | crossAxisAlignment: CrossAxisAlignment.stretch, 36 | children: [ 37 | const _WindowTitle(), 38 | Expanded( 39 | child: widget.child, 40 | ), 41 | ], 42 | ); 43 | } 44 | 45 | class _WindowTitle extends StatefulWidget { 46 | const _WindowTitle(); 47 | 48 | @override 49 | State<_WindowTitle> createState() => _WindowTitleState(); 50 | } 51 | 52 | class _WindowTitleState extends State<_WindowTitle> with WindowListener { 53 | final ValueNotifier _isFullScreen = ValueNotifier(false); 54 | final ValueNotifier _isAlwaysOnTop = ValueNotifier(false); 55 | 56 | @override 57 | void initState() { 58 | windowManager.addListener(this); 59 | super.initState(); 60 | } 61 | 62 | @override 63 | void dispose() { 64 | windowManager.removeListener(this); 65 | super.dispose(); 66 | } 67 | 68 | @override 69 | void onWindowEnterFullScreen() { 70 | super.onWindowEnterFullScreen(); 71 | _isFullScreen.value = true; 72 | } 73 | 74 | @override 75 | void onWindowLeaveFullScreen() { 76 | super.onWindowLeaveFullScreen(); 77 | _isFullScreen.value = false; 78 | } 79 | 80 | @override 81 | void onWindowFocus() { 82 | // Make sure to call once. 83 | setState(() {}); 84 | // do something 85 | } 86 | 87 | void setAlwaysOnTop(bool value) { 88 | Future(() async { 89 | await windowManager.setAlwaysOnTop(value); 90 | _isAlwaysOnTop.value = await windowManager.isAlwaysOnTop(); 91 | }).ignore(); 92 | } 93 | 94 | @override 95 | Widget build(BuildContext context) => SizedBox( 96 | height: 24, 97 | child: DragToMoveArea( 98 | child: Material( 99 | color: Theme.of(context).primaryColor, 100 | child: Stack( 101 | alignment: Alignment.center, 102 | children: [ 103 | Builder( 104 | builder: (context) { 105 | final size = MediaQuery.of(context).size; 106 | return AnimatedPositioned( 107 | duration: const Duration(milliseconds: 350), 108 | left: size.width < 800 ? 8 : 78, 109 | right: 78, 110 | top: 0, 111 | bottom: 0, 112 | child: Center( 113 | child: AnimatedSwitcher( 114 | duration: const Duration(milliseconds: 250), 115 | transitionBuilder: (child, animation) => FadeTransition( 116 | opacity: animation, 117 | child: ScaleTransition( 118 | scale: animation, 119 | child: child, 120 | ), 121 | ), 122 | child: Text( 123 | context.findAncestorWidgetOfExactType()?.title ?? 'App', 124 | maxLines: 1, 125 | overflow: TextOverflow.ellipsis, 126 | style: Theme.of(context).textTheme.labelLarge?.copyWith(height: 1), 127 | ), 128 | ), 129 | ), 130 | ); 131 | }, 132 | ), 133 | _WindowButtons$Windows( 134 | isFullScreen: _isFullScreen, 135 | isAlwaysOnTop: _isAlwaysOnTop, 136 | setAlwaysOnTop: setAlwaysOnTop, 137 | ), 138 | ], 139 | ), 140 | ), 141 | ), 142 | ); 143 | } 144 | 145 | class _WindowButtons$Windows extends StatelessWidget { 146 | const _WindowButtons$Windows({ 147 | required ValueListenable isFullScreen, 148 | required ValueListenable isAlwaysOnTop, 149 | required this.setAlwaysOnTop, 150 | }) : _isFullScreen = isFullScreen, 151 | _isAlwaysOnTop = isAlwaysOnTop; 152 | 153 | // ignore: unused_field 154 | final ValueListenable _isFullScreen; 155 | final ValueListenable _isAlwaysOnTop; 156 | 157 | final ValueChanged setAlwaysOnTop; 158 | 159 | @override 160 | Widget build(BuildContext context) => Align( 161 | alignment: Alignment.centerRight, 162 | child: Row( 163 | mainAxisSize: MainAxisSize.min, 164 | crossAxisAlignment: CrossAxisAlignment.center, 165 | mainAxisAlignment: MainAxisAlignment.center, 166 | children: [ 167 | // Is always on top 168 | ValueListenableBuilder( 169 | valueListenable: _isAlwaysOnTop, 170 | builder: (context, isAlwaysOnTop, _) => _WindowButton( 171 | onPressed: () => setAlwaysOnTop(!isAlwaysOnTop), 172 | icon: isAlwaysOnTop ? Icons.push_pin : Icons.push_pin_outlined, 173 | ), 174 | ), 175 | 176 | // Minimize 177 | _WindowButton( 178 | onPressed: () => windowManager.minimize(), 179 | icon: Icons.minimize, 180 | ), 181 | 182 | /* ValueListenableBuilder( 183 | valueListenable: _isFullScreen, 184 | builder: (context, isFullScreen, _) => _WindowButton( 185 | onPressed: () => windowManager.setFullScreen(!isFullScreen), 186 | icon: isFullScreen ? Icons.fullscreen_exit : Icons.fullscreen, 187 | )), */ 188 | 189 | // Close 190 | _WindowButton( 191 | onPressed: () => windowManager.close(), 192 | icon: Icons.close, 193 | ), 194 | const SizedBox(width: 4), 195 | ], 196 | ), 197 | ); 198 | } 199 | 200 | class _WindowButton extends StatelessWidget { 201 | const _WindowButton({ 202 | required this.onPressed, 203 | required this.icon, 204 | }); 205 | 206 | final VoidCallback onPressed; 207 | final IconData icon; 208 | 209 | @override 210 | Widget build(BuildContext context) => Padding( 211 | padding: const EdgeInsets.symmetric(horizontal: 4), 212 | child: IconButton( 213 | onPressed: onPressed, 214 | icon: Icon(icon), 215 | iconSize: 16, 216 | alignment: Alignment.center, 217 | padding: EdgeInsets.zero, 218 | splashRadius: 12, 219 | constraints: const BoxConstraints.tightFor(width: 24, height: 24), 220 | ), 221 | ); 222 | } 223 | -------------------------------------------------------------------------------- /example/chat_app/lib/src/feature/dependencies/initialization/initialization.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:chatapp/src/common/util/error_util.dart'; 4 | import 'package:chatapp/src/feature/dependencies/initialization/initialize_dependencies.dart'; 5 | import 'package:chatapp/src/feature/dependencies/model/dependencies.dart'; 6 | import 'package:flutter/foundation.dart' show ChangeNotifier, FlutterError, PlatformDispatcher, ValueListenable; 7 | import 'package:flutter/services.dart' show SystemChrome, DeviceOrientation; 8 | import 'package:flutter/widgets.dart' show WidgetsBinding, WidgetsFlutterBinding; 9 | 10 | typedef InitializationProgressTuple = ({int progress, String message}); 11 | 12 | abstract interface class InitializationProgressListenable implements ValueListenable {} 13 | 14 | class InitializationExecutor with ChangeNotifier, InitializeDependencies implements InitializationProgressListenable { 15 | InitializationExecutor(); 16 | 17 | /// Ephemerally initializes the app and prepares it for use. 18 | Future? _$currentInitialization; 19 | 20 | @override 21 | InitializationProgressTuple get value => _value; 22 | InitializationProgressTuple _value = (progress: 0, message: ''); 23 | 24 | /// Initializes the app and prepares it for use. 25 | Future call({ 26 | bool deferFirstFrame = false, 27 | List? orientations, 28 | void Function(int progress, String message)? onProgress, 29 | void Function(Dependencies dependencies)? onSuccess, 30 | void Function(Object error, StackTrace stackTrace)? onError, 31 | }) => 32 | _$currentInitialization ??= Future(() async { 33 | late final WidgetsBinding binding; 34 | final stopwatch = Stopwatch()..start(); 35 | void notifyProgress(int progress, String message) { 36 | _value = (progress: progress.clamp(0, 100), message: message); 37 | onProgress?.call(_value.progress, _value.message); 38 | notifyListeners(); 39 | } 40 | 41 | notifyProgress(0, 'Initializing'); 42 | try { 43 | binding = WidgetsFlutterBinding.ensureInitialized(); 44 | if (deferFirstFrame) binding.deferFirstFrame(); 45 | await _catchExceptions(); 46 | if (orientations != null) await SystemChrome.setPreferredOrientations(orientations); 47 | final dependencies = 48 | await $initializeDependencies(onProgress: notifyProgress).timeout(const Duration(minutes: 5)); 49 | notifyProgress(100, 'Done'); 50 | onSuccess?.call(dependencies); 51 | return dependencies; 52 | } on Object catch (error, stackTrace) { 53 | onError?.call(error, stackTrace); 54 | ErrorUtil.logError( 55 | error, 56 | stackTrace, 57 | hint: 'Failed to initialize app', 58 | ).ignore(); 59 | rethrow; 60 | } finally { 61 | stopwatch.stop(); 62 | binding.addPostFrameCallback((_) { 63 | // Closes splash screen, and show the app layout. 64 | if (deferFirstFrame) binding.allowFirstFrame(); 65 | //final context = binding.renderViewElement; 66 | }); 67 | _$currentInitialization = null; 68 | } 69 | }); 70 | 71 | Future _catchExceptions() async { 72 | try { 73 | PlatformDispatcher.instance.onError = (error, stackTrace) { 74 | ErrorUtil.logError( 75 | error, 76 | stackTrace, 77 | hint: 'ROOT | ${Error.safeToString(error)}', 78 | ).ignore(); 79 | return true; 80 | }; 81 | 82 | final sourceFlutterError = FlutterError.onError; 83 | FlutterError.onError = (final details) { 84 | ErrorUtil.logError( 85 | details.exception, 86 | details.stack ?? StackTrace.current, 87 | hint: 'FLUTTER ERROR\r\n$details', 88 | ).ignore(); 89 | // FlutterError.presentError(details); 90 | sourceFlutterError?.call(details); 91 | }; 92 | } on Object catch (error, stackTrace) { 93 | ErrorUtil.logError(error, stackTrace).ignore(); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /example/chat_app/lib/src/feature/dependencies/initialization/initialize_dependencies.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:chatapp/src/feature/dependencies/initialization/platform/initialization_vm.dart' 4 | // ignore: uri_does_not_exist 5 | if (dart.library.html) 'package:chatapp/src/feature/dependencies/initialization/platform/initialization_js.dart'; 6 | import 'package:chatapp/src/feature/dependencies/model/dependencies.dart'; 7 | import 'package:l/l.dart'; 8 | import 'package:meta/meta.dart'; 9 | 10 | typedef _InitializationStep = FutureOr Function(_MutableDependencies dependencies); 11 | 12 | class _MutableDependencies implements Dependencies {} 13 | 14 | @internal 15 | mixin InitializeDependencies { 16 | /// Initializes the app and returns a [Dependencies] object 17 | @protected 18 | Future $initializeDependencies({ 19 | void Function(int progress, String message)? onProgress, 20 | }) async { 21 | final steps = _initializationSteps; 22 | final dependencies = _MutableDependencies(); 23 | final totalSteps = steps.length; 24 | for (var currentStep = 0; currentStep < totalSteps; currentStep++) { 25 | final step = steps[currentStep]; 26 | final percent = (currentStep * 100 ~/ totalSteps).clamp(0, 100); 27 | onProgress?.call(percent, step.$1); 28 | l.v6('Initialization | $currentStep/$totalSteps ($percent%) | "${step.$1}"'); 29 | await step.$2(dependencies); 30 | } 31 | return dependencies; 32 | } 33 | 34 | List<(String, _InitializationStep)> get _initializationSteps => <(String, _InitializationStep)>[ 35 | ('Platform pre-initialization', (_) => $platformInitialization()), 36 | ('Fake delay 1', (_) => Future.delayed(const Duration(seconds: 1))), 37 | ('Fake delay 2', (_) => Future.delayed(const Duration(seconds: 1))), 38 | ('Fake delay 3', (_) => Future.delayed(const Duration(seconds: 1))), 39 | ]; 40 | } 41 | -------------------------------------------------------------------------------- /example/chat_app/lib/src/feature/dependencies/initialization/platform/initialization_js.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: avoid_web_libraries_in_flutter 2 | 3 | import 'dart:html' as html; 4 | 5 | //import 'package:flutter_web_plugins/flutter_web_plugins.dart'; 6 | 7 | Future $platformInitialization() async { 8 | //setUrlStrategy(const HashUrlStrategy()); 9 | Future.delayed( 10 | const Duration(seconds: 1), 11 | () { 12 | html.document.getElementById('splash')?.remove(); 13 | html.document.getElementById('splash-branding')?.remove(); 14 | html.document.body?.style.background = 'transparent'; 15 | html.document 16 | .getElementsByClassName('splash-loading') 17 | .toList(growable: false) 18 | .forEach((element) => element.remove()); 19 | }, 20 | ); 21 | } 22 | -------------------------------------------------------------------------------- /example/chat_app/lib/src/feature/dependencies/initialization/platform/initialization_vm.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io' as io; 2 | 3 | import 'package:flutter/foundation.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:window_manager/window_manager.dart'; 6 | 7 | Future $platformInitialization() => 8 | io.Platform.isAndroid || io.Platform.isIOS ? _mobileInitialization() : _desktopInitialization(); 9 | 10 | Future _mobileInitialization() async {} 11 | 12 | Future _desktopInitialization() async { 13 | // Must add this line. 14 | await windowManager.ensureInitialized(); 15 | final windowOptions = WindowOptions( 16 | minimumSize: const Size(360, 480), 17 | size: const Size(960, 800), 18 | maximumSize: const Size(1440, 1080), 19 | center: true, 20 | backgroundColor: PlatformDispatcher.instance.platformBrightness == Brightness.dark 21 | ? ThemeData.dark().colorScheme.background 22 | : ThemeData.light().colorScheme.background, 23 | skipTaskbar: false, 24 | titleBarStyle: TitleBarStyle.hidden, 25 | /* alwaysOnTop: true, */ 26 | fullScreen: false, 27 | title: 'Chat App', 28 | ); 29 | await windowManager.waitUntilReadyToShow( 30 | windowOptions, 31 | () async { 32 | if (io.Platform.isMacOS) { 33 | await windowManager.setMovable(true); 34 | } 35 | await windowManager.setMaximizable(false); 36 | await windowManager.show(); 37 | await windowManager.focus(); 38 | }, 39 | ); 40 | } 41 | -------------------------------------------------------------------------------- /example/chat_app/lib/src/feature/dependencies/model/dependencies.dart: -------------------------------------------------------------------------------- 1 | abstract interface class Dependencies {} 2 | -------------------------------------------------------------------------------- /example/chat_app/lib/src/feature/dependencies/widget/dependencies_scope.dart: -------------------------------------------------------------------------------- 1 | import 'package:chatapp/src/feature/dependencies/model/dependencies.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter/widgets.dart'; 4 | 5 | /// {@template dependencies_scope} 6 | /// DependenciesScope widget. 7 | /// {@endtemplate} 8 | class DependenciesScope extends StatelessWidget { 9 | /// {@macro dependencies_scope} 10 | const DependenciesScope({ 11 | required this.initialization, 12 | required this.splashScreen, 13 | required this.child, 14 | this.errorBuilder, 15 | super.key, 16 | }); 17 | 18 | /// The state from the closest instance of this class 19 | /// that encloses the given context, if any. 20 | /// e.g. `DependenciesScope.maybeOf(context)`. 21 | static Dependencies? maybeOf(BuildContext context) => 22 | switch (context.getElementForInheritedWidgetOfExactType<_InheritedDependencies>()?.widget) { 23 | _InheritedDependencies inheritedDependencies => inheritedDependencies.dependencies, 24 | _ => null, 25 | }; 26 | 27 | static Never _notFoundInheritedWidgetOfExactType() => throw ArgumentError( 28 | 'Out of scope, not found inherited widget ' 29 | 'a DependenciesScope of the exact type', 30 | 'out_of_scope', 31 | ); 32 | 33 | /// The state from the closest instance of this class 34 | /// that encloses the given context. 35 | /// e.g. `DependenciesScope.of(context)` 36 | static Dependencies of(BuildContext context) => maybeOf(context) ?? _notFoundInheritedWidgetOfExactType(); 37 | 38 | /// Initialization of the dependencies. 39 | final Future initialization; 40 | 41 | /// Splash screen widget. 42 | final Widget splashScreen; 43 | 44 | /// Error widget. 45 | final Widget Function(Object error, StackTrace? stackTrace)? errorBuilder; 46 | 47 | /// The widget below this widget in the tree. 48 | final Widget child; 49 | 50 | @override 51 | Widget build(BuildContext context) => FutureBuilder( 52 | future: initialization, 53 | builder: (context, snapshot) => switch ((snapshot.data, snapshot.error, snapshot.stackTrace)) { 54 | (Dependencies dependencies, null, null) => _InheritedDependencies( 55 | dependencies: dependencies, 56 | child: child, 57 | ), 58 | (_, Object error, StackTrace? stackTrace) => errorBuilder?.call(error, stackTrace) ?? ErrorWidget(error), 59 | _ => splashScreen, 60 | }, 61 | ); 62 | } 63 | 64 | /// {@template inherited_dependencies} 65 | /// InheritedDependencies widget. 66 | /// {@endtemplate} 67 | class _InheritedDependencies extends InheritedWidget { 68 | /// {@macro inherited_dependencies} 69 | const _InheritedDependencies({ 70 | required this.dependencies, 71 | required super.child, 72 | }); 73 | 74 | final Dependencies dependencies; 75 | 76 | @override 77 | bool updateShouldNotify(covariant _InheritedDependencies oldWidget) => false; 78 | } 79 | -------------------------------------------------------------------------------- /example/chat_app/lib/src/feature/dependencies/widget/initialization_splash_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:chatapp/src/common/widget/radial_progress_indicator.dart'; 2 | import 'package:flutter/foundation.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | class InitializationSplashScreen extends StatelessWidget { 6 | const InitializationSplashScreen({required this.progress, super.key}); 7 | 8 | final ValueListenable<({int progress, String message})> progress; 9 | 10 | @override 11 | Widget build(BuildContext context) { 12 | final theme = View.of(context).platformDispatcher.platformBrightness == Brightness.dark 13 | ? ThemeData.dark() 14 | : ThemeData.light(); 15 | return Material( 16 | color: theme.primaryColor, 17 | child: Directionality( 18 | textDirection: TextDirection.ltr, 19 | child: Center( 20 | child: ListView( 21 | shrinkWrap: true, 22 | children: [ 23 | RadialProgressIndicator( 24 | size: 128, 25 | child: ValueListenableBuilder<({String message, int progress})>( 26 | valueListenable: progress, 27 | builder: (context, value, _) => Text( 28 | '${value.progress}%', 29 | overflow: TextOverflow.ellipsis, 30 | maxLines: 1, 31 | textAlign: TextAlign.center, 32 | style: theme.textTheme.titleLarge?.copyWith( 33 | height: 1, 34 | fontSize: 32, 35 | ), 36 | ), 37 | ), 38 | ), 39 | const SizedBox(height: 16), 40 | Opacity( 41 | opacity: .25, 42 | child: ValueListenableBuilder<({String message, int progress})>( 43 | valueListenable: progress, 44 | builder: (context, value, _) => Text( 45 | value.message, 46 | overflow: TextOverflow.ellipsis, 47 | maxLines: 3, 48 | textAlign: TextAlign.center, 49 | style: theme.textTheme.labelSmall?.copyWith( 50 | height: 1, 51 | ), 52 | ), 53 | ), 54 | ), 55 | ], 56 | ), 57 | ), 58 | ), 59 | ); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /example/chat_app/linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /example/chat_app/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 "chatapp") 8 | # The unique GTK application identifier for this application. See: 9 | # https://wiki.gnome.org/HowDoI/ChooseApplicationID 10 | set(APPLICATION_ID "dev.plugfox.chat.chatapp") 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 | # Fully re-copy the assets directory on each build to avoid having stale files 127 | # from a previous install. 128 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 129 | install(CODE " 130 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 131 | " COMPONENT Runtime) 132 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 133 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 134 | 135 | # Install the AOT library on non-Debug builds only. 136 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") 137 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 138 | COMPONENT Runtime) 139 | endif() 140 | -------------------------------------------------------------------------------- /example/chat_app/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/chat_app/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 | #include 10 | #include 11 | 12 | void fl_register_plugins(FlPluginRegistry* registry) { 13 | g_autoptr(FlPluginRegistrar) screen_retriever_registrar = 14 | fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin"); 15 | screen_retriever_plugin_register_with_registrar(screen_retriever_registrar); 16 | g_autoptr(FlPluginRegistrar) window_manager_registrar = 17 | fl_plugin_registry_get_registrar_for_plugin(registry, "WindowManagerPlugin"); 18 | window_manager_plugin_register_with_registrar(window_manager_registrar); 19 | } 20 | -------------------------------------------------------------------------------- /example/chat_app/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/chat_app/linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | screen_retriever 7 | window_manager 8 | ) 9 | 10 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 11 | ) 12 | 13 | set(PLUGIN_BUNDLED_LIBRARIES) 14 | 15 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 16 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 17 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 19 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 20 | endforeach(plugin) 21 | 22 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 23 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 24 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 25 | endforeach(ffi_plugin) 26 | -------------------------------------------------------------------------------- /example/chat_app/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/chat_app/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, "chatapp"); 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, "chatapp"); 48 | } 49 | 50 | gtk_window_set_default_size(window, 1280, 720); 51 | // gtk_widget_show(GTK_WIDGET(window)); 52 | gtk_widget_realize(GTK_WIDGET(window)); 53 | 54 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 55 | fl_dart_project_set_dart_entrypoint_arguments( 56 | project, self->dart_entrypoint_arguments); 57 | 58 | FlView *view = fl_view_new(project); 59 | gtk_widget_show(GTK_WIDGET(view)); 60 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 61 | 62 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 63 | 64 | gtk_widget_grab_focus(GTK_WIDGET(view)); 65 | } 66 | 67 | // Implements GApplication::local_command_line. 68 | static gboolean my_application_local_command_line(GApplication *application, 69 | gchar ***arguments, 70 | int *exit_status) { 71 | MyApplication *self = MY_APPLICATION(application); 72 | // Strip out the first argument as it is the binary name. 73 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 74 | 75 | g_autoptr(GError) error = nullptr; 76 | if (!g_application_register(application, nullptr, &error)) { 77 | g_warning("Failed to register: %s", error->message); 78 | *exit_status = 1; 79 | return TRUE; 80 | } 81 | 82 | g_application_activate(application); 83 | *exit_status = 0; 84 | 85 | return TRUE; 86 | } 87 | 88 | // Implements GObject::dispose. 89 | static void my_application_dispose(GObject *object) { 90 | MyApplication *self = MY_APPLICATION(object); 91 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 92 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 93 | } 94 | 95 | static void my_application_class_init(MyApplicationClass *klass) { 96 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 97 | G_APPLICATION_CLASS(klass)->local_command_line = 98 | my_application_local_command_line; 99 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 100 | } 101 | 102 | static void my_application_init(MyApplication *self) {} 103 | 104 | MyApplication *my_application_new() { 105 | return MY_APPLICATION(g_object_new(my_application_get_type(), 106 | "application-id", APPLICATION_ID, "flags", 107 | G_APPLICATION_NON_UNIQUE, nullptr)); 108 | } 109 | -------------------------------------------------------------------------------- /example/chat_app/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/chat_app/macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /example/chat_app/macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "ephemeral/Flutter-Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/chat_app/macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "ephemeral/Flutter-Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/chat_app/macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import screen_retriever 9 | import window_manager 10 | 11 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 12 | ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin")) 13 | WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin")) 14 | } 15 | -------------------------------------------------------------------------------- /example/chat_app/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/chat_app/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/chat_app/macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/chat_app/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/chat_app/macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /example/chat_app/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/chat_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /example/chat_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /example/chat_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /example/chat_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /example/chat_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /example/chat_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /example/chat_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /example/chat_app/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 = chatapp 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = dev.plugfox.chat.chatapp 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2023 dev.plugfox.chat. All rights reserved. 15 | -------------------------------------------------------------------------------- /example/chat_app/macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /example/chat_app/macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /example/chat_app/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/chat_app/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/chat_app/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/chat_app/macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | import window_manager 4 | 5 | class MainFlutterWindow: NSWindow { 6 | override func awakeFromNib() { 7 | let flutterViewController = FlutterViewController() 8 | let windowFrame = self.frame 9 | self.contentViewController = flutterViewController 10 | self.setFrame(windowFrame, display: true) 11 | 12 | RegisterGeneratedPlugins(registry: flutterViewController) 13 | 14 | super.awakeFromNib() 15 | } 16 | 17 | // Hidden at launch 18 | override public func order(_ place: NSWindow.OrderingMode, relativeTo otherWin: Int) { 19 | super.order(place, relativeTo: otherWin) 20 | hiddenWindowAtLaunch() 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /example/chat_app/macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/chat_app/macos/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import FlutterMacOS 2 | import Cocoa 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /example/chat_app/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: chatapp 2 | description: The Chat App 3 | version: 0.0.1-dev 4 | homepage: https://github.com/plugfox/chat 5 | repository: https://github.com/plugfox/chat 6 | issue_tracker: https://github.com/plugfox/chat/issues 7 | 8 | funding: 9 | - https://www.buymeacoffee.com/plugfox 10 | - https://www.patreon.com/plugfox 11 | - https://boosty.to/plugfox 12 | 13 | topics: 14 | - chat 15 | - websocket 16 | - cross-platform 17 | - reconnect 18 | - socket 19 | 20 | platforms: 21 | android: 22 | ios: 23 | linux: 24 | macos: 25 | web: 26 | windows: 27 | 28 | #screenshots: 29 | # - description: 'Example of using the library.' 30 | # path: example.png 31 | 32 | environment: 33 | sdk: ">=3.0.0 <4.0.0" 34 | flutter: '>=3.10.5' 35 | 36 | 37 | dependencies: 38 | # Flutter SDK 39 | flutter: 40 | sdk: flutter 41 | 42 | # Localization 43 | flutter_localizations: 44 | sdk: flutter 45 | intl: any 46 | 47 | # Utils 48 | collection: any 49 | async: any 50 | meta: any 51 | path: any 52 | 53 | # Desktop 54 | window_manager: ^0.3.5 55 | 56 | # Logger 57 | l: ^4.0.2 58 | 59 | # Transport 60 | ws: ^0.1.2 61 | 62 | dev_dependencies: 63 | # Unit & Widget tests for Flutter 64 | flutter_test: 65 | sdk: flutter 66 | # Integration tests for Flutter 67 | integration_test: 68 | sdk: flutter 69 | 70 | # Linting 71 | flutter_lints: ^2.0.1 72 | 73 | # Codegen 74 | build_runner: ^2.4.6 75 | #flutter_launcher_icons: ^0.13.1 76 | #flutter_native_splash: ^2.3.1 77 | pubspec_generator: '>=4.0.0 <5.0.0' 78 | #flutter_gen_runner: ^5.3.1 79 | 80 | 81 | flutter: 82 | uses-material-design: true 83 | 84 | 85 | flutter_intl: 86 | enabled: true 87 | class_name: GeneratedLocalization 88 | main_locale: en 89 | arb_dir: lib/src/common/localization 90 | output_dir: lib/src/common/localization/generated 91 | use_deferred_loading: false 92 | 93 | 94 | #flutter_gen: 95 | # output: lib/src/common/constant/ 96 | # line_length: 120 -------------------------------------------------------------------------------- /example/chat_app/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | void main() { 2 | /* testWidgets('Counter increments smoke test', (WidgetTester tester) async { 3 | // Build our app and trigger a frame. 4 | await tester.pumpWidget(const MyApp()); 5 | 6 | // Verify that our counter starts at 0. 7 | expect(find.text('0'), findsOneWidget); 8 | expect(find.text('1'), findsNothing); 9 | 10 | // Tap the '+' icon and trigger a frame. 11 | await tester.tap(find.byIcon(Icons.add)); 12 | await tester.pump(); 13 | 14 | // Verify that our counter has incremented. 15 | expect(find.text('0'), findsNothing); 16 | expect(find.text('1'), findsOneWidget); 17 | }); */ 18 | } 19 | -------------------------------------------------------------------------------- /example/chat_app/tool/makefile/pub.mk: -------------------------------------------------------------------------------- 1 | .PHONY: version doctor clean get codegen intl upgrade upgrade-major outdated dependencies format 2 | 3 | # Check flutter version 4 | version: 5 | @fvm flutter --version 6 | 7 | # Check flutter doctor 8 | doctor: 9 | @fvm flutter doctor 10 | 11 | # Clean all generated files 12 | clean: 13 | @rm -rf coverage .dart_tool .packages pubspec.lock 14 | 15 | # Get dependencies 16 | get: 17 | @fvm flutter pub get 18 | 19 | # Generate code 20 | codegen: get 21 | @fvm flutter pub run build_runner build --delete-conflicting-outputs 22 | @dart pub global run intl_utils:generate 23 | @dart format --fix -l 120 . 24 | 25 | # Generate intl messages 26 | intl: 27 | @dart pub global run intl_utils:generate 28 | @dart format --fix -l 120 . 29 | 30 | # Generate all 31 | gen: codegen 32 | 33 | # Upgrade dependencies 34 | upgrade: 35 | @fvm flutter pub upgrade 36 | 37 | # Upgrade to major versions 38 | upgrade-major: 39 | @fvm flutter pub upgrade --major-versions 40 | 41 | # Check outdated dependencies 42 | outdated: get 43 | @fvm flutter pub outdated 44 | 45 | # Check outdated dependencies 46 | dependencies: upgrade 47 | @fvm flutter pub outdated --dependency-overrides \ 48 | --dev-dependencies --prereleases --show-all --transitive 49 | 50 | # Format code 51 | format: 52 | @dart format --fix -l 120 . -------------------------------------------------------------------------------- /example/chat_app/tool/makefile/setup.mk: -------------------------------------------------------------------------------- 1 | .PHONY: splash icon 2 | 3 | # https://pub.dev/packages/flutter_launcher_icons 4 | icon: 5 | @fvm flutter pub run flutter_launcher_icons -f flutter_launcher_icons.yaml 6 | 7 | # https://pub.dev/packages/flutter_native_splash 8 | splash: 9 | @fvm flutter pub run flutter_native_splash:create --path=flutter_native_splash.yaml 10 | -------------------------------------------------------------------------------- /example/chat_app/tool/makefile/test.mk: -------------------------------------------------------------------------------- 1 | integration: 2 | @fvm flutter test \ 3 | --coverage \ 4 | integration_test/app_test.dart -------------------------------------------------------------------------------- /example/chat_app/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/web/favicon.png -------------------------------------------------------------------------------- /example/chat_app/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/web/icons/Icon-192.png -------------------------------------------------------------------------------- /example/chat_app/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/web/icons/Icon-512.png -------------------------------------------------------------------------------- /example/chat_app/web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /example/chat_app/web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /example/chat_app/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | Chat App 33 | 34 | 35 | 39 | 40 | 41 | 42 | 43 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /example/chat_app/web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "chatapp", 3 | "short_name": "chatapp", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "The Chat App", 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/chat_app/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/chat_app/windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.14) 3 | project(chatapp 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 "chatapp") 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 | # Fully re-copy the assets directory on each build to avoid having stale files 91 | # from a previous install. 92 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 93 | install(CODE " 94 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 95 | " COMPONENT Runtime) 96 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 97 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 98 | 99 | # Install the AOT library on non-Debug builds only. 100 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 101 | CONFIGURATIONS Profile;Release 102 | COMPONENT Runtime) 103 | -------------------------------------------------------------------------------- /example/chat_app/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 | # === Flutter Library === 14 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 15 | 16 | # Published to parent scope for install step. 17 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 18 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 19 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 20 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 21 | 22 | list(APPEND FLUTTER_LIBRARY_HEADERS 23 | "flutter_export.h" 24 | "flutter_windows.h" 25 | "flutter_messenger.h" 26 | "flutter_plugin_registrar.h" 27 | "flutter_texture_registrar.h" 28 | ) 29 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 30 | add_library(flutter INTERFACE) 31 | target_include_directories(flutter INTERFACE 32 | "${EPHEMERAL_DIR}" 33 | ) 34 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 35 | add_dependencies(flutter flutter_assemble) 36 | 37 | # === Wrapper === 38 | list(APPEND CPP_WRAPPER_SOURCES_CORE 39 | "core_implementations.cc" 40 | "standard_codec.cc" 41 | ) 42 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 43 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 44 | "plugin_registrar.cc" 45 | ) 46 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 47 | list(APPEND CPP_WRAPPER_SOURCES_APP 48 | "flutter_engine.cc" 49 | "flutter_view_controller.cc" 50 | ) 51 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 52 | 53 | # Wrapper sources needed for a plugin. 54 | add_library(flutter_wrapper_plugin STATIC 55 | ${CPP_WRAPPER_SOURCES_CORE} 56 | ${CPP_WRAPPER_SOURCES_PLUGIN} 57 | ) 58 | apply_standard_settings(flutter_wrapper_plugin) 59 | set_target_properties(flutter_wrapper_plugin PROPERTIES 60 | POSITION_INDEPENDENT_CODE ON) 61 | set_target_properties(flutter_wrapper_plugin PROPERTIES 62 | CXX_VISIBILITY_PRESET hidden) 63 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 64 | target_include_directories(flutter_wrapper_plugin PUBLIC 65 | "${WRAPPER_ROOT}/include" 66 | ) 67 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 68 | 69 | # Wrapper sources needed for the runner. 70 | add_library(flutter_wrapper_app STATIC 71 | ${CPP_WRAPPER_SOURCES_CORE} 72 | ${CPP_WRAPPER_SOURCES_APP} 73 | ) 74 | apply_standard_settings(flutter_wrapper_app) 75 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 76 | target_include_directories(flutter_wrapper_app PUBLIC 77 | "${WRAPPER_ROOT}/include" 78 | ) 79 | add_dependencies(flutter_wrapper_app flutter_assemble) 80 | 81 | # === Flutter tool backend === 82 | # _phony_ is a non-existent file to force this command to run every time, 83 | # since currently there's no way to get a full input/output list from the 84 | # flutter tool. 85 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 86 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 87 | add_custom_command( 88 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 89 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 90 | ${CPP_WRAPPER_SOURCES_APP} 91 | ${PHONY_OUTPUT} 92 | COMMAND ${CMAKE_COMMAND} -E env 93 | ${FLUTTER_TOOL_ENVIRONMENT} 94 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 95 | windows-x64 $ 96 | VERBATIM 97 | ) 98 | add_custom_target(flutter_assemble DEPENDS 99 | "${FLUTTER_LIBRARY}" 100 | ${FLUTTER_LIBRARY_HEADERS} 101 | ${CPP_WRAPPER_SOURCES_CORE} 102 | ${CPP_WRAPPER_SOURCES_PLUGIN} 103 | ${CPP_WRAPPER_SOURCES_APP} 104 | ) 105 | -------------------------------------------------------------------------------- /example/chat_app/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 | #include 10 | #include 11 | 12 | void RegisterPlugins(flutter::PluginRegistry* registry) { 13 | ScreenRetrieverPluginRegisterWithRegistrar( 14 | registry->GetRegistrarForPlugin("ScreenRetrieverPlugin")); 15 | WindowManagerPluginRegisterWithRegistrar( 16 | registry->GetRegistrarForPlugin("WindowManagerPlugin")); 17 | } 18 | -------------------------------------------------------------------------------- /example/chat_app/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/chat_app/windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | screen_retriever 7 | window_manager 8 | ) 9 | 10 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 11 | ) 12 | 13 | set(PLUGIN_BUNDLED_LIBRARIES) 14 | 15 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 16 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 17 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 19 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 20 | endforeach(plugin) 21 | 22 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 23 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 24 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 25 | endforeach(ffi_plugin) 26 | -------------------------------------------------------------------------------- /example/chat_app/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/chat_app/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", "dev.plugfox.chat" "\0" 93 | VALUE "FileDescription", "chatapp" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "chatapp" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2023 dev.plugfox.chat. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "chatapp.exe" "\0" 98 | VALUE "ProductName", "chatapp" "\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/chat_app/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 | // delete this->Show(); 32 | }); 33 | 34 | return true; 35 | } 36 | 37 | void FlutterWindow::OnDestroy() { 38 | if (flutter_controller_) { 39 | flutter_controller_ = nullptr; 40 | } 41 | 42 | Win32Window::OnDestroy(); 43 | } 44 | 45 | LRESULT 46 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 47 | WPARAM const wparam, 48 | LPARAM const lparam) noexcept { 49 | // Give Flutter, including plugins, an opportunity to handle window messages. 50 | if (flutter_controller_) { 51 | std::optional result = 52 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 53 | lparam); 54 | if (result) { 55 | return *result; 56 | } 57 | } 58 | 59 | switch (message) { 60 | case WM_FONTCHANGE: 61 | flutter_controller_->engine()->ReloadSystemFonts(); 62 | break; 63 | } 64 | 65 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 66 | } 67 | -------------------------------------------------------------------------------- /example/chat_app/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/chat_app/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 = GetCommandLineArguments(); 23 | 24 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 25 | 26 | FlutterWindow window(project); 27 | Win32Window::Point origin(10, 10); 28 | Win32Window::Size size(1280, 720); 29 | if (!window.Create(L"chatapp", origin, size)) { 30 | return EXIT_FAILURE; 31 | } 32 | window.SetQuitOnClose(true); 33 | 34 | ::MSG msg; 35 | while (::GetMessage(&msg, nullptr, 0, 0)) { 36 | ::TranslateMessage(&msg); 37 | ::DispatchMessage(&msg); 38 | } 39 | 40 | ::CoUninitialize(); 41 | return EXIT_SUCCESS; 42 | } 43 | -------------------------------------------------------------------------------- /example/chat_app/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/chat_app/windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlugFox/chat/fdb9450c17897c210a05b8779bd6728d4197e71b/example/chat_app/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /example/chat_app/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/chat_app/windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr) 51 | -1; // remove the trailing null character 52 | int input_length = (int)wcslen(utf16_string); 53 | std::string utf8_string; 54 | if (target_length <= 0 || target_length > utf8_string.max_size()) { 55 | return utf8_string; 56 | } 57 | utf8_string.resize(target_length); 58 | int converted_length = ::WideCharToMultiByte( 59 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 60 | input_length, utf8_string.data(), target_length, nullptr, nullptr); 61 | if (converted_length == 0) { 62 | return std::string(); 63 | } 64 | return utf8_string; 65 | } 66 | -------------------------------------------------------------------------------- /example/chat_app/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/chat_app/windows/runner/win32_window.cpp: -------------------------------------------------------------------------------- 1 | #include "win32_window.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "resource.h" 7 | 8 | namespace { 9 | 10 | /// Window attribute that enables dark mode window decorations. 11 | /// 12 | /// Redefined in case the developer's machine has a Windows SDK older than 13 | /// version 10.0.22000.0. 14 | /// See: 15 | /// https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute 16 | #ifndef DWMWA_USE_IMMERSIVE_DARK_MODE 17 | #define DWMWA_USE_IMMERSIVE_DARK_MODE 20 18 | #endif 19 | 20 | constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; 21 | 22 | /// Registry key for app theme preference. 23 | /// 24 | /// A value of 0 indicates apps should use dark mode. A non-zero or missing 25 | /// value indicates apps should use light mode. 26 | constexpr const wchar_t kGetPreferredBrightnessRegKey[] = 27 | L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; 28 | constexpr const wchar_t kGetPreferredBrightnessRegValue[] = 29 | L"AppsUseLightTheme"; 30 | 31 | // The number of Win32Window objects that currently exist. 32 | static int g_active_window_count = 0; 33 | 34 | using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); 35 | 36 | // Scale helper to convert logical scaler values to physical using passed in 37 | // scale factor 38 | int Scale(int source, double scale_factor) { 39 | return static_cast(source * scale_factor); 40 | } 41 | 42 | // Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. 43 | // This API is only needed for PerMonitor V1 awareness mode. 44 | void EnableFullDpiSupportIfAvailable(HWND hwnd) { 45 | HMODULE user32_module = LoadLibraryA("User32.dll"); 46 | if (!user32_module) { 47 | return; 48 | } 49 | auto enable_non_client_dpi_scaling = 50 | reinterpret_cast( 51 | GetProcAddress(user32_module, "EnableNonClientDpiScaling")); 52 | if (enable_non_client_dpi_scaling != nullptr) { 53 | enable_non_client_dpi_scaling(hwnd); 54 | } 55 | FreeLibrary(user32_module); 56 | } 57 | 58 | } // namespace 59 | 60 | // Manages the Win32Window's window class registration. 61 | class WindowClassRegistrar { 62 | public: 63 | ~WindowClassRegistrar() = default; 64 | 65 | // Returns the singleton registrar instance. 66 | static WindowClassRegistrar *GetInstance() { 67 | if (!instance_) { 68 | instance_ = new WindowClassRegistrar(); 69 | } 70 | return instance_; 71 | } 72 | 73 | // Returns the name of the window class, registering the class if it hasn't 74 | // previously been registered. 75 | const wchar_t *GetWindowClass(); 76 | 77 | // Unregisters the window class. Should only be called if there are no 78 | // instances of the window. 79 | void UnregisterWindowClass(); 80 | 81 | private: 82 | WindowClassRegistrar() = default; 83 | 84 | static WindowClassRegistrar *instance_; 85 | 86 | bool class_registered_ = false; 87 | }; 88 | 89 | WindowClassRegistrar *WindowClassRegistrar::instance_ = nullptr; 90 | 91 | const wchar_t *WindowClassRegistrar::GetWindowClass() { 92 | if (!class_registered_) { 93 | WNDCLASS window_class{}; 94 | window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); 95 | window_class.lpszClassName = kWindowClassName; 96 | window_class.style = CS_HREDRAW | CS_VREDRAW; 97 | window_class.cbClsExtra = 0; 98 | window_class.cbWndExtra = 0; 99 | window_class.hInstance = GetModuleHandle(nullptr); 100 | window_class.hIcon = 101 | LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); 102 | window_class.hbrBackground = 0; 103 | window_class.lpszMenuName = nullptr; 104 | window_class.lpfnWndProc = Win32Window::WndProc; 105 | RegisterClass(&window_class); 106 | class_registered_ = true; 107 | } 108 | return kWindowClassName; 109 | } 110 | 111 | void WindowClassRegistrar::UnregisterWindowClass() { 112 | UnregisterClass(kWindowClassName, nullptr); 113 | class_registered_ = false; 114 | } 115 | 116 | Win32Window::Win32Window() { ++g_active_window_count; } 117 | 118 | Win32Window::~Win32Window() { 119 | --g_active_window_count; 120 | Destroy(); 121 | } 122 | 123 | bool Win32Window::Create(const std::wstring &title, const Point &origin, 124 | const Size &size) { 125 | Destroy(); 126 | 127 | const wchar_t *window_class = 128 | WindowClassRegistrar::GetInstance()->GetWindowClass(); 129 | 130 | const POINT target_point = {static_cast(origin.x), 131 | static_cast(origin.y)}; 132 | HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); 133 | UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); 134 | double scale_factor = dpi / 96.0; 135 | 136 | HWND window = CreateWindow( 137 | // window_class, title.c_str(), WS_OVERLAPPEDWINDOW, 138 | window_class, title.c_str(), 139 | WS_OVERLAPPEDWINDOW, // do not add WS_VISIBLE since the window will be 140 | // shown later 141 | Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), 142 | Scale(size.width, scale_factor), Scale(size.height, scale_factor), 143 | nullptr, nullptr, GetModuleHandle(nullptr), this); 144 | 145 | if (!window) { 146 | return false; 147 | } 148 | 149 | UpdateTheme(window); 150 | 151 | return OnCreate(); 152 | } 153 | 154 | bool Win32Window::Show() { return ShowWindow(window_handle_, SW_SHOWNORMAL); } 155 | 156 | // static 157 | LRESULT CALLBACK Win32Window::WndProc(HWND const window, UINT const message, 158 | WPARAM const wparam, 159 | LPARAM const lparam) noexcept { 160 | if (message == WM_NCCREATE) { 161 | auto window_struct = reinterpret_cast(lparam); 162 | SetWindowLongPtr(window, GWLP_USERDATA, 163 | reinterpret_cast(window_struct->lpCreateParams)); 164 | 165 | auto that = static_cast(window_struct->lpCreateParams); 166 | EnableFullDpiSupportIfAvailable(window); 167 | that->window_handle_ = window; 168 | } else if (Win32Window *that = GetThisFromHandle(window)) { 169 | return that->MessageHandler(window, message, wparam, lparam); 170 | } 171 | 172 | return DefWindowProc(window, message, wparam, lparam); 173 | } 174 | 175 | LRESULT 176 | Win32Window::MessageHandler(HWND hwnd, UINT const message, WPARAM const wparam, 177 | LPARAM const lparam) noexcept { 178 | switch (message) { 179 | case WM_DESTROY: 180 | window_handle_ = nullptr; 181 | Destroy(); 182 | if (quit_on_close_) { 183 | PostQuitMessage(0); 184 | } 185 | return 0; 186 | 187 | case WM_DPICHANGED: { 188 | auto newRectSize = reinterpret_cast(lparam); 189 | LONG newWidth = newRectSize->right - newRectSize->left; 190 | LONG newHeight = newRectSize->bottom - newRectSize->top; 191 | 192 | SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, 193 | newHeight, SWP_NOZORDER | SWP_NOACTIVATE); 194 | 195 | return 0; 196 | } 197 | case WM_SIZE: { 198 | RECT rect = GetClientArea(); 199 | if (child_content_ != nullptr) { 200 | // Size and position the child window. 201 | MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, 202 | rect.bottom - rect.top, TRUE); 203 | } 204 | return 0; 205 | } 206 | 207 | case WM_ACTIVATE: 208 | if (child_content_ != nullptr) { 209 | SetFocus(child_content_); 210 | } 211 | return 0; 212 | 213 | case WM_DWMCOLORIZATIONCOLORCHANGED: 214 | UpdateTheme(hwnd); 215 | return 0; 216 | } 217 | 218 | return DefWindowProc(window_handle_, message, wparam, lparam); 219 | } 220 | 221 | void Win32Window::Destroy() { 222 | OnDestroy(); 223 | 224 | if (window_handle_) { 225 | DestroyWindow(window_handle_); 226 | window_handle_ = nullptr; 227 | } 228 | if (g_active_window_count == 0) { 229 | WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); 230 | } 231 | } 232 | 233 | Win32Window *Win32Window::GetThisFromHandle(HWND const window) noexcept { 234 | return reinterpret_cast( 235 | GetWindowLongPtr(window, GWLP_USERDATA)); 236 | } 237 | 238 | void Win32Window::SetChildContent(HWND content) { 239 | child_content_ = content; 240 | SetParent(content, window_handle_); 241 | RECT frame = GetClientArea(); 242 | 243 | MoveWindow(content, frame.left, frame.top, frame.right - frame.left, 244 | frame.bottom - frame.top, true); 245 | 246 | SetFocus(child_content_); 247 | } 248 | 249 | RECT Win32Window::GetClientArea() { 250 | RECT frame; 251 | GetClientRect(window_handle_, &frame); 252 | return frame; 253 | } 254 | 255 | HWND Win32Window::GetHandle() { return window_handle_; } 256 | 257 | void Win32Window::SetQuitOnClose(bool quit_on_close) { 258 | quit_on_close_ = quit_on_close; 259 | } 260 | 261 | bool Win32Window::OnCreate() { 262 | // No-op; provided for subclasses. 263 | return true; 264 | } 265 | 266 | void Win32Window::OnDestroy() { 267 | // No-op; provided for subclasses. 268 | } 269 | 270 | void Win32Window::UpdateTheme(HWND const window) { 271 | DWORD light_mode; 272 | DWORD light_mode_size = sizeof(light_mode); 273 | LSTATUS result = 274 | RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, 275 | kGetPreferredBrightnessRegValue, RRF_RT_REG_DWORD, nullptr, 276 | &light_mode, &light_mode_size); 277 | 278 | if (result == ERROR_SUCCESS) { 279 | BOOL enable_dark_mode = light_mode == 0; 280 | DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, 281 | &enable_dark_mode, sizeof(enable_dark_mode)); 282 | } 283 | } 284 | -------------------------------------------------------------------------------- /example/chat_app/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 | -------------------------------------------------------------------------------- /lib/chat.dart: -------------------------------------------------------------------------------- 1 | library chat; 2 | 3 | class Placeholder { 4 | const Placeholder._(); 5 | } 6 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: chat 2 | description: The Chat 3 | version: 0.0.1-dev 4 | homepage: https://github.com/plugfox/chat 5 | repository: https://github.com/plugfox/chat 6 | issue_tracker: https://github.com/plugfox/chat/issues 7 | 8 | funding: 9 | - https://www.buymeacoffee.com/plugfox 10 | - https://www.patreon.com/plugfox 11 | - https://boosty.to/plugfox 12 | 13 | topics: 14 | - chat 15 | - websocket 16 | - cross-platform 17 | - reconnect 18 | - socket 19 | 20 | platforms: 21 | android: 22 | ios: 23 | linux: 24 | macos: 25 | web: 26 | windows: 27 | 28 | #screenshots: 29 | # - description: 'Example of using the library.' 30 | # path: example.png 31 | 32 | environment: 33 | sdk: ">=3.0.0 <4.0.0" 34 | flutter: ">=3.10.0" 35 | 36 | 37 | dependencies: 38 | # Flutter SDK 39 | flutter: 40 | sdk: flutter 41 | meta: ^1.9.0 42 | 43 | 44 | dev_dependencies: 45 | test: ^1.21.0 46 | 47 | 48 | flutter: 49 | uses-material-design: true -------------------------------------------------------------------------------- /test/test.dart: -------------------------------------------------------------------------------- 1 | void main() {} 2 | --------------------------------------------------------------------------------