├── .gitignore ├── .metadata ├── CHANGELOG.md ├── CODEOWNERS ├── LICENSE ├── README.md ├── analysis_options.yaml ├── example ├── .gitignore ├── .metadata ├── README.md ├── analysis_options.yaml ├── android │ ├── .gitignore │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── liugl │ │ │ │ │ └── stack_board_example │ │ │ │ │ └── MainActivity.java │ │ │ └── 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 ├── ios │ ├── .gitignore │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ └── Release.xcconfig │ ├── Podfile │ ├── 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 ├── lib │ └── main.dart ├── linux │ ├── .gitignore │ ├── CMakeLists.txt │ ├── flutter │ │ ├── CMakeLists.txt │ │ ├── generated_plugin_registrant.cc │ │ ├── generated_plugin_registrant.h │ │ └── generated_plugins.cmake │ ├── main.cc │ ├── my_application.cc │ └── my_application.h ├── macos │ ├── .gitignore │ ├── Flutter │ │ ├── Flutter-Debug.xcconfig │ │ ├── Flutter-Release.xcconfig │ │ └── GeneratedPluginRegistrant.swift │ ├── Podfile │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ └── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── app_icon_1024.png │ │ │ ├── app_icon_128.png │ │ │ ├── app_icon_16.png │ │ │ ├── app_icon_256.png │ │ │ ├── app_icon_32.png │ │ │ ├── app_icon_512.png │ │ │ └── app_icon_64.png │ │ ├── Base.lproj │ │ └── MainMenu.xib │ │ ├── Configs │ │ ├── AppInfo.xcconfig │ │ ├── Debug.xcconfig │ │ ├── Release.xcconfig │ │ └── Warnings.xcconfig │ │ ├── DebugProfile.entitlements │ │ ├── Info.plist │ │ ├── MainFlutterWindow.swift │ │ └── Release.entitlements ├── pubspec.lock ├── pubspec.yaml ├── test │ └── widget_test.dart ├── web │ ├── favicon.png │ ├── icons │ │ ├── Icon-192.png │ │ ├── Icon-512.png │ │ ├── Icon-maskable-192.png │ │ └── Icon-maskable-512.png │ ├── index.html │ └── manifest.json └── windows │ ├── .gitignore │ ├── CMakeLists.txt │ ├── flutter │ ├── CMakeLists.txt │ ├── generated_plugin_registrant.cc │ ├── generated_plugin_registrant.h │ └── generated_plugins.cmake │ └── runner │ ├── CMakeLists.txt │ ├── Runner.rc │ ├── flutter_window.cpp │ ├── flutter_window.h │ ├── main.cpp │ ├── resource.h │ ├── resources │ └── app_icon.ico │ ├── runner.exe.manifest │ ├── utils.cpp │ ├── utils.h │ ├── win32_window.cpp │ └── win32_window.h ├── lib ├── flutter_stack_board.dart ├── helpers.dart ├── src │ ├── core │ │ ├── case_style.dart │ │ ├── stack_board_controller.dart │ │ └── stack_board_item │ │ │ ├── stack_item.dart │ │ │ ├── stack_item_content.dart │ │ │ └── stack_item_status.dart │ ├── helpers │ │ ├── as_t.dart │ │ ├── ex_enum.dart │ │ ├── ex_list.dart │ │ ├── safe_state.dart │ │ └── safe_value_notifier.dart │ ├── stack_board.dart │ ├── stack_board_items │ │ ├── item_case │ │ │ ├── stack_draw_case.dart │ │ │ ├── stack_image_case.dart │ │ │ └── stack_text_case.dart │ │ └── items │ │ │ ├── stack_draw_item.dart │ │ │ ├── stack_image_item.dart │ │ │ └── stack_text_item.dart │ ├── stack_item_case │ │ ├── config_builder.dart │ │ └── stack_item_case.dart │ ├── widget_style_extension │ │ ├── ex_locale.dart │ │ ├── ex_offset.dart │ │ ├── ex_size.dart │ │ ├── ex_text_height_behavior.dart │ │ ├── ex_text_style.dart │ │ └── stack_text_strut_style.dart │ └── widgets │ │ ├── ex_builder.dart │ │ └── get_size.dart ├── stack_board_item.dart ├── stack_board_items.dart ├── stack_case.dart ├── stack_items.dart └── widget_style_extension.dart ├── pubspec.lock ├── pubspec.yaml └── test └── stack_board_items └── items ├── stack_draw_item.dart ├── stack_image_item.dart └── stack_text_item.dart /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | .dart_tool/ 26 | .flutter-plugins 27 | .flutter-plugins-dependencies 28 | .packages 29 | .pub-cache/ 30 | .pub/ 31 | build/ 32 | 33 | # Android related 34 | **/android/**/gradle-wrapper.jar 35 | **/android/.gradle 36 | **/android/captures/ 37 | **/android/gradlew 38 | **/android/gradlew.bat 39 | **/android/local.properties 40 | **/android/**/GeneratedPluginRegistrant.java 41 | 42 | # iOS/XCode related 43 | **/ios/**/*.mode1v3 44 | **/ios/**/*.mode2v3 45 | **/ios/**/*.moved-aside 46 | **/ios/**/*.pbxuser 47 | **/ios/**/*.perspectivev3 48 | **/ios/**/*sync/ 49 | **/ios/**/.sconsign.dblite 50 | **/ios/**/.tags* 51 | **/ios/**/.vagrant/ 52 | **/ios/**/DerivedData/ 53 | **/ios/**/Icon? 54 | **/ios/**/Pods/ 55 | **/ios/**/.symlinks/ 56 | **/ios/**/profile 57 | **/ios/**/xcuserdata 58 | **/ios/.generated/ 59 | **/ios/Flutter/App.framework 60 | **/ios/Flutter/Flutter.framework 61 | **/ios/Flutter/Flutter.podspec 62 | **/ios/Flutter/Generated.xcconfig 63 | **/ios/Flutter/ephemeral 64 | **/ios/Flutter/app.flx 65 | **/ios/Flutter/app.zip 66 | **/ios/Flutter/flutter_assets/ 67 | **/ios/Flutter/flutter_export_environment.sh 68 | **/ios/ServiceDefinitions.json 69 | **/ios/Runner/GeneratedPluginRegistrant.* 70 | 71 | # Exceptions to above rules. 72 | !**/ios/**/default.mode1v3 73 | !**/ios/**/default.mode2v3 74 | !**/ios/**/default.pbxuser 75 | !**/ios/**/default.perspectivev3 76 | example/pubspec.lock 77 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: 18116933e77adc82f80866c928266a5b4f1ed645 8 | channel: stable 9 | 10 | project_type: package 11 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.2.6+1 2 | 3 | * Fix syntax issues 4 | 5 | ## 0.2.6 6 | 7 | * Merged #15 #13 8 | 9 | ## 0.2.5 10 | 11 | * Merged #12, add lock z order 12 | * Fix sorting exception 13 | * Fix click unresponsiveness 14 | 15 | ## 0.2.4 16 | 17 | * Add web [demo](https://xsilencex.github.io/stack_board_demo/) 18 | 19 | ## 0.2.3 20 | 21 | * Fix syntax errors 22 | 23 | ## 0.2.2 24 | 25 | * Pass static analysis 26 | * Update plugins 27 | 28 | ## 0.2.1 29 | 30 | * Merged #9 31 | * Fix: Images not displaying from JSON in Windows app 32 | 33 | ## 0.2.0 34 | 35 | * Merged #8 36 | * Working improved version inspired by Canva editor 37 | 38 | ## 0.1.2 39 | 40 | * Modify the type determination method 41 | 42 | 43 | ## 0.1.1 44 | 45 | * Update dependencies, pass static analysis 46 | 47 | 48 | ## 0.1.0 49 | 50 | * Update dependencies 51 | 52 | 53 | ## 0.0.9 54 | 55 | * Fix bug, new example 56 | 57 | 58 | ## 0.0.8 59 | 60 | * Fix bug, add click to top and update dependencies 61 | 62 | 63 | ## 0.0.7 64 | 65 | * Add init offset config 66 | 67 | 68 | ## 0.0.6 69 | 70 | * Update dependencies, improve code quality 71 | 72 | 73 | ## 0.0.5 74 | 75 | * Update dependencies 76 | 77 | ## 0.0.4 78 | 79 | * Add rotate operation 80 | 81 | 82 | ## 0.0.3 83 | 84 | * Fix some problems 85 | 86 | 87 | ## 0.0.2 88 | 89 | * Support web 90 | 91 | 92 | ## 0.0.1 93 | 94 | * Complete basic functions 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @xSILENCEx 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2021 xSILENCEx 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Stack Board 2 | 3 | A Flutter package of custom stack board. 4 | 5 | [![pub package](https://img.shields.io/pub/v/stack_board?logo=dart&label=stable&style=flat-square)](https://pub.dev/packages/stack_board) 6 | [![GitHub stars](https://img.shields.io/github/stars/fluttercandies/stack_board?logo=github&style=flat-square)](https://github.com/fluttercandies/stack_board/stargazers) 7 | [![GitHub forks](https://img.shields.io/github/forks/fluttercandies/stack_board?logo=github&style=flat-square)](https://github.com/fluttercandies/stack_board/network/members) 8 | [![CodeFactor](https://img.shields.io/codefactor/grade/github/fluttercandies/stack_board?logo=codefactor&logoColor=%23ffffff&style=flat-square)](https://www.codefactor.io/repository/github/fluttercandies/stack_board) 9 | FlutterCandies 10 | 11 |
12 | 13 | Try it: [Demo](https://xsilencex.github.io/stack_board_demo/) 14 | 15 |
16 | 17 | ## 1.使用 StackBoardController 18 | 19 |
20 | 21 | ```dart 22 | import 'package:stack_board/stack_board.dart'; 23 | 24 | StackBoard( 25 | controller: _boardController, 26 | ///添加背景 27 | background: const ColoredBox(color: Colors.grey), 28 | ), 29 | ``` 30 | 31 | ### 添加自适应文本 32 | 33 |
34 | 35 | 36 | 37 |
38 | 39 | ```dart 40 | _boardController.add( 41 | const AdaptiveText( 42 | 'Flutter Candies', 43 | tapToEdit: true, 44 | style: TextStyle(fontWeight: FontWeight.bold), 45 | ), 46 | ); 47 | ``` 48 | 49 |
50 | 51 | ### 添加自适应图片 52 | 53 |
54 | 55 | 56 | 57 |
58 | 59 | ```dart 60 | _boardController.add( 61 | StackBoardItem( 62 | child: Image.network('https://avatars.githubusercontent.com/u/47586449?s=200&v=4'), 63 | ), 64 | ); 65 | ``` 66 | 67 |
68 | 69 | ### 添加画板 70 | 71 |
72 | 73 | 74 | 75 |
76 | 77 | ```dart 78 | _boardController.add( 79 | const StackDrawing( 80 | caseStyle: CaseStyle( 81 | borderColor: Colors.grey, 82 | iconColor: Colors.white, 83 | boxAspectRatio: 1, 84 | ), 85 | ), 86 | ); 87 | ``` 88 | 89 |
90 | 91 | ### 添加自定义item 92 | 93 |
94 | 95 | 96 | 97 |
98 | 99 | > 1.继承自 StackItemContent 和 StackItem 100 | ```dart 101 | class ColorContent extends StackItemContent { 102 | ColorContent({required this.color}); 103 | 104 | Color color; 105 | 106 | @override 107 | Map toJson() { 108 | return { 109 | 'color': color.value, 110 | }; 111 | } 112 | } 113 | 114 | class ColorStackItem extends StackItem { 115 | ColorStackItem({ 116 | required Size size, 117 | String? id, 118 | Offset? offset, 119 | double? angle, 120 | StackItemStatus? status, 121 | ColorContent? content, 122 | }) : super( 123 | id: id, 124 | size: size, 125 | offset: offset, 126 | angle: angle, 127 | status: status, 128 | content: content, 129 | ); 130 | 131 | @override 132 | ColorStackItem copyWith({ 133 | Size? size, 134 | Offset? offset, 135 | double? angle, 136 | StackItemStatus? status, 137 | ColorContent? content, 138 | }) { 139 | return ColorStackItem( 140 | id: id, // <= must !! 141 | size: size ?? this.size, 142 | offset: offset ?? this.offset, 143 | angle: angle ?? this.angle, 144 | status: status ?? this.status, 145 | content: content ?? this.content, 146 | ); 147 | } 148 | } 149 | ``` 150 | > 2.使用controller添加 151 | ```dart 152 | import 'dart:math' as math; 153 | 154 | ... 155 | 156 | /// Add custom item 157 | void _addCustomItem() { 158 | final Color color = Colors.primaries[Random().nextInt(Colors.primaries.length)]; 159 | _boardController.addItem( 160 | ColorStackItem( 161 | size: const Size.square(100), 162 | content: ColorContent(color: color), 163 | ), 164 | ); 165 | } 166 | ``` 167 | > 3.使用customBuilder构建 168 | ```dart 169 | StackBoard( 170 | controller: _boardController, 171 | /// 如果使用了继承于StackBoardItem的自定义item 172 | /// 使用这个接口进行重构 173 | customBuilder: (StackItem item) { 174 | if (...) { 175 | 176 | ... 177 | 178 | } else if (item is ColorStackItem) { 179 | return Container( 180 | width: item.size.width, 181 | height: item.size.height, 182 | color: item.content?.color, 183 | ); 184 | } 185 | 186 | ... 187 | }, 188 | ) 189 | ``` 190 | 191 | 192 | 193 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # Specify analysis options. 2 | # 3 | # Until there are meta linter rules, each desired lint must be explicitly enabled. 4 | # See: https://github.com/dart-lang/linter/issues/288 5 | # 6 | # For a list of lints, see: http://dart-lang.github.io/linter/lints/ 7 | # See the configuration guide for more 8 | # https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer 9 | # 10 | # There are other similar analysis options files in the flutter repos, 11 | # which should be kept in sync with this file: 12 | # 13 | # - analysis_options.yaml (this file) 14 | # - packages/flutter/lib/analysis_options_user.yaml 15 | # - https://github.com/flutter/plugins/blob/master/analysis_options.yaml 16 | # - https://github.com/flutter/engine/blob/master/analysis_options.yaml 17 | # 18 | # This file contains the analysis options used by Flutter tools, such as IntelliJ, 19 | # Android Studio, and the `flutter analyze` command. 20 | 21 | analyzer: 22 | strong-mode: 23 | implicit-casts: false 24 | implicit-dynamic: false 25 | errors: 26 | # treat missing required parameters as a warning (not a hint) 27 | missing_required_param: warning 28 | # treat missing returns as a warning (not a hint) 29 | missing_return: warning 30 | # allow having TODOs in the code 31 | todo: ignore 32 | # allow self-reference to deprecated members (we do this because otherwise we have 33 | # to annotate every member in every test, assert, etc, when we deprecate something) 34 | deprecated_member_use_from_same_package: ignore 35 | exclude: 36 | - "bin/cache/**" 37 | # the following two are relative to the stocks example and the flutter package respectively 38 | # see https://github.com/dart-lang/sdk/issues/28463 39 | - "lib/i18n/messages_*.dart" 40 | - "lib/src/http/**" 41 | - "test_fixes/**" 42 | 43 | linter: 44 | rules: 45 | # these rules are documented on and in the same order as 46 | # the Dart Lint rules page to make maintenance easier 47 | # https://github.com/dart-lang/linter/blob/master/example/all.yaml 48 | - always_declare_return_types 49 | # - always_put_control_body_on_new_line 50 | - always_specify_types 51 | # - always_use_package_imports # we do this commonly 52 | - annotate_overrides 53 | # - avoid_annotating_with_dynamic # conflicts with always_specify_types 54 | # - avoid_as # required for implicit-casts: true 55 | - avoid_bool_literals_in_conditional_expressions 56 | # - avoid_catches_without_on_clauses # we do this commonly 57 | # - avoid_catching_errors # we do this commonly 58 | - avoid_classes_with_only_static_members 59 | # - avoid_double_and_int_checks # only useful when targeting JS runtime 60 | - avoid_empty_else 61 | - avoid_equals_and_hash_code_on_mutable_classes 62 | # - avoid_escaping_inner_quotes # not yet tested 63 | - avoid_field_initializers_in_const_classes 64 | - avoid_function_literals_in_foreach_calls 65 | # - avoid_implementing_value_types # not yet tested 66 | - avoid_init_to_null 67 | # - avoid_js_rounded_ints # only useful when targeting JS runtime 68 | - avoid_null_checks_in_equality_operators 69 | # - avoid_positional_boolean_parameters # not yet tested 70 | # - avoid_print # not yet tested 71 | # - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356) 72 | # - avoid_redundant_argument_values # not yet tested 73 | - avoid_relative_lib_imports 74 | - avoid_renaming_method_parameters 75 | - avoid_return_types_on_setters 76 | # - avoid_returning_null # there are plenty of valid reasons to return null 77 | # - avoid_returning_null_for_future # not yet tested 78 | - avoid_returning_null_for_void 79 | # - avoid_returning_this # there are plenty of valid reasons to return this 80 | # - avoid_setters_without_getters # not yet tested 81 | - avoid_shadowing_type_parameters 82 | - avoid_single_cascade_in_expression_statements 83 | - avoid_slow_async_io 84 | # - avoid_type_to_string # we do this commonly 85 | - avoid_types_as_parameter_names 86 | # - avoid_types_on_closure_parameters # conflicts with always_specify_types 87 | # - avoid_unnecessary_containers # not yet tested 88 | - avoid_unused_constructor_parameters 89 | - avoid_void_async 90 | # - avoid_web_libraries_in_flutter # not yet tested 91 | - await_only_futures 92 | - camel_case_extensions 93 | - camel_case_types 94 | - cancel_subscriptions 95 | # - cascade_invocations # not yet tested 96 | # - close_sinks # not reliable enough 97 | # - comment_references # blocked on https://github.com/flutter/flutter/issues/20765 98 | # - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204 99 | - control_flow_in_finally 100 | # - curly_braces_in_flow_control_structures # not required by flutter style 101 | # - diagnostic_describe_all_properties # not yet tested 102 | - directives_ordering 103 | # - do_not_use_environment # we do this commonly 104 | - empty_catches 105 | - empty_constructor_bodies 106 | - empty_statements 107 | - exhaustive_cases 108 | # - file_names # not yet tested 109 | - flutter_style_todos 110 | - hash_and_equals 111 | - implementation_imports 112 | # - join_return_with_assignment # not required by flutter style 113 | - leading_newlines_in_multiline_strings 114 | - library_names 115 | - library_prefixes 116 | # - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181 117 | # - missing_whitespace_between_adjacent_strings # not yet tested 118 | - no_adjacent_strings_in_list 119 | # - no_default_cases # too many false positives 120 | - no_duplicate_case_values 121 | - no_logic_in_create_state 122 | # - no_runtimeType_toString # ok in tests; we enable this only in packages/ 123 | - non_constant_identifier_names 124 | # - null_closures # not required by flutter style 125 | # - omit_local_variable_types # opposite of always_specify_types 126 | # - one_member_abstracts # too many false positives 127 | # - only_throw_errors # https://github.com/flutter/flutter/issues/5792 128 | - overridden_fields 129 | - package_api_docs 130 | # - package_names # non conforming packages in sdk 131 | - package_prefixed_library_names 132 | # - parameter_assignments # we do this commonly 133 | - prefer_adjacent_string_concatenation 134 | - prefer_asserts_in_initializer_lists 135 | # - prefer_asserts_with_message # not required by flutter style 136 | - prefer_collection_literals 137 | - prefer_conditional_assignment 138 | - prefer_const_constructors 139 | - prefer_const_constructors_in_immutables 140 | - prefer_const_declarations 141 | - prefer_const_literals_to_create_immutables 142 | # - prefer_constructors_over_static_methods # far too many false positives 143 | - prefer_contains 144 | # - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods 145 | - prefer_final_fields 146 | - prefer_final_in_for_each 147 | - prefer_final_locals 148 | - prefer_for_elements_to_map_fromIterable 149 | - prefer_foreach 150 | # - prefer_function_declarations_over_variables # not yet tested 151 | - prefer_generic_function_type_aliases 152 | - prefer_if_elements_to_conditional_expressions 153 | - prefer_if_null_operators 154 | - prefer_initializing_formals 155 | - prefer_inlined_adds 156 | # - prefer_int_literals # not yet tested 157 | # - prefer_interpolation_to_compose_strings # not yet tested 158 | - prefer_is_empty 159 | - prefer_is_not_empty 160 | - prefer_is_not_operator 161 | - prefer_iterable_whereType 162 | # - prefer_mixin # https://github.com/dart-lang/language/issues/32 163 | # - prefer_null_aware_operators # disable until NNBD, see https://github.com/flutter/flutter/pull/32711#issuecomment-492930932 164 | # - prefer_relative_imports # not yet tested 165 | - prefer_single_quotes 166 | - prefer_spread_collections 167 | - prefer_typing_uninitialized_variables 168 | - prefer_void_to_null 169 | # - provide_deprecation_message # not yet tested 170 | # - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml 171 | - recursive_getters 172 | # - sized_box_for_whitespace # not yet tested 173 | - slash_for_doc_comments 174 | # - sort_child_properties_last # not yet tested 175 | - sort_constructors_first 176 | # - sort_pub_dependencies # prevents separating pinned transitive dependencies 177 | - sort_unnamed_constructors_first 178 | - test_types_in_equals 179 | - throw_in_finally 180 | # - type_annotate_public_apis # subset of always_specify_types 181 | - type_init_formals 182 | # - unawaited_futures # too many false positives 183 | # - unnecessary_await_in_return # not yet tested 184 | - unnecessary_brace_in_string_interps 185 | - unnecessary_const 186 | # - unnecessary_final # conflicts with prefer_final_locals 187 | - unnecessary_getters_setters 188 | # - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498 189 | - unnecessary_new 190 | - unnecessary_null_aware_assignments 191 | # - unnecessary_null_checks # not yet tested 192 | - unnecessary_null_in_if_null_operators 193 | - unnecessary_nullable_for_final_variable_declarations 194 | - unnecessary_overrides 195 | - unnecessary_parenthesis 196 | # - unnecessary_raw_strings # not yet tested 197 | - unnecessary_statements 198 | - unnecessary_string_escapes 199 | - unnecessary_string_interpolations 200 | - unnecessary_this 201 | - unrelated_type_equality_checks 202 | # - unsafe_html # not yet tested 203 | - use_full_hex_values_for_flutter_colors 204 | # - use_function_type_syntax_for_parameters # not yet tested 205 | - use_is_even_rather_than_modulo 206 | # - use_key_in_widget_constructors # not yet tested 207 | - use_late_for_private_fields_and_variables 208 | - use_raw_strings 209 | - use_rethrow_when_possible 210 | # - use_setters_to_change_properties # not yet tested 211 | # - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182 212 | # - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review 213 | - valid_regexps 214 | - void_checks -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | **/ios/Flutter/.last_build_id 26 | .dart_tool/ 27 | .flutter-plugins 28 | .flutter-plugins-dependencies 29 | .packages 30 | .pub-cache/ 31 | .pub/ 32 | /build/ 33 | 34 | # Web related 35 | 36 | # Symbolication related 37 | app.*.symbols 38 | 39 | # Obfuscation related 40 | app.*.map.json 41 | 42 | # Android Studio will place build artifacts here 43 | /android/app/debug 44 | /android/app/profile 45 | /android/app/release 46 | -------------------------------------------------------------------------------- /example/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: 18116933e77adc82f80866c928266a5b4f1ed645 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # stack_board_example 2 | 3 | Demonstrates how to use the stack_board plugin. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) 13 | 14 | For help getting started with Flutter, view our 15 | [online documentation](https://flutter.dev/docs), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /example/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/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion 30 30 | 31 | compileOptions { 32 | sourceCompatibility JavaVersion.VERSION_1_8 33 | targetCompatibility JavaVersion.VERSION_1_8 34 | } 35 | 36 | kotlinOptions { 37 | jvmTarget = '1.8' 38 | } 39 | 40 | sourceSets { 41 | main.java.srcDirs += 'src/main/kotlin' 42 | } 43 | 44 | defaultConfig { 45 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 46 | applicationId "com.liugl.stack_board_example" 47 | minSdkVersion flutter.minSdkVersion 48 | targetSdkVersion 30 49 | versionCode flutterVersionCode.toInteger() 50 | versionName flutterVersionName 51 | } 52 | 53 | buildTypes { 54 | release { 55 | // TODO: Add your own signing config for the release build. 56 | // Signing with the debug keys for now, so `flutter run --release` works. 57 | signingConfig signingConfigs.debug 58 | } 59 | } 60 | } 61 | 62 | flutter { 63 | source '../..' 64 | } 65 | 66 | dependencies { 67 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 68 | } 69 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 13 | 17 | 21 | 26 | 30 | 31 | 32 | 33 | 34 | 35 | 37 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/liugl/stack_board_example/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.liugl.stack_board_example; 2 | 3 | import io.flutter.embedding.android.FlutterActivity; 4 | 5 | public class MainActivity extends FlutterActivity { 6 | } 7 | 8 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.3.50' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:4.1.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 | project.evaluationDependsOn(':app') 25 | } 26 | 27 | tasks.register("clean", Delete) { 28 | delete rootProject.buildDir 29 | } 30 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip 7 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /example/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/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 | 12.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '12.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | end 36 | 37 | post_install do |installer| 38 | installer.pods_project.targets.each do |target| 39 | flutter_additional_ios_build_settings(target) 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/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/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/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /example/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/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/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/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/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/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | stack_board_example 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(FLUTTER_BUILD_NAME) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UIViewControllerBasedStatusBarAppearance 43 | 44 | CADisableMinimumFrameDurationOnPhone 45 | 46 | UIApplicationSupportsIndirectInputEvents 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /example/linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /example/linux/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | project(runner LANGUAGES CXX) 3 | 4 | set(BINARY_NAME "stack_board_example") 5 | set(APPLICATION_ID "com.liugl.stack_board") 6 | 7 | cmake_policy(SET CMP0063 NEW) 8 | 9 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 10 | 11 | # Root filesystem for cross-building. 12 | if(FLUTTER_TARGET_PLATFORM_SYSROOT) 13 | set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) 14 | set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) 15 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 16 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 17 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 18 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 19 | endif() 20 | 21 | # Configure build options. 22 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 23 | set(CMAKE_BUILD_TYPE "Debug" CACHE 24 | STRING "Flutter build mode" FORCE) 25 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 26 | "Debug" "Profile" "Release") 27 | endif() 28 | 29 | # Compilation settings that should be applied to most targets. 30 | function(APPLY_STANDARD_SETTINGS TARGET) 31 | target_compile_features(${TARGET} PUBLIC cxx_std_14) 32 | target_compile_options(${TARGET} PRIVATE -Wall -Werror) 33 | target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") 34 | target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") 35 | endfunction() 36 | 37 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 38 | 39 | # Flutter library and tool build rules. 40 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 41 | 42 | # System-level dependencies. 43 | find_package(PkgConfig REQUIRED) 44 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 45 | 46 | add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") 47 | 48 | # Application build 49 | add_executable(${BINARY_NAME} 50 | "main.cc" 51 | "my_application.cc" 52 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 53 | ) 54 | apply_standard_settings(${BINARY_NAME}) 55 | target_link_libraries(${BINARY_NAME} PRIVATE flutter) 56 | target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) 57 | add_dependencies(${BINARY_NAME} flutter_assemble) 58 | # Only the install-generated bundle's copy of the executable will launch 59 | # correctly, since the resources must in the right relative locations. To avoid 60 | # people trying to run the unbundled copy, put it in a subdirectory instead of 61 | # the default top-level location. 62 | set_target_properties(${BINARY_NAME} 63 | PROPERTIES 64 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" 65 | ) 66 | 67 | # Generated plugin build rules, which manage building the plugins and adding 68 | # them to the application. 69 | include(flutter/generated_plugins.cmake) 70 | 71 | 72 | # === Installation === 73 | # By default, "installing" just makes a relocatable bundle in the build 74 | # directory. 75 | set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") 76 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 77 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 78 | endif() 79 | 80 | # Start with a clean build bundle directory every time. 81 | install(CODE " 82 | file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") 83 | " COMPONENT Runtime) 84 | 85 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 86 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") 87 | 88 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 89 | COMPONENT Runtime) 90 | 91 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 92 | COMPONENT Runtime) 93 | 94 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 95 | COMPONENT Runtime) 96 | 97 | if(PLUGIN_BUNDLED_LIBRARIES) 98 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 99 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 100 | COMPONENT Runtime) 101 | endif() 102 | 103 | # Fully re-copy the assets directory on each build to avoid having stale files 104 | # from a previous install. 105 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 106 | install(CODE " 107 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 108 | " COMPONENT Runtime) 109 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 110 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 111 | 112 | # Install the AOT library on non-Debug builds only. 113 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") 114 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 115 | COMPONENT Runtime) 116 | endif() 117 | -------------------------------------------------------------------------------- /example/linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 4 | 5 | # Configuration provided via flutter tool. 6 | include(${EPHEMERAL_DIR}/generated_config.cmake) 7 | 8 | # TODO: Move the rest of this into files in ephemeral. See 9 | # https://github.com/flutter/flutter/issues/57146. 10 | 11 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 12 | # which isn't available in 3.10. 13 | function(list_prepend LIST_NAME PREFIX) 14 | set(NEW_LIST "") 15 | foreach(element ${${LIST_NAME}}) 16 | list(APPEND NEW_LIST "${PREFIX}${element}") 17 | endforeach(element) 18 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 19 | endfunction() 20 | 21 | # === Flutter Library === 22 | # System-level dependencies. 23 | find_package(PkgConfig REQUIRED) 24 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 25 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 26 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 27 | 28 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 29 | 30 | # Published to parent scope for install step. 31 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 32 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 33 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 34 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 35 | 36 | list(APPEND FLUTTER_LIBRARY_HEADERS 37 | "fl_basic_message_channel.h" 38 | "fl_binary_codec.h" 39 | "fl_binary_messenger.h" 40 | "fl_dart_project.h" 41 | "fl_engine.h" 42 | "fl_json_message_codec.h" 43 | "fl_json_method_codec.h" 44 | "fl_message_codec.h" 45 | "fl_method_call.h" 46 | "fl_method_channel.h" 47 | "fl_method_codec.h" 48 | "fl_method_response.h" 49 | "fl_plugin_registrar.h" 50 | "fl_plugin_registry.h" 51 | "fl_standard_message_codec.h" 52 | "fl_standard_method_codec.h" 53 | "fl_string_codec.h" 54 | "fl_value.h" 55 | "fl_view.h" 56 | "flutter_linux.h" 57 | ) 58 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 59 | add_library(flutter INTERFACE) 60 | target_include_directories(flutter INTERFACE 61 | "${EPHEMERAL_DIR}" 62 | ) 63 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 64 | target_link_libraries(flutter INTERFACE 65 | PkgConfig::GTK 66 | PkgConfig::GLIB 67 | PkgConfig::GIO 68 | ) 69 | add_dependencies(flutter flutter_assemble) 70 | 71 | # === Flutter tool backend === 72 | # _phony_ is a non-existent file to force this command to run every time, 73 | # since currently there's no way to get a full input/output list from the 74 | # flutter tool. 75 | add_custom_command( 76 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 77 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 78 | COMMAND ${CMAKE_COMMAND} -E env 79 | ${FLUTTER_TOOL_ENVIRONMENT} 80 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 81 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 82 | VERBATIM 83 | ) 84 | add_custom_target(flutter_assemble DEPENDS 85 | "${FLUTTER_LIBRARY}" 86 | ${FLUTTER_LIBRARY_HEADERS} 87 | ) 88 | -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | 10 | void fl_register_plugins(FlPluginRegistry* registry) { 11 | } 12 | -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | ) 7 | 8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 9 | ) 10 | 11 | set(PLUGIN_BUNDLED_LIBRARIES) 12 | 13 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 18 | endforeach(plugin) 19 | 20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 23 | endforeach(ffi_plugin) 24 | -------------------------------------------------------------------------------- /example/linux/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /example/linux/my_application.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | #include 4 | #ifdef GDK_WINDOWING_X11 5 | #include 6 | #endif 7 | 8 | #include "flutter/generated_plugin_registrant.h" 9 | 10 | struct _MyApplication { 11 | GtkApplication parent_instance; 12 | char** dart_entrypoint_arguments; 13 | }; 14 | 15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) 16 | 17 | // Implements GApplication::activate. 18 | static void my_application_activate(GApplication* application) { 19 | MyApplication* self = MY_APPLICATION(application); 20 | GtkWindow* window = 21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 22 | 23 | // Use a header bar when running in GNOME as this is the common style used 24 | // by applications and is the setup most users will be using (e.g. Ubuntu 25 | // desktop). 26 | // If running on X and not using GNOME then just use a traditional title bar 27 | // in case the window manager does more exotic layout, e.g. tiling. 28 | // If running on Wayland assume the header bar will work (may need changing 29 | // if future cases occur). 30 | gboolean use_header_bar = TRUE; 31 | #ifdef GDK_WINDOWING_X11 32 | GdkScreen* screen = gtk_window_get_screen(window); 33 | if (GDK_IS_X11_SCREEN(screen)) { 34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 36 | use_header_bar = FALSE; 37 | } 38 | } 39 | #endif 40 | if (use_header_bar) { 41 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 42 | gtk_widget_show(GTK_WIDGET(header_bar)); 43 | gtk_header_bar_set_title(header_bar, "stack_board_example"); 44 | gtk_header_bar_set_show_close_button(header_bar, TRUE); 45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 46 | } else { 47 | gtk_window_set_title(window, "stack_board_example"); 48 | } 49 | 50 | gtk_window_set_default_size(window, 1280, 720); 51 | gtk_widget_show(GTK_WIDGET(window)); 52 | 53 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 54 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); 55 | 56 | FlView* view = fl_view_new(project); 57 | gtk_widget_show(GTK_WIDGET(view)); 58 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 59 | 60 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 61 | 62 | gtk_widget_grab_focus(GTK_WIDGET(view)); 63 | } 64 | 65 | // Implements GApplication::local_command_line. 66 | static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { 67 | MyApplication* self = MY_APPLICATION(application); 68 | // Strip out the first argument as it is the binary name. 69 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 70 | 71 | g_autoptr(GError) error = nullptr; 72 | if (!g_application_register(application, nullptr, &error)) { 73 | g_warning("Failed to register: %s", error->message); 74 | *exit_status = 1; 75 | return TRUE; 76 | } 77 | 78 | g_application_activate(application); 79 | *exit_status = 0; 80 | 81 | return TRUE; 82 | } 83 | 84 | // Implements GObject::dispose. 85 | static void my_application_dispose(GObject* object) { 86 | MyApplication* self = MY_APPLICATION(object); 87 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 88 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 89 | } 90 | 91 | static void my_application_class_init(MyApplicationClass* klass) { 92 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 93 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; 94 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 95 | } 96 | 97 | static void my_application_init(MyApplication* self) {} 98 | 99 | MyApplication* my_application_new() { 100 | return MY_APPLICATION(g_object_new(my_application_get_type(), 101 | "application-id", APPLICATION_ID, 102 | "flags", G_APPLICATION_NON_UNIQUE, 103 | nullptr)); 104 | } 105 | -------------------------------------------------------------------------------- /example/linux/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /example/macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /example/macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | 9 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 10 | } 11 | -------------------------------------------------------------------------------- /example/macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.14' 2 | 3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 5 | 6 | project 'Runner', { 7 | 'Debug' => :debug, 8 | 'Profile' => :release, 9 | 'Release' => :release, 10 | } 11 | 12 | def flutter_root 13 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) 14 | unless File.exist?(generated_xcode_build_settings_path) 15 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" 16 | end 17 | 18 | File.foreach(generated_xcode_build_settings_path) do |line| 19 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 20 | return matches[1].strip if matches 21 | end 22 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" 23 | end 24 | 25 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 26 | 27 | flutter_macos_podfile_setup 28 | 29 | target 'Runner' do 30 | use_frameworks! 31 | use_modular_headers! 32 | 33 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) 34 | end 35 | 36 | post_install do |installer| 37 | installer.pods_project.targets.each do |target| 38 | flutter_additional_macos_build_settings(target) 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 64 | 65 | 71 | 73 | 79 | 80 | 81 | 82 | 84 | 85 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /example/macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "app_icon_16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "app_icon_32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "app_icon_32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "app_icon_64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "app_icon_128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "app_icon_256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "app_icon_256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "app_icon_512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "app_icon_512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "app_icon_1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /example/macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = stack_board_example 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.liugl.stackBoardExample 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2021 com.liugl. All rights reserved. 15 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /example/macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.server 10 | 11 | com.apple.security.network.client 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /example/macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | $(PRODUCT_COPYRIGHT) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /example/macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController.init() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /example/macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" 9 | url: "https://pub.dev" 10 | source: hosted 11 | version: "2.11.0" 12 | boolean_selector: 13 | dependency: transitive 14 | description: 15 | name: boolean_selector 16 | sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" 17 | url: "https://pub.dev" 18 | source: hosted 19 | version: "2.1.1" 20 | characters: 21 | dependency: transitive 22 | description: 23 | name: characters 24 | sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" 25 | url: "https://pub.dev" 26 | source: hosted 27 | version: "1.3.0" 28 | clock: 29 | dependency: transitive 30 | description: 31 | name: clock 32 | sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf 33 | url: "https://pub.dev" 34 | source: hosted 35 | version: "1.1.1" 36 | collection: 37 | dependency: transitive 38 | description: 39 | name: collection 40 | sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a 41 | url: "https://pub.dev" 42 | source: hosted 43 | version: "1.18.0" 44 | cupertino_icons: 45 | dependency: "direct main" 46 | description: 47 | name: cupertino_icons 48 | sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 49 | url: "https://pub.dev" 50 | source: hosted 51 | version: "1.0.8" 52 | fake_async: 53 | dependency: transitive 54 | description: 55 | name: fake_async 56 | sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" 57 | url: "https://pub.dev" 58 | source: hosted 59 | version: "1.3.1" 60 | flutter: 61 | dependency: "direct main" 62 | description: flutter 63 | source: sdk 64 | version: "0.0.0" 65 | flutter_drawing_board: 66 | dependency: transitive 67 | description: 68 | name: flutter_drawing_board 69 | sha256: "82700847d7f367c9af1eaf186c88f74a6be821dbe783871e4736bf724f015192" 70 | url: "https://pub.dev" 71 | source: hosted 72 | version: "0.7.0+2" 73 | flutter_lints: 74 | dependency: "direct dev" 75 | description: 76 | name: flutter_lints 77 | sha256: b543301ad291598523947dc534aaddc5aaad597b709d2426d3a0e0d44c5cb493 78 | url: "https://pub.dev" 79 | source: hosted 80 | version: "1.0.4" 81 | flutter_test: 82 | dependency: "direct dev" 83 | description: flutter 84 | source: sdk 85 | version: "0.0.0" 86 | leak_tracker: 87 | dependency: transitive 88 | description: 89 | name: leak_tracker 90 | sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" 91 | url: "https://pub.dev" 92 | source: hosted 93 | version: "10.0.0" 94 | leak_tracker_flutter_testing: 95 | dependency: transitive 96 | description: 97 | name: leak_tracker_flutter_testing 98 | sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 99 | url: "https://pub.dev" 100 | source: hosted 101 | version: "2.0.1" 102 | leak_tracker_testing: 103 | dependency: transitive 104 | description: 105 | name: leak_tracker_testing 106 | sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 107 | url: "https://pub.dev" 108 | source: hosted 109 | version: "2.0.1" 110 | lints: 111 | dependency: transitive 112 | description: 113 | name: lints 114 | sha256: a2c3d198cb5ea2e179926622d433331d8b58374ab8f29cdda6e863bd62fd369c 115 | url: "https://pub.dev" 116 | source: hosted 117 | version: "1.0.1" 118 | matcher: 119 | dependency: transitive 120 | description: 121 | name: matcher 122 | sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb 123 | url: "https://pub.dev" 124 | source: hosted 125 | version: "0.12.16+1" 126 | material_color_utilities: 127 | dependency: transitive 128 | description: 129 | name: material_color_utilities 130 | sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" 131 | url: "https://pub.dev" 132 | source: hosted 133 | version: "0.8.0" 134 | meta: 135 | dependency: transitive 136 | description: 137 | name: meta 138 | sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 139 | url: "https://pub.dev" 140 | source: hosted 141 | version: "1.11.0" 142 | path: 143 | dependency: transitive 144 | description: 145 | name: path 146 | sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" 147 | url: "https://pub.dev" 148 | source: hosted 149 | version: "1.9.0" 150 | sky_engine: 151 | dependency: transitive 152 | description: flutter 153 | source: sdk 154 | version: "0.0.99" 155 | source_span: 156 | dependency: transitive 157 | description: 158 | name: source_span 159 | sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" 160 | url: "https://pub.dev" 161 | source: hosted 162 | version: "1.10.0" 163 | stack_board: 164 | dependency: "direct main" 165 | description: 166 | path: ".." 167 | relative: true 168 | source: path 169 | version: "0.2.5" 170 | stack_trace: 171 | dependency: transitive 172 | description: 173 | name: stack_trace 174 | sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" 175 | url: "https://pub.dev" 176 | source: hosted 177 | version: "1.11.1" 178 | stream_channel: 179 | dependency: transitive 180 | description: 181 | name: stream_channel 182 | sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 183 | url: "https://pub.dev" 184 | source: hosted 185 | version: "2.1.2" 186 | string_scanner: 187 | dependency: transitive 188 | description: 189 | name: string_scanner 190 | sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" 191 | url: "https://pub.dev" 192 | source: hosted 193 | version: "1.2.0" 194 | term_glyph: 195 | dependency: transitive 196 | description: 197 | name: term_glyph 198 | sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 199 | url: "https://pub.dev" 200 | source: hosted 201 | version: "1.2.1" 202 | test_api: 203 | dependency: transitive 204 | description: 205 | name: test_api 206 | sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" 207 | url: "https://pub.dev" 208 | source: hosted 209 | version: "0.6.1" 210 | vector_math: 211 | dependency: transitive 212 | description: 213 | name: vector_math 214 | sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" 215 | url: "https://pub.dev" 216 | source: hosted 217 | version: "2.1.4" 218 | vm_service: 219 | dependency: transitive 220 | description: 221 | name: vm_service 222 | sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 223 | url: "https://pub.dev" 224 | source: hosted 225 | version: "13.0.0" 226 | sdks: 227 | dart: ">=3.2.0-0 <4.0.0" 228 | flutter: ">=3.0.0" 229 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: stack_board_example 2 | description: Demonstrates how to use the stack_board plugin. 3 | 4 | # The following line prevents the package from being accidentally published to 5 | # pub.dev using `flutter pub publish`. This is preferred for private packages. 6 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev 7 | 8 | environment: 9 | sdk: ">=2.12.0 <3.0.0" 10 | 11 | # Dependencies specify other packages that your package needs in order to work. 12 | # To automatically upgrade your package dependencies to the latest versions 13 | # consider running `flutter pub upgrade --major-versions`. Alternatively, 14 | # dependencies can be manually updated by changing the version numbers below to 15 | # the latest version available on pub.dev. To see which dependencies have newer 16 | # versions available, run `flutter pub outdated`. 17 | dependencies: 18 | flutter: 19 | sdk: flutter 20 | 21 | stack_board: 22 | # When depending on this package from a real application you should use: 23 | # stack_board: ^x.y.z 24 | # See https://dart.dev/tools/pub/dependencies#version-constraints 25 | # The example app is bundled with the plugin so we use a path dependency on 26 | # the parent directory to use the current plugin's version. 27 | path: ../ 28 | 29 | # The following adds the Cupertino Icons font to your application. 30 | # Use with the CupertinoIcons class for iOS style icons. 31 | cupertino_icons: ^1.0.2 32 | 33 | dev_dependencies: 34 | flutter_test: 35 | sdk: flutter 36 | 37 | # The "flutter_lints" package below contains a set of recommended lints to 38 | # encourage good coding practices. The lint set provided by the package is 39 | # activated in the `analysis_options.yaml` file located at the root of your 40 | # package. See that file for information about deactivating specific lint 41 | # rules and activating additional ones. 42 | flutter_lints: ^1.0.0 43 | 44 | # For information on the generic Dart part of this file, see the 45 | # following page: https://dart.dev/tools/pub/pubspec 46 | 47 | # The following section is specific to Flutter. 48 | flutter: 49 | 50 | # The following line ensures that the Material Icons font is 51 | # included with your application, so that you can use the icons in 52 | # the material Icons class. 53 | uses-material-design: true 54 | 55 | # To add assets to your application, add an assets section, like this: 56 | # assets: 57 | # - images/a_dot_burr.jpeg 58 | # - images/a_dot_ham.jpeg 59 | 60 | # An image asset can refer to one or more resolution-specific "variants", see 61 | # https://flutter.dev/assets-and-images/#resolution-aware. 62 | 63 | # For details regarding adding assets from package dependencies, see 64 | # https://flutter.dev/assets-and-images/#from-packages 65 | 66 | # To add custom fonts to your application, add a fonts section here, 67 | # in this "flutter" section. Each entry in this list should have a 68 | # "family" key with the font family name, and a "fonts" key with a 69 | # list giving the asset and other descriptors for the font. For 70 | # example: 71 | # fonts: 72 | # - family: Schyler 73 | # fonts: 74 | # - asset: fonts/Schyler-Regular.ttf 75 | # - asset: fonts/Schyler-Italic.ttf 76 | # style: italic 77 | # - family: Trajan Pro 78 | # fonts: 79 | # - asset: fonts/TrajanPro.ttf 80 | # - asset: fonts/TrajanPro_Bold.ttf 81 | # weight: 700 82 | # 83 | # For details regarding fonts from package dependencies, 84 | # see https://flutter.dev/custom-fonts/#from-packages 85 | -------------------------------------------------------------------------------- /example/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility that Flutter provides. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter_test/flutter_test.dart'; 10 | 11 | import 'package:stack_board_example/main.dart'; 12 | 13 | void main() { 14 | testWidgets('Verify Platform version', (WidgetTester tester) async { 15 | // Build our app and trigger a frame. 16 | await tester.pumpWidget(const MyApp()); 17 | 18 | // Verify that platform version is retrieved. 19 | expect( 20 | find.byWidgetPredicate( 21 | (Widget widget) => 22 | widget is Text && widget.data!.startsWith('Running on:'), 23 | ), 24 | findsOneWidget, 25 | ); 26 | }); 27 | } 28 | -------------------------------------------------------------------------------- /example/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/web/favicon.png -------------------------------------------------------------------------------- /example/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/web/icons/Icon-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/web/icons/Icon-512.png -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /example/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | stack_board_example 30 | 31 | 32 | 33 | 36 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /example/web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "stack_board_example", 3 | "short_name": "stack_board_example", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "Demonstrates how to use the stack_board plugin.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /example/windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /example/windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15) 2 | project(stack_board_example LANGUAGES CXX) 3 | 4 | set(BINARY_NAME "stack_board_example") 5 | 6 | cmake_policy(SET CMP0063 NEW) 7 | 8 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 9 | 10 | # Configure build options. 11 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 12 | if(IS_MULTICONFIG) 13 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 14 | CACHE STRING "" FORCE) 15 | else() 16 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 17 | set(CMAKE_BUILD_TYPE "Debug" CACHE 18 | STRING "Flutter build mode" FORCE) 19 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 20 | "Debug" "Profile" "Release") 21 | endif() 22 | endif() 23 | 24 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 25 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 26 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 27 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 28 | 29 | # Use Unicode for all projects. 30 | add_definitions(-DUNICODE -D_UNICODE) 31 | 32 | # Compilation settings that should be applied to most targets. 33 | function(APPLY_STANDARD_SETTINGS TARGET) 34 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 35 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 36 | target_compile_options(${TARGET} PRIVATE /EHsc) 37 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 38 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 39 | endfunction() 40 | 41 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 42 | 43 | # Flutter library and tool build rules. 44 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 45 | 46 | # Application build 47 | add_subdirectory("runner") 48 | 49 | # Generated plugin build rules, which manage building the plugins and adding 50 | # them to the application. 51 | include(flutter/generated_plugins.cmake) 52 | 53 | 54 | # === Installation === 55 | # Support files are copied into place next to the executable, so that it can 56 | # run in place. This is done instead of making a separate bundle (as on Linux) 57 | # so that building and running from within Visual Studio will work. 58 | set(BUILD_BUNDLE_DIR "$") 59 | # Make the "install" step default, as it's required to run. 60 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 61 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 62 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 63 | endif() 64 | 65 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 66 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 67 | 68 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 69 | COMPONENT Runtime) 70 | 71 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 72 | COMPONENT Runtime) 73 | 74 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 75 | COMPONENT Runtime) 76 | 77 | if(PLUGIN_BUNDLED_LIBRARIES) 78 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 79 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 80 | COMPONENT Runtime) 81 | endif() 82 | 83 | # Fully re-copy the assets directory on each build to avoid having stale files 84 | # from a previous install. 85 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 86 | install(CODE " 87 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 88 | " COMPONENT Runtime) 89 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 90 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 91 | 92 | # Install the AOT library on non-Debug builds only. 93 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 94 | CONFIGURATIONS Profile;Release 95 | COMPONENT Runtime) 96 | -------------------------------------------------------------------------------- /example/windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15) 2 | 3 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 4 | 5 | # Configuration provided via flutter tool. 6 | include(${EPHEMERAL_DIR}/generated_config.cmake) 7 | 8 | # TODO: Move the rest of this into files in ephemeral. See 9 | # https://github.com/flutter/flutter/issues/57146. 10 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 11 | 12 | # === Flutter Library === 13 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 14 | 15 | # Published to parent scope for install step. 16 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 17 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 18 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 19 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 20 | 21 | list(APPEND FLUTTER_LIBRARY_HEADERS 22 | "flutter_export.h" 23 | "flutter_windows.h" 24 | "flutter_messenger.h" 25 | "flutter_plugin_registrar.h" 26 | "flutter_texture_registrar.h" 27 | ) 28 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 29 | add_library(flutter INTERFACE) 30 | target_include_directories(flutter INTERFACE 31 | "${EPHEMERAL_DIR}" 32 | ) 33 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 34 | add_dependencies(flutter flutter_assemble) 35 | 36 | # === Wrapper === 37 | list(APPEND CPP_WRAPPER_SOURCES_CORE 38 | "core_implementations.cc" 39 | "standard_codec.cc" 40 | ) 41 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 42 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 43 | "plugin_registrar.cc" 44 | ) 45 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 46 | list(APPEND CPP_WRAPPER_SOURCES_APP 47 | "flutter_engine.cc" 48 | "flutter_view_controller.cc" 49 | ) 50 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 51 | 52 | # Wrapper sources needed for a plugin. 53 | add_library(flutter_wrapper_plugin STATIC 54 | ${CPP_WRAPPER_SOURCES_CORE} 55 | ${CPP_WRAPPER_SOURCES_PLUGIN} 56 | ) 57 | apply_standard_settings(flutter_wrapper_plugin) 58 | set_target_properties(flutter_wrapper_plugin PROPERTIES 59 | POSITION_INDEPENDENT_CODE ON) 60 | set_target_properties(flutter_wrapper_plugin PROPERTIES 61 | CXX_VISIBILITY_PRESET hidden) 62 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 63 | target_include_directories(flutter_wrapper_plugin PUBLIC 64 | "${WRAPPER_ROOT}/include" 65 | ) 66 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 67 | 68 | # Wrapper sources needed for the runner. 69 | add_library(flutter_wrapper_app STATIC 70 | ${CPP_WRAPPER_SOURCES_CORE} 71 | ${CPP_WRAPPER_SOURCES_APP} 72 | ) 73 | apply_standard_settings(flutter_wrapper_app) 74 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 75 | target_include_directories(flutter_wrapper_app PUBLIC 76 | "${WRAPPER_ROOT}/include" 77 | ) 78 | add_dependencies(flutter_wrapper_app flutter_assemble) 79 | 80 | # === Flutter tool backend === 81 | # _phony_ is a non-existent file to force this command to run every time, 82 | # since currently there's no way to get a full input/output list from the 83 | # flutter tool. 84 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 85 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 86 | add_custom_command( 87 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 88 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 89 | ${CPP_WRAPPER_SOURCES_APP} 90 | ${PHONY_OUTPUT} 91 | COMMAND ${CMAKE_COMMAND} -E env 92 | ${FLUTTER_TOOL_ENVIRONMENT} 93 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 94 | windows-x64 $ 95 | VERBATIM 96 | ) 97 | add_custom_target(flutter_assemble DEPENDS 98 | "${FLUTTER_LIBRARY}" 99 | ${FLUTTER_LIBRARY_HEADERS} 100 | ${CPP_WRAPPER_SOURCES_CORE} 101 | ${CPP_WRAPPER_SOURCES_PLUGIN} 102 | ${CPP_WRAPPER_SOURCES_APP} 103 | ) 104 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | 10 | void RegisterPlugins(flutter::PluginRegistry* registry) { 11 | } 12 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | ) 7 | 8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 9 | ) 10 | 11 | set(PLUGIN_BUNDLED_LIBRARIES) 12 | 13 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 18 | endforeach(plugin) 19 | 20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 23 | endforeach(ffi_plugin) 24 | -------------------------------------------------------------------------------- /example/windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15) 2 | project(runner LANGUAGES CXX) 3 | 4 | add_executable(${BINARY_NAME} WIN32 5 | "flutter_window.cpp" 6 | "main.cpp" 7 | "utils.cpp" 8 | "win32_window.cpp" 9 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 10 | "Runner.rc" 11 | "runner.exe.manifest" 12 | ) 13 | apply_standard_settings(${BINARY_NAME}) 14 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 15 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 16 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 17 | add_dependencies(${BINARY_NAME} flutter_assemble) 18 | -------------------------------------------------------------------------------- /example/windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #ifdef FLUTTER_BUILD_NUMBER 64 | #define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0 67 | #endif 68 | 69 | #ifdef FLUTTER_BUILD_NAME 70 | #define VERSION_AS_STRING #FLUTTER_BUILD_NAME 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "com.liugl" "\0" 93 | VALUE "FileDescription", "Demonstrates how to use the stack_board plugin." "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "stack_board_example" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2021 com.liugl. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "stack_board_example.exe" "\0" 98 | VALUE "ProductName", "stack_board_example" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /example/windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | return true; 30 | } 31 | 32 | void FlutterWindow::OnDestroy() { 33 | if (flutter_controller_) { 34 | flutter_controller_ = nullptr; 35 | } 36 | 37 | Win32Window::OnDestroy(); 38 | } 39 | 40 | LRESULT 41 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 42 | WPARAM const wparam, 43 | LPARAM const lparam) noexcept { 44 | // Give Flutter, including plugins, an opportunity to handle window messages. 45 | if (flutter_controller_) { 46 | std::optional result = 47 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 48 | lparam); 49 | if (result) { 50 | return *result; 51 | } 52 | } 53 | 54 | switch (message) { 55 | case WM_FONTCHANGE: 56 | flutter_controller_->engine()->ReloadSystemFonts(); 57 | break; 58 | } 59 | 60 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 61 | } 62 | -------------------------------------------------------------------------------- /example/windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /example/windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.CreateAndShow(L"stack_board_example", origin, size)) { 31 | return EXIT_FAILURE; 32 | } 33 | window.SetQuitOnClose(true); 34 | 35 | ::MSG msg; 36 | while (::GetMessage(&msg, nullptr, 0, 0)) { 37 | ::TranslateMessage(&msg); 38 | ::DispatchMessage(&msg); 39 | } 40 | 41 | ::CoUninitialize(); 42 | return EXIT_SUCCESS; 43 | } 44 | -------------------------------------------------------------------------------- /example/windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /example/windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/stack_board/18d1b4ae8bc177c53041dea96eaaa5fe46e4b8e0/example/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /example/windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /example/windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr); 51 | if (target_length == 0) { 52 | return std::string(); 53 | } 54 | std::string utf8_string; 55 | utf8_string.resize(target_length); 56 | int converted_length = ::WideCharToMultiByte( 57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 58 | -1, utf8_string.data(), 59 | target_length, nullptr, nullptr); 60 | if (converted_length == 0) { 61 | return std::string(); 62 | } 63 | return utf8_string; 64 | } 65 | -------------------------------------------------------------------------------- /example/windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /example/windows/runner/win32_window.cpp: -------------------------------------------------------------------------------- 1 | #include "win32_window.h" 2 | 3 | #include 4 | 5 | #include "resource.h" 6 | 7 | namespace { 8 | 9 | constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; 10 | 11 | // The number of Win32Window objects that currently exist. 12 | static int g_active_window_count = 0; 13 | 14 | using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); 15 | 16 | // Scale helper to convert logical scaler values to physical using passed in 17 | // scale factor 18 | int Scale(int source, double scale_factor) { 19 | return static_cast(source * scale_factor); 20 | } 21 | 22 | // Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. 23 | // This API is only needed for PerMonitor V1 awareness mode. 24 | void EnableFullDpiSupportIfAvailable(HWND hwnd) { 25 | HMODULE user32_module = LoadLibraryA("User32.dll"); 26 | if (!user32_module) { 27 | return; 28 | } 29 | auto enable_non_client_dpi_scaling = 30 | reinterpret_cast( 31 | GetProcAddress(user32_module, "EnableNonClientDpiScaling")); 32 | if (enable_non_client_dpi_scaling != nullptr) { 33 | enable_non_client_dpi_scaling(hwnd); 34 | FreeLibrary(user32_module); 35 | } 36 | } 37 | 38 | } // namespace 39 | 40 | // Manages the Win32Window's window class registration. 41 | class WindowClassRegistrar { 42 | public: 43 | ~WindowClassRegistrar() = default; 44 | 45 | // Returns the singleton registar instance. 46 | static WindowClassRegistrar* GetInstance() { 47 | if (!instance_) { 48 | instance_ = new WindowClassRegistrar(); 49 | } 50 | return instance_; 51 | } 52 | 53 | // Returns the name of the window class, registering the class if it hasn't 54 | // previously been registered. 55 | const wchar_t* GetWindowClass(); 56 | 57 | // Unregisters the window class. Should only be called if there are no 58 | // instances of the window. 59 | void UnregisterWindowClass(); 60 | 61 | private: 62 | WindowClassRegistrar() = default; 63 | 64 | static WindowClassRegistrar* instance_; 65 | 66 | bool class_registered_ = false; 67 | }; 68 | 69 | WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; 70 | 71 | const wchar_t* WindowClassRegistrar::GetWindowClass() { 72 | if (!class_registered_) { 73 | WNDCLASS window_class{}; 74 | window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); 75 | window_class.lpszClassName = kWindowClassName; 76 | window_class.style = CS_HREDRAW | CS_VREDRAW; 77 | window_class.cbClsExtra = 0; 78 | window_class.cbWndExtra = 0; 79 | window_class.hInstance = GetModuleHandle(nullptr); 80 | window_class.hIcon = 81 | LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); 82 | window_class.hbrBackground = 0; 83 | window_class.lpszMenuName = nullptr; 84 | window_class.lpfnWndProc = Win32Window::WndProc; 85 | RegisterClass(&window_class); 86 | class_registered_ = true; 87 | } 88 | return kWindowClassName; 89 | } 90 | 91 | void WindowClassRegistrar::UnregisterWindowClass() { 92 | UnregisterClass(kWindowClassName, nullptr); 93 | class_registered_ = false; 94 | } 95 | 96 | Win32Window::Win32Window() { 97 | ++g_active_window_count; 98 | } 99 | 100 | Win32Window::~Win32Window() { 101 | --g_active_window_count; 102 | Destroy(); 103 | } 104 | 105 | bool Win32Window::CreateAndShow(const std::wstring& title, 106 | const Point& origin, 107 | const Size& size) { 108 | Destroy(); 109 | 110 | const wchar_t* window_class = 111 | WindowClassRegistrar::GetInstance()->GetWindowClass(); 112 | 113 | const POINT target_point = {static_cast(origin.x), 114 | static_cast(origin.y)}; 115 | HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); 116 | UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); 117 | double scale_factor = dpi / 96.0; 118 | 119 | HWND window = CreateWindow( 120 | window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE, 121 | Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), 122 | Scale(size.width, scale_factor), Scale(size.height, scale_factor), 123 | nullptr, nullptr, GetModuleHandle(nullptr), this); 124 | 125 | if (!window) { 126 | return false; 127 | } 128 | 129 | return OnCreate(); 130 | } 131 | 132 | // static 133 | LRESULT CALLBACK Win32Window::WndProc(HWND const window, 134 | UINT const message, 135 | WPARAM const wparam, 136 | LPARAM const lparam) noexcept { 137 | if (message == WM_NCCREATE) { 138 | auto window_struct = reinterpret_cast(lparam); 139 | SetWindowLongPtr(window, GWLP_USERDATA, 140 | reinterpret_cast(window_struct->lpCreateParams)); 141 | 142 | auto that = static_cast(window_struct->lpCreateParams); 143 | EnableFullDpiSupportIfAvailable(window); 144 | that->window_handle_ = window; 145 | } else if (Win32Window* that = GetThisFromHandle(window)) { 146 | return that->MessageHandler(window, message, wparam, lparam); 147 | } 148 | 149 | return DefWindowProc(window, message, wparam, lparam); 150 | } 151 | 152 | LRESULT 153 | Win32Window::MessageHandler(HWND hwnd, 154 | UINT const message, 155 | WPARAM const wparam, 156 | LPARAM const lparam) noexcept { 157 | switch (message) { 158 | case WM_DESTROY: 159 | window_handle_ = nullptr; 160 | Destroy(); 161 | if (quit_on_close_) { 162 | PostQuitMessage(0); 163 | } 164 | return 0; 165 | 166 | case WM_DPICHANGED: { 167 | auto newRectSize = reinterpret_cast(lparam); 168 | LONG newWidth = newRectSize->right - newRectSize->left; 169 | LONG newHeight = newRectSize->bottom - newRectSize->top; 170 | 171 | SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, 172 | newHeight, SWP_NOZORDER | SWP_NOACTIVATE); 173 | 174 | return 0; 175 | } 176 | case WM_SIZE: { 177 | RECT rect = GetClientArea(); 178 | if (child_content_ != nullptr) { 179 | // Size and position the child window. 180 | MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, 181 | rect.bottom - rect.top, TRUE); 182 | } 183 | return 0; 184 | } 185 | 186 | case WM_ACTIVATE: 187 | if (child_content_ != nullptr) { 188 | SetFocus(child_content_); 189 | } 190 | return 0; 191 | } 192 | 193 | return DefWindowProc(window_handle_, message, wparam, lparam); 194 | } 195 | 196 | void Win32Window::Destroy() { 197 | OnDestroy(); 198 | 199 | if (window_handle_) { 200 | DestroyWindow(window_handle_); 201 | window_handle_ = nullptr; 202 | } 203 | if (g_active_window_count == 0) { 204 | WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); 205 | } 206 | } 207 | 208 | Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { 209 | return reinterpret_cast( 210 | GetWindowLongPtr(window, GWLP_USERDATA)); 211 | } 212 | 213 | void Win32Window::SetChildContent(HWND content) { 214 | child_content_ = content; 215 | SetParent(content, window_handle_); 216 | RECT frame = GetClientArea(); 217 | 218 | MoveWindow(content, frame.left, frame.top, frame.right - frame.left, 219 | frame.bottom - frame.top, true); 220 | 221 | SetFocus(child_content_); 222 | } 223 | 224 | RECT Win32Window::GetClientArea() { 225 | RECT frame; 226 | GetClientRect(window_handle_, &frame); 227 | return frame; 228 | } 229 | 230 | HWND Win32Window::GetHandle() { 231 | return window_handle_; 232 | } 233 | 234 | void Win32Window::SetQuitOnClose(bool quit_on_close) { 235 | quit_on_close_ = quit_on_close; 236 | } 237 | 238 | bool Win32Window::OnCreate() { 239 | // No-op; provided for subclasses. 240 | return true; 241 | } 242 | 243 | void Win32Window::OnDestroy() { 244 | // No-op; provided for subclasses. 245 | } 246 | -------------------------------------------------------------------------------- /example/windows/runner/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates and shows a win32 window with |title| and position and size 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 to will treat the width height passed in to this function 35 | // as logical pixels and scale to appropriate for the default monitor. Returns 36 | // true if the window was created successfully. 37 | bool CreateAndShow(const std::wstring& title, 38 | const Point& origin, 39 | const Size& size); 40 | 41 | // Release OS resources associated with window. 42 | void Destroy(); 43 | 44 | // Inserts |content| into the window tree. 45 | void SetChildContent(HWND content); 46 | 47 | // Returns the backing Window handle to enable clients to set icon and other 48 | // window properties. Returns nullptr if the window has been destroyed. 49 | HWND GetHandle(); 50 | 51 | // If true, closing this window will quit the application. 52 | void SetQuitOnClose(bool quit_on_close); 53 | 54 | // Return a RECT representing the bounds of the current client area. 55 | RECT GetClientArea(); 56 | 57 | protected: 58 | // Processes and route salient window messages for mouse handling, 59 | // size change and DPI. Delegates handling of these to member overloads that 60 | // inheriting classes can handle. 61 | virtual LRESULT MessageHandler(HWND window, 62 | UINT const message, 63 | WPARAM const wparam, 64 | LPARAM const lparam) noexcept; 65 | 66 | // Called when CreateAndShow is called, allowing subclass window-related 67 | // setup. Subclasses should return false if setup fails. 68 | virtual bool OnCreate(); 69 | 70 | // Called when Destroy is called. 71 | virtual void OnDestroy(); 72 | 73 | private: 74 | friend class WindowClassRegistrar; 75 | 76 | // OS callback called by message pump. Handles the WM_NCCREATE message which 77 | // is passed when the non-client area is being created and enables automatic 78 | // non-client DPI scaling so that the non-client area automatically 79 | // responsponds to changes in DPI. All other messages are handled by 80 | // MessageHandler. 81 | static LRESULT CALLBACK WndProc(HWND const window, 82 | UINT const message, 83 | WPARAM const wparam, 84 | LPARAM const lparam) noexcept; 85 | 86 | // Retrieves a class instance pointer for |window| 87 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 88 | 89 | bool quit_on_close_ = false; 90 | 91 | // window handle for top level window. 92 | HWND window_handle_ = nullptr; 93 | 94 | // window handle for hosted content. 95 | HWND child_content_ = nullptr; 96 | }; 97 | 98 | #endif // RUNNER_WIN32_WINDOW_H_ 99 | -------------------------------------------------------------------------------- /lib/flutter_stack_board.dart: -------------------------------------------------------------------------------- 1 | library stack_board; 2 | 3 | export 'src/core/case_style.dart'; 4 | export 'src/core/stack_board_controller.dart'; 5 | export 'src/stack_board.dart'; 6 | -------------------------------------------------------------------------------- /lib/helpers.dart: -------------------------------------------------------------------------------- 1 | library stack_board_helpers; 2 | 3 | export 'src/helpers/as_t.dart'; 4 | export 'src/helpers/ex_enum.dart'; 5 | export 'src/helpers/ex_list.dart'; 6 | export 'src/helpers/safe_state.dart'; 7 | export 'src/helpers/safe_value_notifier.dart'; 8 | export 'src/widgets/ex_builder.dart'; 9 | export 'src/widgets/get_size.dart'; 10 | -------------------------------------------------------------------------------- /lib/src/core/case_style.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:stack_board/src/helpers/as_t.dart'; 3 | 4 | /// * 操作壳样式 5 | /// * case style 6 | @immutable 7 | class CaseStyle { 8 | const CaseStyle({ 9 | this.buttonBgColor = Colors.white, 10 | this.buttonBorderColor = Colors.grey, 11 | this.buttonBorderWidth = 1, 12 | this.buttonIconColor = Colors.grey, 13 | this.buttonSize = 24, 14 | this.boxAspectRatio, 15 | this.frameBorderColor = Colors.purple, 16 | this.frameBorderWidth = 2, 17 | }); 18 | 19 | factory CaseStyle.fromJson(final Map json) { 20 | final Color? buttonBgColor = asNullT(json['buttonBgColor']); 21 | final Color? buttonBorderColor = asNullT(json['buttonBorderColor']); 22 | final double? buttonBorderWidth = 23 | asNullT(json['buttonBorderWidth']); 24 | final Color? buttonIconColor = asNullT(json['buttonIconColor']); 25 | final double? buttonSize = asNullT(json['buttonSize']); 26 | final double? boxAspectRatio = asNullT(json['boxAspectRatio']); 27 | final Color? frameBorderColor = asNullT(json['frameBorderColor']); 28 | final double? frameBorderWidth = asNullT(json['frameBorderWidth']); 29 | 30 | return CaseStyle( 31 | buttonBgColor: buttonBgColor ?? Colors.white, 32 | buttonBorderColor: buttonBorderColor ?? Colors.grey, 33 | buttonBorderWidth: buttonBorderWidth ?? 1, 34 | buttonIconColor: buttonIconColor ?? Colors.grey, 35 | buttonSize: buttonSize ?? 24, 36 | boxAspectRatio: boxAspectRatio, 37 | frameBorderColor: frameBorderColor ?? Colors.purple, 38 | frameBorderWidth: frameBorderWidth ?? 2, 39 | ); 40 | } 41 | 42 | /// * 边框(包括操作手柄)颜色 43 | /// * Background color 44 | final Color buttonBgColor; 45 | 46 | /// * 边框(包括操作手柄)颜色 47 | /// * Border color 48 | final Color buttonBorderColor; 49 | 50 | /// * 边框粗细 51 | /// * Border thickness 52 | final double buttonBorderWidth; 53 | 54 | /// * 图标颜色 55 | /// * Icon color 56 | final Color buttonIconColor; 57 | 58 | /// * Button size 59 | final double buttonSize; 60 | 61 | /// * Frame border color 62 | final Color frameBorderColor; 63 | 64 | /// * Frame border thickness 65 | final double frameBorderWidth; 66 | 67 | /// * 边框比例 68 | /// * if(boxAspectRatio!=null) 缩放变换将固定比例 69 | /// * Border ratio 70 | /// * if(boxAspectRatio!=null) Scaling transformation will fix the ratio 71 | // * `TODO`: transform this parameter to a boolean disabling the resizeX and resizeY handles 72 | final double? boxAspectRatio; 73 | 74 | Map toJson() => { 75 | 'bgColor': buttonBgColor, 76 | 'buttonBorderColor': buttonBorderColor, 77 | 'buttonBorderWidth': buttonBorderWidth, 78 | 'buttonIconColor': buttonIconColor, 79 | 'buttonSize': buttonSize, 80 | 'boxAspectRatio': boxAspectRatio, 81 | 'frameBorderColor': frameBorderColor, 82 | 'frameBorderWidth': frameBorderWidth, 83 | }; 84 | 85 | @override 86 | int get hashCode => Object.hash( 87 | buttonBgColor, 88 | buttonBorderColor, 89 | buttonBorderWidth, 90 | buttonIconColor, 91 | buttonSize, 92 | boxAspectRatio, 93 | frameBorderColor, 94 | frameBorderWidth); 95 | 96 | @override 97 | bool operator ==(Object other) => 98 | identical(this, other) || 99 | other is CaseStyle && 100 | runtimeType == other.runtimeType && 101 | buttonBgColor == other.buttonBgColor && 102 | buttonBorderColor == other.buttonBorderColor && 103 | buttonBorderWidth == other.buttonBorderWidth && 104 | buttonIconColor == other.buttonIconColor && 105 | buttonSize == other.buttonSize && 106 | boxAspectRatio == other.boxAspectRatio && 107 | frameBorderColor == other.frameBorderColor && 108 | frameBorderWidth == other.frameBorderWidth; 109 | } 110 | -------------------------------------------------------------------------------- /lib/src/core/stack_board_item/stack_item.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'dart:math'; 3 | 4 | import 'package:flutter/foundation.dart'; 5 | import 'package:flutter/painting.dart'; 6 | import 'package:stack_board/src/widget_style_extension/ex_offset.dart'; 7 | import 'package:stack_board/src/widget_style_extension/ex_size.dart'; 8 | 9 | import 'stack_item_content.dart'; 10 | import 'stack_item_status.dart'; 11 | 12 | /// * 生成 StackItem id 13 | /// * Generate Id for StackItem 14 | String _genId() { 15 | final DateTime now = DateTime.now(); 16 | final int value = Random().nextInt(100000); 17 | return '$value-${now.millisecondsSinceEpoch}'; 18 | } 19 | 20 | /// * 布局数据核心类 21 | /// * 自定义需要继承此类 22 | /// * Core class for layout data 23 | /// * Custom needs to inherit this class 24 | @immutable 25 | abstract class StackItem { 26 | StackItem({ 27 | String? id, 28 | required this.size, 29 | Offset? offset, 30 | double? angle = 0, 31 | StackItemStatus? status = StackItemStatus.selected, 32 | bool? lockZOrder = false, 33 | this.content, 34 | }) : id = id ?? _genId(), 35 | offset = offset ?? Offset.zero, 36 | angle = angle ?? 0, 37 | lockZOrder = lockZOrder ?? false, 38 | status = status ?? StackItemStatus.selected; 39 | 40 | const StackItem.empty({ 41 | required this.size, 42 | required this.offset, 43 | required this.angle, 44 | required this.status, 45 | required this.content, 46 | required this.lockZOrder, 47 | }) : id = ''; 48 | 49 | /// id 50 | final String id; 51 | 52 | /// Size 53 | final Size size; 54 | 55 | /// Offset 56 | final Offset offset; 57 | 58 | /// Angle 59 | final double angle; 60 | 61 | /// Status 62 | final StackItemStatus status; 63 | 64 | final bool lockZOrder; 65 | 66 | /// Content 67 | final T? content; 68 | 69 | /// Update content and return new instance 70 | StackItem copyWith({ 71 | Size? size, 72 | Offset? offset, 73 | double? angle, 74 | StackItemStatus? status, 75 | bool? lockZOrder, 76 | T? content, 77 | }); 78 | 79 | /// to json 80 | Map toJson() { 81 | return { 82 | 'id': id, 83 | 'type': runtimeType.toString(), 84 | 'angle': angle, 85 | 'size': size.toJson(), 86 | 'offset': offset.toJson(), 87 | 'status': status.index, 88 | 'lockZOrder': lockZOrder, 89 | if (content != null) 'content': content?.toJson(), 90 | }; 91 | } 92 | 93 | @override 94 | String toString() { 95 | return jsonEncode(toJson()); 96 | } 97 | 98 | @override 99 | int get hashCode => id.hashCode; 100 | 101 | @override 102 | bool operator ==(Object other) => other is StackItem && id == other.id; 103 | } 104 | -------------------------------------------------------------------------------- /lib/src/core/stack_board_item/stack_item_content.dart: -------------------------------------------------------------------------------- 1 | /// * More info of StackItem 2 | /// * StackItem 内容 3 | abstract class StackItemContent { 4 | const StackItemContent(); 5 | 6 | /// * to json 7 | /// * 转 json 8 | Map toJson(); 9 | } 10 | -------------------------------------------------------------------------------- /lib/src/core/stack_board_item/stack_item_status.dart: -------------------------------------------------------------------------------- 1 | /// * StackItemStatus 2 | /// * [editing] editing 3 | /// * [moving] moving 4 | /// * [scaling] scaling 5 | /// * [roating] roating 6 | /// * [selected] selected 7 | /// * [idle] idle 8 | enum StackItemStatus { 9 | /// * 正在编辑 10 | /// * Editing 11 | editing, 12 | 13 | /// * 正在移动 14 | /// * Moving 15 | moving, 16 | 17 | /// * 正在缩放 18 | /// * Scaling 19 | scaling, 20 | 21 | /// * 正在旋转 22 | /// * Resizing (compressing or streching) 23 | resizing, 24 | 25 | /// * 正在旋转 26 | /// * Rotating 27 | roating, 28 | 29 | /// * 仅被选中 30 | /// * Selected 31 | selected, 32 | 33 | /// * 常规状态 34 | /// * Idle 35 | idle, 36 | 37 | /// * 锁定 38 | /// * Locked 39 | locked, 40 | } 41 | -------------------------------------------------------------------------------- /lib/src/helpers/as_t.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | /// 转换为 Map 4 | /// Convert to Map 5 | Map asMap(dynamic value) { 6 | if (value == null) { 7 | return {}; 8 | } 9 | return asT>(value); 10 | } 11 | 12 | /// 自动转换类型 13 | /// Auto convert type 14 | T asT(dynamic value, [T? def]) { 15 | if (value is T) { 16 | return value; 17 | } 18 | if (T == String) { 19 | return '' as T; 20 | } 21 | if (T == bool) { 22 | return false as T; 23 | } 24 | if (T == int) { 25 | return 0 as T; 26 | } 27 | if (T == double) { 28 | return 0.0 as T; 29 | } 30 | 31 | if ({} is T) { 32 | if (value is String && value.isNotEmpty) { 33 | return json.decode(value) as T; 34 | } 35 | return {} as T; 36 | } 37 | if ({} is T) { 38 | if (value is String) { 39 | return json.decode(value) as T; 40 | } 41 | return {} as T; 42 | } 43 | if ({} is T) { 44 | if (value is String) { 45 | return json.decode(value) as T; 46 | } 47 | return {} as T; 48 | } 49 | return def as T; 50 | } 51 | 52 | /// 自动转换为可空类型 53 | /// Auto convert to nullable type 54 | T? asNullT(dynamic value) { 55 | if (value is T) { 56 | return value; 57 | } 58 | return null; 59 | } 60 | -------------------------------------------------------------------------------- /lib/src/helpers/ex_enum.dart: -------------------------------------------------------------------------------- 1 | /// * enum解析工具 2 | /// * tools of convert enum 3 | class ExEnum { 4 | const ExEnum._(); 5 | 6 | static bool _isEnum(Object item) { 7 | final List splitItem = item.toString().split('.'); 8 | return splitItem.length > 1 && splitItem[0] == T.toString(); 9 | } 10 | 11 | static T? tryParse(List values, String? item) { 12 | if (item == null) return null; 13 | if (item.isEmpty) return null; 14 | if (!_isEnum(item)) throw Exception('Item $item is not ${T.toString()}'); 15 | 16 | for (final T value in values) { 17 | if (value.toString() == item) return value; 18 | } 19 | 20 | return null; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/src/helpers/ex_list.dart: -------------------------------------------------------------------------------- 1 | /// * List扩展 2 | /// * list extension 3 | extension ExList on List { 4 | T? firstWhereOrNull(bool Function(T element) test) { 5 | for (final T element in this) { 6 | if (test(element)) { 7 | return element; 8 | } 9 | } 10 | return null; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lib/src/helpers/safe_state.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/material.dart'; 4 | 5 | /// State安全扩展 6 | mixin SafeState on State { 7 | /// 安全刷新 8 | FutureOr safeSetState(FutureOr Function() fn) async { 9 | if (mounted && 10 | !context.debugDoingBuild && 11 | context.owner?.debugBuilding == false) { 12 | await fn(); 13 | setState(() {}); 14 | } 15 | } 16 | 17 | @override 18 | void initState() { 19 | super.initState(); 20 | Future.delayed(Duration.zero, () async { 21 | if (mounted) { 22 | await contextReady(); 23 | } 24 | }); 25 | } 26 | 27 | @override 28 | void setState(Function() fn) { 29 | if (mounted) { 30 | super.setState(fn); 31 | } 32 | } 33 | 34 | /// context可读回调 35 | Future contextReady() async {} 36 | } 37 | -------------------------------------------------------------------------------- /lib/src/helpers/safe_value_notifier.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | /// * ValueNotifier安全扩展 4 | /// * Safe ValueNotifier extension 5 | class SafeValueNotifier extends ValueNotifier { 6 | SafeValueNotifier(T value) : super(value); 7 | 8 | bool _mounted = true; 9 | 10 | @override 11 | set value(T newValue) { 12 | if (_mounted) { 13 | super.value = newValue; 14 | } 15 | } 16 | 17 | @override 18 | void dispose() { 19 | _mounted = false; 20 | super.dispose(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/src/stack_board.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:stack_board/src/stack_item_case/stack_item_case.dart'; 3 | import 'package:stack_board/src/widgets/ex_builder.dart'; 4 | 5 | import 'core/case_style.dart'; 6 | import 'core/stack_board_controller.dart'; 7 | import 'core/stack_board_item/stack_item.dart'; 8 | import 'core/stack_board_item/stack_item_content.dart'; 9 | import 'core/stack_board_item/stack_item_status.dart'; 10 | 11 | class StackBoardConfig extends InheritedWidget { 12 | const StackBoardConfig({ 13 | Key? key, 14 | required this.controller, 15 | this.caseStyle, 16 | required Widget child, 17 | }) : super(key: key, child: child); 18 | 19 | final StackBoardController controller; 20 | final CaseStyle? caseStyle; 21 | 22 | static StackBoardConfig of(BuildContext context) { 23 | final StackBoardConfig? result = 24 | context.dependOnInheritedWidgetOfExactType(); 25 | assert(result != null, 'No StackBoardConfig found in context'); 26 | return result!; 27 | } 28 | 29 | @override 30 | bool updateShouldNotify(covariant StackBoardConfig oldWidget) => 31 | oldWidget.controller != controller || oldWidget.caseStyle != caseStyle; 32 | } 33 | 34 | /// StackBoard 35 | class StackBoard extends StatelessWidget { 36 | const StackBoard({ 37 | Key? key, 38 | this.controller, 39 | this.background, 40 | this.caseStyle, 41 | this.customBuilder, 42 | this.onDel, 43 | this.onTap, 44 | this.onSizeChanged, 45 | this.onOffsetChanged, 46 | this.onAngleChanged, 47 | this.onStatusChanged, 48 | this.actionsBuilder, 49 | this.borderBuilder, 50 | }) : super(key: key); 51 | 52 | final StackBoardController? controller; 53 | 54 | /// * 背景 55 | /// * background 56 | final Widget? background; 57 | 58 | /// * 操作框样式 59 | /// * case style 60 | final CaseStyle? caseStyle; 61 | 62 | /// * 自定义类型控件构建器 63 | /// * custom builder 64 | final Widget? Function(StackItem item)? customBuilder; 65 | 66 | /// * 移除拦截 67 | /// * delete intercept 68 | final void Function(StackItem item)? onDel; 69 | 70 | /// * 点击回调 71 | /// * onTap item 72 | final void Function(StackItem item)? onTap; 73 | 74 | /// * 尺寸变化回调 75 | /// * 返回值可控制是否继续进行 76 | /// * size changed callback 77 | /// * return value can control whether to continue 78 | final bool? Function(StackItem item, Size size)? 79 | onSizeChanged; 80 | 81 | /// * 位置变化回调 82 | /// * 返回值可控制是否继续进行 83 | /// * offset changed callback 84 | /// * return value can control whether to continue 85 | final bool? Function(StackItem item, Offset offset)? 86 | onOffsetChanged; 87 | 88 | /// * 角度变化回调 89 | /// * 返回值可控制是否继续进行 90 | /// * angle changed callback 91 | /// * return value can control whether to continue 92 | final bool? Function(StackItem item, double angle)? 93 | onAngleChanged; 94 | 95 | /// * 操作状态回调 96 | /// * 返回值可控制是否继续进行 97 | /// * edit status changed callback 98 | /// * return value can control whether to continue 99 | final bool? Function( 100 | StackItem item, StackItemStatus operatState)? 101 | onStatusChanged; 102 | 103 | /// * 操作层构建器 104 | /// * actions builder 105 | final Widget Function(StackItemStatus operatState, CaseStyle caseStyle)? 106 | actionsBuilder; 107 | 108 | /// * 边框构建器 109 | /// * border builder 110 | final Widget Function(StackItemStatus operatState)? borderBuilder; 111 | 112 | StackBoardController get _controller => 113 | controller ?? StackBoardController.def(); 114 | 115 | @override 116 | Widget build(BuildContext context) { 117 | return StackBoardConfig( 118 | controller: _controller, 119 | caseStyle: caseStyle, 120 | child: GestureDetector( 121 | onTap: () => _controller.unSelectAll(), 122 | behavior: HitTestBehavior.opaque, 123 | child: ExBuilder( 124 | valueListenable: _controller, 125 | shouldRebuild: (StackConfig p, StackConfig n) => 126 | p.indexMap != n.indexMap, 127 | builder: (StackConfig sc) { 128 | return Stack( 129 | fit: StackFit.expand, 130 | children: [ 131 | const SizedBox.expand(), 132 | if (background != null) background!, 133 | for (final StackItem item in sc.data) 134 | _itemBuilder(item), 135 | ], 136 | ); 137 | }, 138 | ), 139 | ), 140 | ); 141 | } 142 | 143 | Widget _itemBuilder(StackItem item) { 144 | return StackItemCase( 145 | key: ValueKey(item.id), 146 | stackItem: item, 147 | childBuilder: customBuilder, 148 | caseStyle: caseStyle, 149 | onDel: () => onDel?.call(item), 150 | onTap: () => onTap?.call(item), 151 | onSizeChanged: (Size size) => onSizeChanged?.call(item, size) ?? true, 152 | onOffsetChanged: (Offset offset) => 153 | onOffsetChanged?.call(item, offset) ?? true, 154 | onAngleChanged: (double angle) => 155 | onAngleChanged?.call(item, angle) ?? true, 156 | onStatusChanged: (StackItemStatus operatState) => 157 | onStatusChanged?.call(item, operatState) ?? true, 158 | actionsBuilder: actionsBuilder, 159 | borderBuilder: borderBuilder, 160 | ); 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /lib/src/stack_board_items/item_case/stack_image_case.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:stack_board/src/core/stack_board_item/stack_item_status.dart'; 3 | import 'package:stack_board/src/stack_board_items/items/stack_image_item.dart'; 4 | 5 | class StackImageCase extends StatelessWidget { 6 | const StackImageCase({ 7 | Key? key, 8 | required this.item, 9 | }) : super(key: key); 10 | 11 | final StackImageItem item; 12 | 13 | ImageItemContent get content => item.content!; 14 | 15 | @override 16 | Widget build(BuildContext context) { 17 | return item.status == StackItemStatus.editing 18 | ? Center( 19 | child: TextFormField( 20 | initialValue: item.content?.url, 21 | onChanged: (String url) { 22 | item.setUrl(url); 23 | }, 24 | ), 25 | ) 26 | : Image( 27 | image: content.image, 28 | width: content.width, 29 | height: content.height, 30 | fit: content.fit, 31 | color: content.color, 32 | colorBlendMode: content.colorBlendMode, 33 | repeat: content.repeat, 34 | filterQuality: content.filterQuality, 35 | gaplessPlayback: content.gaplessPlayback, 36 | isAntiAlias: content.isAntiAlias, 37 | matchTextDirection: content.matchTextDirection, 38 | excludeFromSemantics: content.excludeFromSemantics, 39 | semanticLabel: content.semanticLabel, 40 | ); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /lib/src/stack_board_items/item_case/stack_text_case.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter/services.dart'; 3 | import 'package:stack_board/src/core/stack_board_item/stack_item_status.dart'; 4 | import 'package:stack_board/src/stack_board_items/items/stack_text_item.dart'; 5 | 6 | class StackTextCase extends StatelessWidget { 7 | const StackTextCase({ 8 | Key? key, 9 | required this.item, 10 | this.decoration, 11 | this.keyboardType, 12 | this.textCapitalization = TextCapitalization.none, 13 | this.textInputAction, 14 | this.textAlignVertical, 15 | this.controller, 16 | this.maxLength, 17 | this.onChanged, 18 | this.onEditingComplete, 19 | this.onTap, 20 | this.readOnly = false, 21 | this.autofocus = true, 22 | this.obscureText = false, 23 | this.maxLines, 24 | this.inputFormatters, 25 | this.focusNode, 26 | this.enabled = true, 27 | }) : super(key: key); 28 | 29 | final StackTextItem item; 30 | 31 | final InputDecoration? decoration; 32 | final TextEditingController? controller; 33 | 34 | final int? maxLength; 35 | 36 | final TextInputAction? textInputAction; 37 | 38 | final TextAlignVertical? textAlignVertical; 39 | 40 | final TextInputType? keyboardType; 41 | 42 | final Function(String)? onChanged; 43 | 44 | final Function()? onEditingComplete; 45 | 46 | final Function()? onTap; 47 | 48 | final bool readOnly; 49 | 50 | final bool autofocus; 51 | 52 | final bool obscureText; 53 | 54 | final int? maxLines; 55 | 56 | final List? inputFormatters; 57 | 58 | final FocusNode? focusNode; 59 | 60 | final bool enabled; 61 | 62 | final TextCapitalization textCapitalization; 63 | 64 | TextItemContent? get content => item.content; 65 | 66 | @override 67 | Widget build(BuildContext context) { 68 | return item.status == StackItemStatus.editing 69 | ? _buildEditing(context) 70 | : _buildNormal(context); 71 | } 72 | 73 | /// * 构建文本 74 | /// * Text 75 | Widget _buildNormal(BuildContext context) { 76 | return FittedBox( 77 | child: Text( 78 | content?.data ?? '', 79 | style: content?.style, 80 | strutStyle: content?.strutStyle?.style, 81 | textAlign: content?.textAlign, 82 | textDirection: content?.textDirection, 83 | locale: content?.locale, 84 | softWrap: content?.softWrap, 85 | overflow: content?.overflow, 86 | textScaler: content?.textScaleFactor != null 87 | ? TextScaler.linear(content!.textScaleFactor!) 88 | : TextScaler.noScaling, 89 | maxLines: content?.maxLines, 90 | semanticsLabel: content?.semanticsLabel, 91 | textWidthBasis: content?.textWidthBasis, 92 | textHeightBehavior: content?.textHeightBehavior, 93 | selectionColor: content?.selectionColor, 94 | ), 95 | ); 96 | } 97 | 98 | /// * 构建编辑框 99 | /// * TextFormField 100 | Widget _buildEditing(BuildContext context) { 101 | return Center( 102 | child: TextFormField( 103 | initialValue: content?.data, 104 | style: content?.style, 105 | strutStyle: content?.strutStyle?.style, 106 | textAlign: content?.textAlign ?? TextAlign.start, 107 | textDirection: content?.textDirection, 108 | maxLines: content?.maxLines, 109 | decoration: decoration, 110 | keyboardType: keyboardType, 111 | textCapitalization: textCapitalization, 112 | textInputAction: textInputAction, 113 | textAlignVertical: textAlignVertical, 114 | controller: controller, 115 | focusNode: focusNode, 116 | autofocus: autofocus, 117 | readOnly: readOnly, 118 | obscureText: obscureText, 119 | maxLength: maxLength, 120 | onChanged: (String str) { 121 | item.setData(str); 122 | onChanged?.call(str); 123 | }, 124 | onTap: onTap, 125 | onEditingComplete: onEditingComplete, 126 | inputFormatters: inputFormatters, 127 | enabled: enabled, 128 | ), 129 | ); 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /lib/src/stack_board_items/items/stack_draw_item.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:flutter_drawing_board/paint_contents.dart'; 4 | import 'package:stack_board/src/core/stack_board_item/stack_item.dart'; 5 | import 'package:stack_board/src/core/stack_board_item/stack_item_content.dart'; 6 | import 'package:stack_board/src/core/stack_board_item/stack_item_status.dart'; 7 | import 'package:stack_board/src/widget_style_extension/ex_offset.dart'; 8 | import 'package:stack_board/src/widget_style_extension/ex_size.dart'; 9 | 10 | import '../../../helpers.dart'; 11 | 12 | class DrawItemContent implements StackItemContent { 13 | DrawItemContent({ 14 | required this.size, 15 | required this.paintContents, 16 | }); 17 | 18 | factory DrawItemContent.fromJson( 19 | Map data, { 20 | PaintContent Function(String type, Map jsonStepMap)? 21 | contentFactory, 22 | }) { 23 | return DrawItemContent( 24 | size: data['size'] as double, 25 | paintContents: (data['paintContents'] as List).map((dynamic e) { 26 | final String type = e['type'] as String; 27 | 28 | final Map contentJson = e as Map; 29 | 30 | switch (type) { 31 | case 'Circle': 32 | return Circle.fromJson(contentJson); 33 | case 'Eraser': 34 | return Eraser.fromJson(contentJson); 35 | case 'Rectangle': 36 | return Rectangle.fromJson(contentJson); 37 | case 'SimpleLine': 38 | return SimpleLine.fromJson(contentJson); 39 | case 'SmoothLine': 40 | return SmoothLine.fromJson(contentJson); 41 | case 'StraightLine': 42 | return StraightLine.fromJson(contentJson); 43 | } 44 | 45 | return contentFactory?.call(type, contentJson) ?? 46 | EmptyContent.fromJson(contentJson); 47 | }).toList(), 48 | ); 49 | } 50 | 51 | double size; 52 | List paintContents; 53 | 54 | @override 55 | Map toJson() { 56 | return { 57 | 'size': size, 58 | 'paintContents': 59 | paintContents.map((PaintContent e) => e.toJson()).toList(), 60 | }; 61 | } 62 | } 63 | 64 | /// StackDrawItem 65 | class StackDrawItem extends StackItem { 66 | StackDrawItem({ 67 | DrawItemContent? content, 68 | String? id, 69 | double? angle, 70 | Size size = const Size(300, 300), 71 | Offset? offset, 72 | bool? lockZOrder, 73 | StackItemStatus? status, 74 | }) : super( 75 | id: id, 76 | size: size, 77 | offset: offset, 78 | angle: angle, 79 | status: status, 80 | lockZOrder: lockZOrder, 81 | content: content ?? 82 | DrawItemContent( 83 | size: size.shortestSide, paintContents: [])); 84 | 85 | factory StackDrawItem.fromJson(Map data) { 86 | return StackDrawItem( 87 | id: data['id'] as String?, 88 | angle: data['angle'] as double?, 89 | size: jsonToSize(data['size'] as Map), 90 | offset: jsonToOffset(data['offset'] as Map), 91 | status: StackItemStatus.values[data['status'] as int], 92 | lockZOrder: asNullT(data['lockZOrder']) ?? false, 93 | content: 94 | DrawItemContent.fromJson(data['content'] as Map), 95 | ); 96 | } 97 | 98 | /// * 覆盖绘制内容 99 | /// * Override the drawing content 100 | void setContents(List contents) { 101 | content!.paintContents = contents; 102 | } 103 | 104 | @override 105 | StackDrawItem copyWith({ 106 | Size? size, 107 | Offset? offset, 108 | double? angle, 109 | StackItemStatus? status, 110 | bool? lockZOrder, 111 | DrawItemContent? content, 112 | }) { 113 | return StackDrawItem( 114 | id: id, 115 | size: size ?? this.size, 116 | offset: offset ?? this.offset, 117 | angle: angle ?? this.angle, 118 | status: status ?? this.status, 119 | lockZOrder: lockZOrder ?? this.lockZOrder, 120 | content: content ?? this.content, 121 | ); 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /lib/src/stack_board_items/items/stack_image_item.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:stack_board/helpers.dart'; 3 | import 'package:stack_board/src/core/stack_board_item/stack_item.dart'; 4 | import 'package:stack_board/src/core/stack_board_item/stack_item_content.dart'; 5 | import 'package:stack_board/src/core/stack_board_item/stack_item_status.dart'; 6 | import 'package:stack_board/src/widget_style_extension/ex_offset.dart'; 7 | import 'package:stack_board/src/widget_style_extension/ex_size.dart'; 8 | 9 | class ImageItemContent extends StackItemContent { 10 | ImageItemContent({ 11 | this.url, 12 | this.assetName, 13 | this.semanticLabel, 14 | this.excludeFromSemantics = false, 15 | this.width, 16 | this.height, 17 | this.color, 18 | this.colorBlendMode, 19 | this.fit = BoxFit.cover, 20 | this.repeat = ImageRepeat.noRepeat, 21 | this.matchTextDirection = false, 22 | this.gaplessPlayback = false, 23 | this.isAntiAlias = false, 24 | this.filterQuality = FilterQuality.low, 25 | }) { 26 | _init(); 27 | } 28 | 29 | factory ImageItemContent.fromJson(Map json) { 30 | return ImageItemContent( 31 | url: json['url'] != null ? asT(json['url']) : null, 32 | assetName: 33 | json['assetName'] != null ? asT(json['assetName']) : null, 34 | semanticLabel: json['semanticLabel'] != null 35 | ? asT(json['semanticLabel']) 36 | : null, 37 | excludeFromSemantics: 38 | asNullT(json['excludeFromSemantics']) ?? false, 39 | width: json['width'] != null ? asT(json['width']) : null, 40 | height: json['height'] != null ? asT(json['height']) : null, 41 | color: json['color'] != null ? Color(asT(json['color'])) : null, 42 | colorBlendMode: json['colorBlendMode'] != null 43 | ? BlendMode.values[asT(json['colorBlendMode'])] 44 | : BlendMode.srcIn, 45 | fit: json['fit'] != null 46 | ? BoxFit.values[asT(json['fit'])] 47 | : BoxFit.cover, 48 | repeat: json['repeat'] != null 49 | ? ImageRepeat.values[asT(json['repeat'])] 50 | : ImageRepeat.noRepeat, 51 | matchTextDirection: asNullT(json['matchTextDirection']) ?? false, 52 | gaplessPlayback: asNullT(json['gaplessPlayback']) ?? false, 53 | isAntiAlias: asNullT(json['isAntiAlias']) ?? true, 54 | filterQuality: json['filterQuality'] != null 55 | ? FilterQuality.values[asT(json['filterQuality'])] 56 | : FilterQuality.high, 57 | ); 58 | } 59 | 60 | void _init() { 61 | if (url != null && assetName != null) { 62 | throw Exception('url and assetName can not be set at the same time'); 63 | } 64 | 65 | if (url == null && assetName == null) { 66 | throw Exception('url and assetName can not be null at the same time'); 67 | } 68 | 69 | if (url != null) { 70 | _image = NetworkImage(url!); 71 | } else if (assetName != null) { 72 | _image = AssetImage(assetName!); 73 | } 74 | } 75 | 76 | late ImageProvider _image; 77 | String? url; 78 | String? assetName; 79 | String? semanticLabel; 80 | bool excludeFromSemantics; 81 | double? width; 82 | double? height; 83 | Color? color; 84 | BlendMode? colorBlendMode; 85 | BoxFit fit; 86 | ImageRepeat repeat; 87 | bool matchTextDirection; 88 | bool gaplessPlayback; 89 | bool isAntiAlias; 90 | FilterQuality filterQuality; 91 | 92 | ImageProvider get image => _image; 93 | 94 | void setRes({ 95 | String? url, 96 | String? assetName, 97 | }) { 98 | if (url != null) this.url = url; 99 | if (assetName != null) this.assetName = assetName; 100 | _init(); 101 | } 102 | 103 | @override 104 | Map toJson() { 105 | return { 106 | if (url != null) 'url': url, 107 | if (assetName != null) 'assetName': assetName, 108 | if (semanticLabel != null) 'semanticLabel': semanticLabel, 109 | 'excludeFromSemantics': excludeFromSemantics, 110 | if (width != null) 'width': width, 111 | if (height != null) 'height': height, 112 | if (color != null) 'color': color?.value, 113 | if (colorBlendMode != null) 'colorBlendMode': colorBlendMode?.index, 114 | 'fit': fit.index, 115 | 'repeat': repeat.index, 116 | 'matchTextDirection': matchTextDirection, 117 | 'gaplessPlayback': gaplessPlayback, 118 | 'isAntiAlias': isAntiAlias, 119 | 'filterQuality': filterQuality.index, 120 | }; 121 | } 122 | } 123 | 124 | class StackImageItem extends StackItem { 125 | StackImageItem({ 126 | required ImageItemContent? content, 127 | String? id, 128 | double? angle, 129 | required Size size, 130 | Offset? offset, 131 | StackItemStatus? status, 132 | bool? lockZOrder, 133 | }) : super( 134 | id: id, 135 | size: size, 136 | offset: offset, 137 | angle: angle, 138 | status: status, 139 | content: content, 140 | lockZOrder: lockZOrder, 141 | ); 142 | 143 | factory StackImageItem.fromJson(Map data) { 144 | return StackImageItem( 145 | id: data['id'] == null ? null : asT(data['id']), 146 | angle: data['angle'] == null ? null : asT(data['angle']), 147 | size: jsonToSize(asMap(data['size'])), 148 | offset: 149 | data['offset'] == null ? null : jsonToOffset(asMap(data['offset'])), 150 | status: StackItemStatus.values[data['status'] as int], 151 | lockZOrder: asNullT(data['lockZOrder']) ?? false, 152 | content: ImageItemContent.fromJson(asMap(data['content'])), 153 | ); 154 | } 155 | 156 | void setUrl(String url) { 157 | content?.setRes(url: url); 158 | } 159 | 160 | void setAssetName(String assetName) { 161 | content?.setRes(assetName: assetName); 162 | } 163 | 164 | @override 165 | StackImageItem copyWith({ 166 | Size? size, 167 | Offset? offset, 168 | double? angle, 169 | StackItemStatus? status, 170 | bool? lockZOrder, 171 | ImageItemContent? content, 172 | }) { 173 | return StackImageItem( 174 | id: id, 175 | size: size ?? this.size, 176 | offset: offset ?? this.offset, 177 | angle: angle ?? this.angle, 178 | status: status ?? this.status, 179 | lockZOrder: lockZOrder ?? this.lockZOrder, 180 | content: content ?? this.content, 181 | ); 182 | } 183 | } 184 | -------------------------------------------------------------------------------- /lib/src/stack_board_items/items/stack_text_item.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/painting.dart'; 2 | import 'package:stack_board/src/core/stack_board_item/stack_item.dart'; 3 | import 'package:stack_board/src/core/stack_board_item/stack_item_content.dart'; 4 | import 'package:stack_board/src/core/stack_board_item/stack_item_status.dart'; 5 | import 'package:stack_board/src/helpers/as_t.dart'; 6 | import 'package:stack_board/src/helpers/ex_enum.dart'; 7 | import 'package:stack_board/src/widget_style_extension/ex_locale.dart'; 8 | import 'package:stack_board/src/widget_style_extension/ex_offset.dart'; 9 | import 'package:stack_board/src/widget_style_extension/ex_size.dart'; 10 | import 'package:stack_board/src/widget_style_extension/ex_text_height_behavior.dart'; 11 | import 'package:stack_board/src/widget_style_extension/ex_text_style.dart'; 12 | import 'package:stack_board/src/widget_style_extension/stack_text_strut_style.dart'; 13 | 14 | /// TextItemContent 15 | class TextItemContent implements StackItemContent { 16 | TextItemContent({ 17 | this.data, 18 | this.style, 19 | this.strutStyle, 20 | this.textAlign, 21 | this.textDirection, 22 | this.locale, 23 | this.softWrap, 24 | this.overflow, 25 | this.textScaleFactor, 26 | this.maxLines, 27 | this.semanticsLabel, 28 | this.textWidthBasis, 29 | this.textHeightBehavior, 30 | this.selectionColor, 31 | }); 32 | 33 | factory TextItemContent.fromJson(Map data) { 34 | return TextItemContent( 35 | data: data['data'] == null ? null : asT(data['data']), 36 | style: 37 | data['style'] == null ? null : jsonToTextStyle(asMap(data['style'])), 38 | strutStyle: data['strutStyle'] == null 39 | ? null 40 | : StackTextStrutStyle.fromJson(asMap(data['strutStyle'])), 41 | textAlign: data['textAlign'] == null 42 | ? null 43 | : ExEnum.tryParse( 44 | TextAlign.values, asT(data['textAlign'])), 45 | textDirection: data['textDirection'] == null 46 | ? null 47 | : ExEnum.tryParse( 48 | TextDirection.values, asT(data['textDirection'])), 49 | locale: 50 | data['locale'] == null ? null : jsonToLocale(asMap(data['locale'])), 51 | softWrap: data['softWrap'] == null ? null : asT(data['softWrap']), 52 | overflow: data['overflow'] == null 53 | ? null 54 | : ExEnum.tryParse( 55 | TextOverflow.values, asT(data['overflow'])), 56 | textScaleFactor: data['textScaleFactor'] == null 57 | ? null 58 | : asT(data['textScaleFactor']), 59 | maxLines: data['maxLines'] == null ? null : asT(data['maxLines']), 60 | semanticsLabel: data['semanticsLabel'] == null 61 | ? null 62 | : asT(data['semanticsLabel']), 63 | textWidthBasis: data['textWidthBasis'] == null 64 | ? null 65 | : ExEnum.tryParse( 66 | TextWidthBasis.values, asT(data['textWidthBasis'])), 67 | textHeightBehavior: data['textHeightBehavior'] == null 68 | ? null 69 | : jsonToTextHeightBehavior(asMap(data['textHeightBehavior'])), 70 | selectionColor: data['selectionColor'] == null 71 | ? null 72 | : Color(asT(data['selectionColor'])), 73 | ); 74 | } 75 | 76 | String? data; 77 | TextStyle? style; 78 | StackTextStrutStyle? strutStyle; 79 | TextAlign? textAlign; 80 | TextDirection? textDirection; 81 | Locale? locale; 82 | bool? softWrap; 83 | TextOverflow? overflow; 84 | double? textScaleFactor; 85 | int? maxLines; 86 | String? semanticsLabel; 87 | TextWidthBasis? textWidthBasis; 88 | TextHeightBehavior? textHeightBehavior; 89 | Color? selectionColor; 90 | 91 | @override 92 | Map toJson() { 93 | return { 94 | if (data != null) 'data': data, 95 | if (style != null) 'style': style?.toJson(), 96 | if (strutStyle != null) 'strutStyle': strutStyle?.toJson(), 97 | if (textAlign != null) 'textAlign': textAlign?.toString(), 98 | if (textDirection != null) 'textDirection': textDirection?.toString(), 99 | if (locale != null) 'locale': locale?.toJson(), 100 | if (softWrap != null) 'softWrap': softWrap, 101 | if (overflow != null) 'overflow': overflow?.toString(), 102 | if (textScaleFactor != null) 'textScaleFactor': textScaleFactor, 103 | if (maxLines != null) 'maxLines': maxLines, 104 | if (semanticsLabel != null) 'semanticsLabel': semanticsLabel, 105 | if (textWidthBasis != null) 'textWidthBasis': textWidthBasis?.toString(), 106 | if (textHeightBehavior != null) 107 | 'textHeightBehavior': textHeightBehavior?.toJson(), 108 | if (selectionColor != null) 'selectionColor': selectionColor?.value, 109 | }; 110 | } 111 | } 112 | 113 | /// StackTextItem 114 | class StackTextItem extends StackItem { 115 | StackTextItem({ 116 | TextItemContent? content, 117 | String? id, 118 | double? angle, 119 | required Size size, 120 | Offset? offset, 121 | bool? lockZOrder, 122 | StackItemStatus? status, 123 | }) : super( 124 | id: id, 125 | size: size, 126 | offset: offset, 127 | angle: angle, 128 | status: status, 129 | lockZOrder: lockZOrder, 130 | content: content, 131 | ); 132 | 133 | factory StackTextItem.fromJson(Map data) { 134 | return StackTextItem( 135 | id: data['id'] == null ? null : asT(data['id']), 136 | angle: data['angle'] == null ? null : asT(data['angle']), 137 | size: jsonToSize(asMap(data['size'])), 138 | offset: 139 | data['offset'] == null ? null : jsonToOffset(asMap(data['offset'])), 140 | status: StackItemStatus.values[data['status'] as int], 141 | lockZOrder: asNullT(data['lockZOrder']) ?? false, 142 | content: TextItemContent.fromJson(asMap(data['content'])), 143 | ); 144 | } 145 | 146 | /// * 覆盖文本 147 | /// * Override text 148 | void setData(String str) { 149 | content!.data = str; 150 | } 151 | 152 | @override 153 | StackTextItem copyWith({ 154 | double? angle, 155 | Size? size, 156 | Offset? offset, 157 | StackItemStatus? status, 158 | bool? lockZOrder, 159 | TextItemContent? content, 160 | }) { 161 | return StackTextItem( 162 | id: id, 163 | angle: angle ?? this.angle, 164 | size: size ?? this.size, 165 | offset: offset ?? this.offset, 166 | status: status ?? this.status, 167 | lockZOrder: lockZOrder ?? this.lockZOrder, 168 | content: content ?? this.content, 169 | ); 170 | } 171 | } 172 | -------------------------------------------------------------------------------- /lib/src/stack_item_case/config_builder.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:stack_board/src/core/stack_board_controller.dart'; 3 | import 'package:stack_board/src/core/stack_board_item/stack_item.dart'; 4 | import 'package:stack_board/src/core/stack_board_item/stack_item_content.dart'; 5 | import 'package:stack_board/src/stack_board.dart'; 6 | import 'package:stack_board/src/widgets/ex_builder.dart'; 7 | 8 | export 'package:stack_board/src/core/stack_board_controller.dart'; 9 | 10 | /// Config Builder 11 | class ConfigBuilder extends StatelessWidget { 12 | const ConfigBuilder({ 13 | Key? key, 14 | this.shouldRebuild, 15 | this.childBuilder, 16 | required this.child, 17 | }) : super(key: key); 18 | 19 | final bool Function(StackConfig p, StackConfig n)? shouldRebuild; 20 | final Widget Function(StackConfig sc, Widget c)? childBuilder; 21 | final Widget child; 22 | 23 | @override 24 | Widget build(BuildContext context) { 25 | return ExBuilder.child( 26 | valueListenable: StackBoardConfig.of(context).controller, 27 | shouldRebuild: shouldRebuild, 28 | childBuilder: childBuilder, 29 | child: child, 30 | ); 31 | } 32 | 33 | static Widget withItem( 34 | String id, { 35 | required Widget child, 36 | bool Function(StackItem p, StackItem n)? 37 | shouldRebuild, 38 | Widget Function(StackItem item, Widget c)? childBuilder, 39 | }) { 40 | return ConfigBuilder( 41 | shouldRebuild: (StackConfig p, StackConfig n) { 42 | try { 43 | final StackItem pI = p[id]; 44 | final StackItem nI = n[id]; 45 | 46 | return shouldRebuild?.call(pI, nI) ?? true; 47 | } catch (e) { 48 | return true; 49 | } 50 | }, 51 | childBuilder: (StackConfig sc, Widget c) { 52 | final StackItem item = sc[id]; 53 | return childBuilder?.call(item, c) ?? c; 54 | }, 55 | child: child, 56 | ); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /lib/src/widget_style_extension/ex_locale.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/painting.dart'; 2 | import 'package:stack_board/src/helpers/as_t.dart'; 3 | 4 | extension ExLocale on Locale { 5 | Map toJson() { 6 | return { 7 | 'languageCode': languageCode, 8 | if (countryCode != null) 'countryCode': countryCode, 9 | }; 10 | } 11 | } 12 | 13 | Locale jsonToLocale(Map data) { 14 | return Locale( 15 | asT(data['languageCode']), asNullT(data['countryCode'])); 16 | } 17 | -------------------------------------------------------------------------------- /lib/src/widget_style_extension/ex_offset.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/painting.dart'; 2 | import 'package:stack_board/src/helpers/as_t.dart'; 3 | 4 | extension ExOffset on Offset { 5 | Map toJson() { 6 | return {'dx': dx, 'dy': dy}; 7 | } 8 | } 9 | 10 | Offset? jsonToOffset(Map? data) { 11 | if (data == null) { 12 | return null; 13 | } 14 | return Offset(asT(data['dx']), asT(data['dy'])); 15 | } 16 | -------------------------------------------------------------------------------- /lib/src/widget_style_extension/ex_size.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:stack_board/src/helpers/as_t.dart'; 4 | 5 | extension ExSize on Size { 6 | Map toJson() { 7 | return { 8 | 'width': width, 9 | 'height': height, 10 | }; 11 | } 12 | } 13 | 14 | Size jsonToSize(Map data) { 15 | return Size(asT(data['width']), asT(data['height'])); 16 | } 17 | -------------------------------------------------------------------------------- /lib/src/widget_style_extension/ex_text_height_behavior.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/painting.dart'; 2 | import 'package:stack_board/src/helpers/as_t.dart'; 3 | import 'package:stack_board/src/helpers/ex_enum.dart'; 4 | 5 | extension ExTextHeightBehavior on TextHeightBehavior { 6 | Map toJson() { 7 | return { 8 | 'applyHeightToFirstAscent': applyHeightToFirstAscent, 9 | 'applyHeightToLastDescent': applyHeightToLastDescent, 10 | 'leadingDistribution': leadingDistribution.toString(), 11 | }; 12 | } 13 | } 14 | 15 | TextHeightBehavior jsonToTextHeightBehavior(Map data) { 16 | return TextHeightBehavior( 17 | applyHeightToFirstAscent: asT(data['applyHeightToFirstAscent']), 18 | applyHeightToLastDescent: asT(data['applyHeightToLastDescent']), 19 | leadingDistribution: ExEnum.tryParse( 20 | TextLeadingDistribution.values, 21 | asT(data['leadingDistribution'])) ?? 22 | TextLeadingDistribution.proportional, 23 | ); 24 | } 25 | -------------------------------------------------------------------------------- /lib/src/widget_style_extension/ex_text_style.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/painting.dart'; 2 | import 'package:stack_board/src/helpers/as_t.dart'; 3 | import 'package:stack_board/src/helpers/ex_enum.dart'; 4 | import 'ex_locale.dart'; 5 | 6 | extension ExTextStyle on TextStyle { 7 | Map toJson() { 8 | return { 9 | if (color != null) 'color': color?.value, 10 | if (decoration != null) 'decoration': decoration?.toString(), 11 | if (decorationColor != null) 'decorationColor': decorationColor?.value, 12 | if (decorationStyle != null) 13 | 'decorationStyle': decorationStyle?.toString(), 14 | if (decorationThickness != null) 15 | 'decorationThickness': decorationThickness, 16 | if (fontWeight != null) 'fontWeight': fontWeight?.toString(), 17 | if (fontStyle != null) 'fontStyle': fontStyle?.toString(), 18 | if (fontFamily != null) 'fontFamily': fontFamily, 19 | if (fontFamilyFallback != null) 20 | 'fontFamilyFallback': fontFamilyFallback?.join(','), 21 | if (fontSize != null) 'fontSize': fontSize, 22 | if (letterSpacing != null) 'letterSpacing': letterSpacing, 23 | if (wordSpacing != null) 'wordSpacing': wordSpacing, 24 | if (textBaseline != null) 'textBaseline': textBaseline?.toString(), 25 | if (height != null) 'height': height, 26 | if (locale != null) 'locale': locale?.toJson(), 27 | }; 28 | } 29 | } 30 | 31 | TextStyle? jsonToTextStyle(Map data) { 32 | return TextStyle( 33 | color: data['color'] == null ? null : Color(asT(data['color'])), 34 | decoration: data['decoration'] == null 35 | ? null 36 | : stringToTextDecoration(asT(data['decoration'])), 37 | decorationColor: data['decorationColor'] == null 38 | ? null 39 | : Color(asT(data['decorationColor'])), 40 | decorationStyle: ExEnum.tryParse( 41 | TextDecorationStyle.values, asT(data['decorationStyle'])), 42 | decorationThickness: data['decorationThickness'] == null 43 | ? null 44 | : asT(data['decorationThickness']), 45 | fontWeight: ExEnum.tryParse( 46 | FontWeight.values, asT(data['fontWeight'])), 47 | fontStyle: ExEnum.tryParse( 48 | FontStyle.values, asT(data['fontStyle'])), 49 | fontFamily: 50 | data['fontFamily'] == null ? null : asT(data['fontFamily']), 51 | fontFamilyFallback: data['fontFamilyFallback'] == null 52 | ? null 53 | : asT(data['fontFamilyFallback']).split(','), 54 | fontSize: data['fontSize'] == null ? null : asT(data['fontSize']), 55 | letterSpacing: data['letterSpacing'] == null 56 | ? null 57 | : asT(data['letterSpacing']), 58 | wordSpacing: 59 | data['wordSpacing'] == null ? null : asT(data['wordSpacing']), 60 | textBaseline: 61 | ExEnum.tryParse(TextBaseline.values, asT(data['textBaseline'])), 62 | height: data['height'] == null ? null : asT(data['height']), 63 | locale: data['locale'] == null ? null : jsonToLocale(asMap(data['locale'])), 64 | ); 65 | } 66 | 67 | TextDecoration? stringToTextDecoration(String data) { 68 | if (!data.contains('combine')) { 69 | switch (data) { 70 | case 'TextDecoration.none': 71 | return TextDecoration.none; 72 | case 'TextDecoration.underline': 73 | return TextDecoration.underline; 74 | case 'TextDecoration.overline': 75 | return TextDecoration.overline; 76 | case 'TextDecoration.lineThrough': 77 | return TextDecoration.lineThrough; 78 | default: 79 | return TextDecoration.none; 80 | } 81 | } 82 | 83 | final List values = data.split('[')[1].split(']')[0].split(', '); 84 | final List decorations = []; 85 | for (final String value in values) { 86 | switch (value) { 87 | case 'underline': 88 | decorations.add(TextDecoration.underline); 89 | break; 90 | case 'overline': 91 | decorations.add(TextDecoration.overline); 92 | break; 93 | case 'lineThrough': 94 | decorations.add(TextDecoration.lineThrough); 95 | break; 96 | default: 97 | break; 98 | } 99 | } 100 | 101 | return TextDecoration.combine(decorations); 102 | } 103 | -------------------------------------------------------------------------------- /lib/src/widget_style_extension/stack_text_strut_style.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | import 'package:stack_board/src/helpers/as_t.dart'; 3 | import 'package:stack_board/src/helpers/ex_enum.dart'; 4 | 5 | class StackTextStrutStyle { 6 | StackTextStrutStyle({ 7 | this.fontFamily, 8 | this.fontFamilyFallback, 9 | this.fontSize, 10 | this.height, 11 | this.leadingDistribution, 12 | this.leading, 13 | this.fontWeight, 14 | this.fontStyle, 15 | this.forceStrutHeight, 16 | }); 17 | 18 | factory StackTextStrutStyle.fromJson(Map data) { 19 | return StackTextStrutStyle( 20 | fontFamily: asNullT(data['fontFamily']), 21 | fontFamilyFallback: 22 | asNullT(data['fontFamilyFallback'])?.split(','), 23 | fontSize: asNullT(data['fontSize']), 24 | height: asNullT(data['height']), 25 | leadingDistribution: ExEnum.tryParse( 26 | TextLeadingDistribution.values, 27 | asNullT(data['leadingDistribution'])), 28 | leading: asNullT(data['leading']), 29 | fontWeight: ExEnum.tryParse( 30 | FontWeight.values, asNullT(data['fontWeight'])), 31 | fontStyle: ExEnum.tryParse( 32 | FontStyle.values, asNullT(data['fontStyle'])), 33 | forceStrutHeight: asNullT(data['forceStrutHeight']), 34 | ); 35 | } 36 | 37 | final String? fontFamily; 38 | final List? fontFamilyFallback; 39 | final double? fontSize; 40 | final double? height; 41 | final TextLeadingDistribution? leadingDistribution; 42 | final double? leading; 43 | final FontWeight? fontWeight; 44 | final FontStyle? fontStyle; 45 | final bool? forceStrutHeight; 46 | 47 | StrutStyle get style { 48 | return StrutStyle( 49 | fontFamily: fontFamily, 50 | fontFamilyFallback: fontFamilyFallback, 51 | fontSize: fontSize, 52 | height: height, 53 | leadingDistribution: leadingDistribution, 54 | leading: leading, 55 | fontWeight: fontWeight, 56 | fontStyle: fontStyle, 57 | forceStrutHeight: forceStrutHeight, 58 | ); 59 | } 60 | 61 | Map toJson() { 62 | return { 63 | if (fontFamily != null) 'fontFamily': fontFamily, 64 | if (fontFamilyFallback != null) 65 | 'fontFamilyFallback': fontFamilyFallback?.join(','), 66 | if (fontSize != null) 'fontSize': fontSize, 67 | if (height != null) 'height': height, 68 | if (leadingDistribution != null) 69 | 'leadingDistribution': leadingDistribution.toString(), 70 | if (leading != null) 'leading': leading, 71 | if (fontWeight != null) 'fontWeight': fontWeight, 72 | if (fontStyle != null) 'fontStyle': fontStyle, 73 | if (forceStrutHeight != null) 'forceStrutHeight': forceStrutHeight, 74 | }; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /lib/src/widgets/ex_builder.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:stack_board/src/helpers/safe_state.dart'; 4 | 5 | /// * 简化的 `ExValueBuilder` 6 | /// * Simplified `ExValueBuilder` 7 | class ExBuilder extends StatefulWidget { 8 | const ExBuilder({ 9 | Key? key, 10 | required this.valueListenable, 11 | required this.builder, 12 | this.shouldRebuild, 13 | }) : child = null, 14 | childBuilder = null, 15 | super(key: key); 16 | 17 | const ExBuilder.child({ 18 | Key? key, 19 | required this.valueListenable, 20 | required this.childBuilder, 21 | required this.child, 22 | this.shouldRebuild, 23 | }) : builder = null, 24 | super(key: key); 25 | 26 | final ValueListenable valueListenable; 27 | 28 | final Widget? child; 29 | 30 | final Widget Function(T value)? builder; 31 | 32 | final Widget Function(T value, Widget child)? childBuilder; 33 | 34 | ///是否进行重建 35 | final bool Function(T previous, T next)? shouldRebuild; 36 | 37 | @override 38 | State createState() => _ExBuilderState(); 39 | } 40 | 41 | class _ExBuilderState extends State> 42 | with SafeState> { 43 | late T _value; 44 | 45 | @override 46 | void initState() { 47 | super.initState(); 48 | _value = widget.valueListenable.value; 49 | widget.valueListenable.addListener(_valueChanged); 50 | } 51 | 52 | @override 53 | void didUpdateWidget(ExBuilder oldWidget) { 54 | if (oldWidget.valueListenable != widget.valueListenable) { 55 | oldWidget.valueListenable.removeListener(_valueChanged); 56 | _value = widget.valueListenable.value; 57 | widget.valueListenable.addListener(_valueChanged); 58 | } 59 | super.didUpdateWidget(oldWidget); 60 | } 61 | 62 | @override 63 | void dispose() { 64 | widget.valueListenable.removeListener(_valueChanged); 65 | super.dispose(); 66 | } 67 | 68 | void _valueChanged() { 69 | ///条件判断 70 | if (widget.shouldRebuild?.call(_value, widget.valueListenable.value) ?? 71 | true) { 72 | safeSetState(() { 73 | _value = widget.valueListenable.value; 74 | }); 75 | } 76 | } 77 | 78 | @override 79 | Widget build(BuildContext context) { 80 | if (widget.child == null) { 81 | return widget.builder?.call(_value) ?? 82 | widget.childBuilder 83 | ?.call(_value, widget.child ?? const SizedBox.shrink()) ?? 84 | const SizedBox.shrink(); 85 | } 86 | 87 | return widget.childBuilder?.call(_value, widget.child!) ?? 88 | const SizedBox.shrink(); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /lib/src/widgets/get_size.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter/rendering.dart'; 3 | 4 | typedef OnWidgetSizeChange = void Function(Size size); 5 | 6 | class _MeasureSizeRenderObject extends RenderProxyBox { 7 | _MeasureSizeRenderObject(this.onChange); 8 | 9 | Size? oldSize; 10 | final OnWidgetSizeChange onChange; 11 | 12 | @override 13 | void performLayout() { 14 | super.performLayout(); 15 | 16 | final Size newSize = child!.size; 17 | if (oldSize == newSize) { 18 | return; 19 | } 20 | 21 | oldSize = newSize; 22 | 23 | WidgetsBinding.instance.addPostFrameCallback((_) { 24 | onChange(newSize); 25 | }); 26 | } 27 | } 28 | 29 | class GetSize extends SingleChildRenderObjectWidget { 30 | const GetSize({ 31 | Key? key, 32 | required this.onChanged, 33 | required Widget child, 34 | }) : super(key: key, child: child); 35 | final OnWidgetSizeChange onChanged; 36 | 37 | @override 38 | RenderObject createRenderObject(BuildContext context) { 39 | return _MeasureSizeRenderObject(onChanged); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lib/stack_board_item.dart: -------------------------------------------------------------------------------- 1 | library stack_board_item; 2 | 3 | export 'src/core/stack_board_item/stack_item.dart'; 4 | export 'src/core/stack_board_item/stack_item_content.dart'; 5 | export 'src/core/stack_board_item/stack_item_status.dart'; 6 | -------------------------------------------------------------------------------- /lib/stack_board_items.dart: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/stack_case.dart: -------------------------------------------------------------------------------- 1 | library stack_case; 2 | 3 | export 'src/stack_board_items/item_case/stack_draw_case.dart'; 4 | export 'src/stack_board_items/item_case/stack_image_case.dart'; 5 | export 'src/stack_board_items/item_case/stack_text_case.dart'; 6 | -------------------------------------------------------------------------------- /lib/stack_items.dart: -------------------------------------------------------------------------------- 1 | library stack_items; 2 | 3 | export 'src/stack_board_items/items/stack_draw_item.dart'; 4 | export 'src/stack_board_items/items/stack_image_item.dart'; 5 | export 'src/stack_board_items/items/stack_text_item.dart'; 6 | -------------------------------------------------------------------------------- /lib/widget_style_extension.dart: -------------------------------------------------------------------------------- 1 | library widget_style_extension; 2 | 3 | export 'src/widget_style_extension/ex_locale.dart'; 4 | export 'src/widget_style_extension/ex_offset.dart'; 5 | export 'src/widget_style_extension/ex_size.dart'; 6 | export 'src/widget_style_extension/ex_text_height_behavior.dart'; 7 | export 'src/widget_style_extension/ex_text_style.dart'; 8 | export 'src/widget_style_extension/stack_text_strut_style.dart'; 9 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" 9 | url: "https://pub.dev" 10 | source: hosted 11 | version: "2.11.0" 12 | boolean_selector: 13 | dependency: transitive 14 | description: 15 | name: boolean_selector 16 | sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" 17 | url: "https://pub.dev" 18 | source: hosted 19 | version: "2.1.1" 20 | characters: 21 | dependency: transitive 22 | description: 23 | name: characters 24 | sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" 25 | url: "https://pub.dev" 26 | source: hosted 27 | version: "1.3.0" 28 | clock: 29 | dependency: transitive 30 | description: 31 | name: clock 32 | sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf 33 | url: "https://pub.dev" 34 | source: hosted 35 | version: "1.1.1" 36 | collection: 37 | dependency: transitive 38 | description: 39 | name: collection 40 | sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a 41 | url: "https://pub.dev" 42 | source: hosted 43 | version: "1.18.0" 44 | fake_async: 45 | dependency: transitive 46 | description: 47 | name: fake_async 48 | sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" 49 | url: "https://pub.dev" 50 | source: hosted 51 | version: "1.3.1" 52 | flutter: 53 | dependency: "direct main" 54 | description: flutter 55 | source: sdk 56 | version: "0.0.0" 57 | flutter_drawing_board: 58 | dependency: "direct main" 59 | description: 60 | name: flutter_drawing_board 61 | sha256: "82700847d7f367c9af1eaf186c88f74a6be821dbe783871e4736bf724f015192" 62 | url: "https://pub.dev" 63 | source: hosted 64 | version: "0.7.0+2" 65 | flutter_lints: 66 | dependency: "direct dev" 67 | description: 68 | name: flutter_lints 69 | sha256: b543301ad291598523947dc534aaddc5aaad597b709d2426d3a0e0d44c5cb493 70 | url: "https://pub.dev" 71 | source: hosted 72 | version: "1.0.4" 73 | flutter_test: 74 | dependency: "direct dev" 75 | description: flutter 76 | source: sdk 77 | version: "0.0.0" 78 | leak_tracker: 79 | dependency: transitive 80 | description: 81 | name: leak_tracker 82 | sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" 83 | url: "https://pub.dev" 84 | source: hosted 85 | version: "10.0.0" 86 | leak_tracker_flutter_testing: 87 | dependency: transitive 88 | description: 89 | name: leak_tracker_flutter_testing 90 | sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 91 | url: "https://pub.dev" 92 | source: hosted 93 | version: "2.0.1" 94 | leak_tracker_testing: 95 | dependency: transitive 96 | description: 97 | name: leak_tracker_testing 98 | sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 99 | url: "https://pub.dev" 100 | source: hosted 101 | version: "2.0.1" 102 | lints: 103 | dependency: transitive 104 | description: 105 | name: lints 106 | sha256: a2c3d198cb5ea2e179926622d433331d8b58374ab8f29cdda6e863bd62fd369c 107 | url: "https://pub.dev" 108 | source: hosted 109 | version: "1.0.1" 110 | matcher: 111 | dependency: transitive 112 | description: 113 | name: matcher 114 | sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb 115 | url: "https://pub.dev" 116 | source: hosted 117 | version: "0.12.16+1" 118 | material_color_utilities: 119 | dependency: transitive 120 | description: 121 | name: material_color_utilities 122 | sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" 123 | url: "https://pub.dev" 124 | source: hosted 125 | version: "0.8.0" 126 | meta: 127 | dependency: "direct main" 128 | description: 129 | name: meta 130 | sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 131 | url: "https://pub.dev" 132 | source: hosted 133 | version: "1.11.0" 134 | path: 135 | dependency: transitive 136 | description: 137 | name: path 138 | sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" 139 | url: "https://pub.dev" 140 | source: hosted 141 | version: "1.9.0" 142 | sky_engine: 143 | dependency: transitive 144 | description: flutter 145 | source: sdk 146 | version: "0.0.99" 147 | source_span: 148 | dependency: transitive 149 | description: 150 | name: source_span 151 | sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" 152 | url: "https://pub.dev" 153 | source: hosted 154 | version: "1.10.0" 155 | stack_trace: 156 | dependency: transitive 157 | description: 158 | name: stack_trace 159 | sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" 160 | url: "https://pub.dev" 161 | source: hosted 162 | version: "1.11.1" 163 | stream_channel: 164 | dependency: transitive 165 | description: 166 | name: stream_channel 167 | sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 168 | url: "https://pub.dev" 169 | source: hosted 170 | version: "2.1.2" 171 | string_scanner: 172 | dependency: transitive 173 | description: 174 | name: string_scanner 175 | sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" 176 | url: "https://pub.dev" 177 | source: hosted 178 | version: "1.2.0" 179 | term_glyph: 180 | dependency: transitive 181 | description: 182 | name: term_glyph 183 | sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 184 | url: "https://pub.dev" 185 | source: hosted 186 | version: "1.2.1" 187 | test_api: 188 | dependency: transitive 189 | description: 190 | name: test_api 191 | sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" 192 | url: "https://pub.dev" 193 | source: hosted 194 | version: "0.6.1" 195 | vector_math: 196 | dependency: transitive 197 | description: 198 | name: vector_math 199 | sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" 200 | url: "https://pub.dev" 201 | source: hosted 202 | version: "2.1.4" 203 | vm_service: 204 | dependency: transitive 205 | description: 206 | name: vm_service 207 | sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 208 | url: "https://pub.dev" 209 | source: hosted 210 | version: "13.0.0" 211 | sdks: 212 | dart: ">=3.2.0-0 <4.0.0" 213 | flutter: ">=3.0.0" 214 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: stack_board 2 | description: A Flutter package of stack board, components that can be stacked and edited for any widget. 3 | version: 0.2.6+1 4 | homepage: https://github.com/fluttercandies/stack_board 5 | 6 | environment: 7 | sdk: ">=2.16.2 <4.0.0" 8 | flutter: ">=1.17.0" 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | 14 | meta: ^1.11.0 15 | flutter_drawing_board: ^0.7.0+2 16 | 17 | dev_dependencies: 18 | flutter_test: 19 | sdk: flutter 20 | flutter_lints: ^1.0.0 21 | 22 | # For information on the generic Dart part of this file, see the 23 | # following page: https://dart.dev/tools/pub/pubspec 24 | 25 | # The following section is specific to Flutter. 26 | flutter: 27 | 28 | # To add assets to your package, add an assets section, like this: 29 | # assets: 30 | # - images/a_dot_burr.jpeg 31 | # - images/a_dot_ham.jpeg 32 | # 33 | # For details regarding assets in packages, see 34 | # https://flutter.dev/assets-and-images/#from-packages 35 | # 36 | # An image asset can refer to one or more resolution-specific "variants", see 37 | # https://flutter.dev/assets-and-images/#resolution-aware. 38 | 39 | # To add custom fonts to your package, add a fonts section here, 40 | # in this "flutter" section. Each entry in this list should have a 41 | # "family" key with the font family name, and a "fonts" key with a 42 | # list giving the asset and other descriptors for the font. For 43 | # example: 44 | # fonts: 45 | # - family: Schyler 46 | # fonts: 47 | # - asset: fonts/Schyler-Regular.ttf 48 | # - asset: fonts/Schyler-Italic.ttf 49 | # style: italic 50 | # - family: Trajan Pro 51 | # fonts: 52 | # - asset: fonts/TrajanPro.ttf 53 | # - asset: fonts/TrajanPro_Bold.ttf 54 | # weight: 700 55 | # 56 | # For details regarding fonts in packages, see 57 | # https://flutter.dev/custom-fonts/#from-packages 58 | -------------------------------------------------------------------------------- /test/stack_board_items/items/stack_draw_item.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_drawing_board/paint_contents.dart'; 3 | import 'package:flutter_test/flutter_test.dart'; 4 | import 'package:stack_board/stack_items.dart'; 5 | 6 | void main() { 7 | test('Stack Draw Item should save lockZorder to json', () { 8 | final StackDrawItem item = StackDrawItem( 9 | content: DrawItemContent(size: 100, paintContents: []), 10 | size: const Size(100, 100), 11 | lockZOrder: true); 12 | expect(item.toJson()['lockZOrder'], true); 13 | }); 14 | 15 | test('Stack Draw Item should restore lockZorder from json', () { 16 | final StackDrawItem item = StackDrawItem.fromJson(const { 17 | 'id': 'id', 18 | 'size': {'width': 100, 'height': 100}, 19 | 'content': {'size': 100.0, 'paintContents': []}, 20 | 'lockZOrder': true, 21 | 'offset': {'dx': 0, 'dy': 0}, 22 | 'status': 0, 23 | }); 24 | expect(item.lockZOrder, true); 25 | }); 26 | } 27 | -------------------------------------------------------------------------------- /test/stack_board_items/items/stack_image_item.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:stack_board/stack_items.dart'; 4 | 5 | void main() { 6 | test('Stack Image Item should save lockZorder to json', () { 7 | final StackImageItem item = StackImageItem( 8 | content: ImageItemContent(url: 'http://a.b.c'), 9 | size: const Size(100, 100), 10 | lockZOrder: true); 11 | expect(item.toJson()['lockZOrder'], true); 12 | }); 13 | 14 | test('Stack Image Item should restore lockZorder from json', () { 15 | final StackImageItem item = StackImageItem.fromJson(const { 16 | 'id': 'id', 17 | 'size': {'width': 100, 'height': 100}, 18 | 'content': {'url': 'http://a.b.c'}, 19 | 'lockZOrder': true, 20 | 'status': 0, 21 | }); 22 | expect(item.lockZOrder, true); 23 | }); 24 | } 25 | -------------------------------------------------------------------------------- /test/stack_board_items/items/stack_text_item.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:stack_board/stack_items.dart'; 4 | 5 | void main() { 6 | test('Stack Text Item should save lockZorder to json', () { 7 | final StackTextItem item = StackTextItem( 8 | content: TextItemContent(), 9 | size: const Size(100, 100), 10 | lockZOrder: true); 11 | expect(item.toJson()['lockZOrder'], true); 12 | }); 13 | 14 | test('Stack Text Item should restore lockZorder from json', () { 15 | final StackTextItem item = StackTextItem.fromJson(const { 16 | 'id': 'id', 17 | 'size': {'width': 100, 'height': 100}, 18 | 'content': {'text': 'text'}, 19 | 'lockZOrder': true, 20 | 'offset': {'dx': 0, 'dy': 0}, 21 | 'status': 0, 22 | }); 23 | expect(item.lockZOrder, true); 24 | }); 25 | } 26 | --------------------------------------------------------------------------------