├── .github └── workflows │ └── dart.yml ├── .gitignore ├── .metadata ├── CHANGELOG.md ├── LICENSE ├── README.md ├── example ├── .gitignore ├── .metadata ├── README.md ├── analysis_options.yaml ├── android │ ├── .gitignore │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── kotlin │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── example │ │ │ │ │ └── MainActivity.kt │ │ │ └── res │ │ │ │ ├── drawable-v21 │ │ │ │ └── launch_background.xml │ │ │ │ ├── drawable │ │ │ │ └── launch_background.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── values-night │ │ │ │ └── styles.xml │ │ │ │ └── values │ │ │ │ └── styles.xml │ │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── settings.gradle ├── assets │ ├── Agumon(Burst).png │ ├── Agumon(savers).jpeg │ ├── Agumon.jpeg │ ├── AncientGreymon.jpeg │ ├── GeoGreymon.jpeg │ ├── Goddramon.jpeg │ ├── Greymon.jpeg │ ├── MasterTyranomon.jpeg │ ├── MetalGreymon.jpeg │ ├── RizeGreymon.jpeg │ ├── ShineGreymon.jpeg │ ├── ShineGreymonBurstMode.jpeg │ ├── ShineGreymonRuinMode.jpeg │ ├── Skullgreymon.jpeg │ ├── Tyranomon.jpeg │ ├── VictoryGreymon.jpeg │ ├── WarGreymon.jpeg │ ├── botomon.jpeg │ └── koromon.jpeg ├── ios │ ├── .gitignore │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ └── Release.xcconfig │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ │ └── WorkspaceSettings.xcsettings │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ └── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ ├── Icon-App-20x20@1x.png │ │ │ ├── Icon-App-20x20@2x.png │ │ │ ├── Icon-App-20x20@3x.png │ │ │ ├── Icon-App-29x29@1x.png │ │ │ ├── Icon-App-29x29@2x.png │ │ │ ├── Icon-App-29x29@3x.png │ │ │ ├── Icon-App-40x40@1x.png │ │ │ ├── Icon-App-40x40@2x.png │ │ │ ├── Icon-App-40x40@3x.png │ │ │ ├── Icon-App-60x60@2x.png │ │ │ ├── Icon-App-60x60@3x.png │ │ │ ├── Icon-App-76x76@1x.png │ │ │ ├── Icon-App-76x76@2x.png │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ └── LaunchImage.imageset │ │ │ ├── Contents.json │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ └── README.md │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── Runner-Bridging-Header.h ├── lib │ ├── custom_edges.dart │ ├── digimon.dart │ ├── flowchart.dart │ ├── labels.dart │ └── 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 │ ├── 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 ├── 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 ├── image ├── cba.svg ├── custom.gif ├── dig.gif ├── flo.gif ├── leb.gif └── vertical.gif ├── lib ├── core │ ├── graph.dart │ ├── graph_basic.dart │ ├── graph_matrix.dart │ ├── matrix.dart │ ├── traverse_queue.dart │ └── typings.dart ├── graphite.dart ├── graphite_canvas.dart ├── graphite_cell.dart ├── graphite_edges_painter.dart ├── graphite_root.dart ├── graphite_typings.dart └── utils.dart ├── pubspec.lock ├── pubspec.yaml └── test └── graphite_test.dart /.github/workflows/dart.yml: -------------------------------------------------------------------------------- 1 | name: tests 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | name: install dependencies 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v3 15 | - uses: subosito/flutter-action@v2 16 | with: 17 | flutter-version: '3.0.5' 18 | channel: 'stable' 19 | - run: flutter pub get 20 | - run: flutter test 21 | -------------------------------------------------------------------------------- /.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/app.flx 64 | **/ios/Flutter/app.zip 65 | **/ios/Flutter/flutter_assets/ 66 | **/ios/Flutter/flutter_export_environment.sh 67 | **/ios/ServiceDefinitions.json 68 | **/ios/Runner/GeneratedPluginRegistrant.* 69 | 70 | # Exceptions to above rules. 71 | !**/ios/**/default.mode1v3 72 | !**/ios/**/default.mode2v3 73 | !**/ios/**/default.pbxuser 74 | !**/ios/**/default.perspectivev3 75 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 76 | -------------------------------------------------------------------------------- /.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: 0b8abb4724aa590dd0f429683339b1e045a1594d 8 | channel: stable 9 | 10 | project_type: package 11 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [0.1.0] - July 18, 2020. 2 | 3 | * Initial widget version. 4 | * Nodes and edge gesture events. 5 | * Ability provide graph building direction (horizontal or vertical). 6 | * Ability provide scrolling direction (horizontal, vertical, both or none). 7 | * Ability to provide custom builder to node widget. 8 | * Ability to provide custom paint builder to graph edges. 9 | * Ability to customize arrows. 10 | 11 | ## [0.1.1] - July 18, 2020. 12 | 13 | * Code style fixes. 14 | 15 | ## [0.2.0] - August 29, 2020. 16 | 17 | * Ability to scale & pan graph through Interactive Widget. 18 | * Removed ScrollDirection enum (replaced ScrollViews with Interactive Widget). 19 | * Added ability to customize path shape with pathBuilder param. 20 | 21 | ## [0.2.3] - December 16, 2020 22 | 23 | * Core lib bug fixes 24 | 25 | ## [0.3.0-alpha] - April 29, 2021 26 | 27 | * Initial null safety support 28 | 29 | ## [0.3.0-beta] - April 30, 2021 30 | 31 | * Fix edges shift bug as a result of grid view non-zero padding 32 | 33 | ## [0.3.0] - May 13, 2021 34 | 35 | * Use arrow_path v2.0, skip own fork 36 | 37 | ## [1.0.0] - December 11, 2022 38 | 39 | * Param `cellSize` changed to `defaultCellSize` with `Size` type. Now it's possible to create non-square nodes. [#16](https://github.com/lempiy/flutter_graphite/issues/16) 40 | * Each node input now has `size` param allowing `defaultCellSize` override for particular nodes. [#15](https://github.com/lempiy/flutter_graphite/issues/15) 41 | * Node gestures know also have rect (`Rect`) as param, with info about node's position on `Stack`. 42 | * Ability to set `centered` node outcomes to provide more pretty graph rendering for tree-like graphs. [#2](https://github.com/lempiy/flutter_graphite/issues/2) 43 | * Ability to add overlays with `overlayBuilder` param. 44 | * Ability to add edge text or `Widget` labels using `edgeLabels` param. [#13](https://github.com/lempiy/flutter_graphite/issues/13) 45 | * Ability to wrap `InteractiveViewer` content with custom widget using `contentWrapperBuilder`. 46 | * Ability to draw double-headed arrows on edges or without arrows on edges via `EdgeInput.type`. [#4](https://github.com/lempiy/flutter_graphite/issues/4) 47 | * Added `clipBehavior`, `transformationController` as new params. 48 | * Fixed bugs with non-firing edge gestures and increased edges hitbox to improve UX. [#10](https://github.com/lempiy/flutter_graphite/issues/10) [#14](https://github.com/lempiy/flutter_graphite/issues/14) 49 | * More examples. 50 | * Many fixes and improvements for more compact graph rendering. 51 | 52 | ## [1.1.0] - March 9, 2023 53 | 54 | * Removed internal `InteractiveViewer` dependency. Content boundaries, scrolls or `InteractiveViewer` usage are now on applications responsibility. [#20](https://github.com/lempiy/flutter_graphite/issues/20) 55 | * Removed `transformationController` since `InteractiveViewer` is no longer used. 56 | * Removed `contentWrapperBuilder` since `InteractiveViewer` is no longer used. 57 | * Changed `onCanvasTap` callback to provide tap details and trigger only if tapped out of other widgets and figures. 58 | 59 | ## [1.1.1] - April 27, 2023 60 | 61 | * Removed max iterations limitation for graph. 62 | 63 | ## [1.1.2] - May 12, 2023 64 | 65 | * Fixed complexity bug with node relations detection. 66 | 67 | ## [1.2.0] - Jun 25, 2024 68 | 69 | * Added new `EdgeStyle` param with options for edges customization, like border-radius and like style. 70 | * Changed `PaintBuilder` to `EdgeStyleBuilder`, paint selection is now a part of `EdgeStyleBuilder`. 71 | * Changed `PathBuilder` to accept `EdgeStyle style` param as an argument. 72 | * Edges gestures hit-box rework. 73 | 74 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Anton Lempiy 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Graphite 2 | 3 | [![Actions Status](https://github.com/lempiy/flutter_graphite/workflows/tests/badge.svg)](https://github.com/lempiy/flutter_graphite/actions) 4 | [![](https://img.shields.io/pub/v/graphite)](https://pub.dev/packages/graphite) 5 | [![](https://img.shields.io/badge/package-flutter-blue)](https://github.com/lempiy/flutter_graphite) 6 | [![](https://img.shields.io/github/license/lempiy/flutter_graphite)](https://github.com/lempiy/flutter_graphite) 7 | [![](https://img.shields.io/github/stars/lempiy/flutter_graphite)](https://github.com/lempiy/flutter_graphite) 8 | [![](https://img.shields.io/github/languages/code-size/lempiy/flutter_graphite)](https://github.com/lempiy/flutter_graphite) 9 | 10 | 11 | :arrow_right: :black_square_button: Flutter widget to draw direct graphs, trees, flowcharts in rectanglar manner. 12 | 13 | #### Support the author :yellow_heart: :blue_heart: 14 | 15 | 16 | [![](./image/cba.svg)](https://savelife.in.ua/en/donate-en/#donate-army-card-once) 17 | 18 | 19 | The only reason why the latest release of Graphite become possible is because of __Armed Forces Of Ukraine__. 20 | Ukrainian defenders are those who saved the author's life last spring and currently continue fighting 21 | with absolute evil in my country. If you liked this lib and want to support future releases I would 22 | be grateful for your donations to [Come Back Alive](https://savelife.in.ua/en/donate-en/#donate-army-card-once) Charity which directly supports UA Army with equipment. 23 | 24 | Thank you. 25 | 26 | 27 | ![vertical](./image/vertical.gif) ![custom](./image/custom.gif) 28 | 29 | 30 | ![flowchart](./image/flo.gif) 31 | 32 | 33 | ![label](./image/leb.gif) 34 | 35 | 36 | ![digimon](./image/dig.gif) 37 | 38 | 39 | 40 | ## Example of usage: 41 | ```dart 42 | import 'package:flutter/material.dart'; 43 | import 'package:graphite/graphite.dart'; 44 | 45 | void main() => runApp(MyApp()); 46 | const list = '[' 47 | '{"id":"A","next":[{"outcome":"B"}]},' 48 | '{"id":"B","next":[{"outcome":"C"},{"outcome":"D"},{"outcome":"E"}]},' 49 | '{"id":"C","next":[{"outcome":"F"}]},' 50 | '{"id":"D","next":[{"outcome":"J"}]},{"id":"E","next":[{"outcome":"J"}]},' 51 | '{"id":"J","next":[{"outcome":"I"}]},' 52 | '{"id":"I","next":[{"outcome":"H"}]},{"id":"F","next":[{"outcome":"K"}]},' 53 | '{"id":"K","next":[{"outcome":"L"}]},' 54 | '{"id":"H","next":[{"outcome":"L"}]},{"id":"L","next":[{"outcome":"P"}]},' 55 | '{"id":"P","next":[{"outcome":"M"},{"outcome":"N"}]},' 56 | '{"id":"M","next":[]},{"id":"N","next":[]}' 57 | ']'; 58 | 59 | class MyApp extends StatelessWidget { 60 | @override 61 | Widget build(BuildContext context) { 62 | return MaterialApp( 63 | title: 'Flutter Graphite', 64 | theme: ThemeData( 65 | primarySwatch: Colors.teal, 66 | ), 67 | home: MyHomePage(), 68 | ); 69 | } 70 | } 71 | 72 | class MyHomePage extends StatefulWidget { 73 | MyHomePage({Key key}) : super(key: key); 74 | @override 75 | _MyHomePageState createState() => _MyHomePageState(); 76 | } 77 | 78 | class _MyHomePageState extends State { 79 | @override 80 | Widget build(BuildContext context) { 81 | return Scaffold( 82 | body: InteractiveViewer( 83 | constrained: false, 84 | child: DirectGraph( 85 | list: nodeInputFromJson(list), 86 | defaultCellSize: const Size(100.0, 100.0), 87 | cellPadding: const EdgeInsets.all(20), 88 | orientation: MatrixOrientation.Vertical, 89 | ), 90 | ) 91 | ); 92 | } 93 | } 94 | ``` 95 | 96 | ## Features 97 | * Nodes and edge gesture events. 98 | * Ability provide graph building direction (horizontal or vertical). 99 | * Ability to provide custom builder to node widget. 100 | * Ability to add overlays. 101 | * Ability to add edge text or `Widget` labels. 102 | * Ability to provide custom paint builder to graph edges. 103 | * Ability to customize arrows and lines. 104 | 105 | 106 | ## License 107 | 108 | MIT © [lempiy](https://github.com/lempiy) 109 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | **/doc/api/ 26 | **/ios/Flutter/.last_build_id 27 | .dart_tool/ 28 | .flutter-plugins 29 | .flutter-plugins-dependencies 30 | .packages 31 | .pub-cache/ 32 | .pub/ 33 | /build/ 34 | 35 | # Symbolication related 36 | app.*.symbols 37 | 38 | # Obfuscation related 39 | app.*.map.json 40 | 41 | # Android Studio will place build artifacts here 42 | /android/app/debug 43 | /android/app/profile 44 | /android/app/release 45 | -------------------------------------------------------------------------------- /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. 5 | 6 | version: 7 | revision: e99c9c7cd9f6c0b2f8ae6e3ebfd585239f5568f4 8 | channel: stable 9 | 10 | project_type: app 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: e99c9c7cd9f6c0b2f8ae6e3ebfd585239f5568f4 17 | base_revision: e99c9c7cd9f6c0b2f8ae6e3ebfd585239f5568f4 18 | - platform: android 19 | create_revision: e99c9c7cd9f6c0b2f8ae6e3ebfd585239f5568f4 20 | base_revision: e99c9c7cd9f6c0b2f8ae6e3ebfd585239f5568f4 21 | - platform: ios 22 | create_revision: e99c9c7cd9f6c0b2f8ae6e3ebfd585239f5568f4 23 | base_revision: e99c9c7cd9f6c0b2f8ae6e3ebfd585239f5568f4 24 | - platform: linux 25 | create_revision: e99c9c7cd9f6c0b2f8ae6e3ebfd585239f5568f4 26 | base_revision: e99c9c7cd9f6c0b2f8ae6e3ebfd585239f5568f4 27 | - platform: macos 28 | create_revision: e99c9c7cd9f6c0b2f8ae6e3ebfd585239f5568f4 29 | base_revision: e99c9c7cd9f6c0b2f8ae6e3ebfd585239f5568f4 30 | - platform: web 31 | create_revision: e99c9c7cd9f6c0b2f8ae6e3ebfd585239f5568f4 32 | base_revision: e99c9c7cd9f6c0b2f8ae6e3ebfd585239f5568f4 33 | - platform: windows 34 | create_revision: e99c9c7cd9f6c0b2f8ae6e3ebfd585239f5568f4 35 | base_revision: e99c9c7cd9f6c0b2f8ae6e3ebfd585239f5568f4 36 | 37 | # User provided section 38 | 39 | # List of Local paths (relative to this file) that should be 40 | # ignored by the migrate tool. 41 | # 42 | # Files that are not part of the templates will be ignored by default. 43 | unmanaged_files: 44 | - 'lib/main.dart' 45 | - 'ios/Runner.xcodeproj/project.pbxproj' 46 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # example 2 | 3 | A new Flutter project. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) 13 | 14 | For help getting started with Flutter development, view the 15 | [online documentation](https://docs.flutter.dev/), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /example/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at 17 | # https://dart-lang.github.io/linter/lints/index.html. 18 | # 19 | # Instead of disabling a lint rule for the entire project in the 20 | # section below, it can also be suppressed for a single line of code 21 | # or a specific dart file by using the `// ignore: name_of_lint` and 22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 23 | # producing the lint. 24 | rules: 25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 27 | 28 | # Additional information about this file can be found at 29 | # https://dart.dev/guides/language/analysis-options 30 | -------------------------------------------------------------------------------- /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 flutter.compileSdkVersion 30 | ndkVersion flutter.ndkVersion 31 | 32 | compileOptions { 33 | sourceCompatibility JavaVersion.VERSION_1_8 34 | targetCompatibility JavaVersion.VERSION_1_8 35 | } 36 | 37 | kotlinOptions { 38 | jvmTarget = '1.8' 39 | } 40 | 41 | sourceSets { 42 | main.java.srcDirs += 'src/main/kotlin' 43 | } 44 | 45 | defaultConfig { 46 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 47 | applicationId "com.example.example" 48 | // You can update the following values to match your application needs. 49 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. 50 | minSdkVersion flutter.minSdkVersion 51 | targetSdkVersion flutter.targetSdkVersion 52 | versionCode flutterVersionCode.toInteger() 53 | versionName flutterVersionName 54 | } 55 | 56 | buildTypes { 57 | release { 58 | // TODO: Add your own signing config for the release build. 59 | // Signing with the debug keys for now, so `flutter run --release` works. 60 | signingConfig signingConfigs.debug 61 | } 62 | } 63 | } 64 | 65 | flutter { 66 | source '../..' 67 | } 68 | 69 | dependencies { 70 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 71 | } 72 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 15 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /example/android/app/src/main/kotlin/com/example/example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.example 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /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/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/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/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/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/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/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/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/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/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/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 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.6.10' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.1.2' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | mavenCentral() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | task clean(type: Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /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 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip 6 | -------------------------------------------------------------------------------- /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/assets/Agumon(Burst).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/example/assets/Agumon(Burst).png -------------------------------------------------------------------------------- /example/assets/Agumon(savers).jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/example/assets/Agumon(savers).jpeg -------------------------------------------------------------------------------- /example/assets/Agumon.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/example/assets/Agumon.jpeg -------------------------------------------------------------------------------- /example/assets/AncientGreymon.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/example/assets/AncientGreymon.jpeg -------------------------------------------------------------------------------- /example/assets/GeoGreymon.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/example/assets/GeoGreymon.jpeg -------------------------------------------------------------------------------- /example/assets/Goddramon.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/example/assets/Goddramon.jpeg -------------------------------------------------------------------------------- /example/assets/Greymon.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/example/assets/Greymon.jpeg -------------------------------------------------------------------------------- /example/assets/MasterTyranomon.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/example/assets/MasterTyranomon.jpeg -------------------------------------------------------------------------------- /example/assets/MetalGreymon.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/example/assets/MetalGreymon.jpeg -------------------------------------------------------------------------------- /example/assets/RizeGreymon.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/example/assets/RizeGreymon.jpeg -------------------------------------------------------------------------------- /example/assets/ShineGreymon.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/example/assets/ShineGreymon.jpeg -------------------------------------------------------------------------------- /example/assets/ShineGreymonBurstMode.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/example/assets/ShineGreymonBurstMode.jpeg -------------------------------------------------------------------------------- /example/assets/ShineGreymonRuinMode.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/example/assets/ShineGreymonRuinMode.jpeg -------------------------------------------------------------------------------- /example/assets/Skullgreymon.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/example/assets/Skullgreymon.jpeg -------------------------------------------------------------------------------- /example/assets/Tyranomon.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/example/assets/Tyranomon.jpeg -------------------------------------------------------------------------------- /example/assets/VictoryGreymon.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/example/assets/VictoryGreymon.jpeg -------------------------------------------------------------------------------- /example/assets/WarGreymon.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/example/assets/WarGreymon.jpeg -------------------------------------------------------------------------------- /example/assets/botomon.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/example/assets/botomon.jpeg -------------------------------------------------------------------------------- /example/assets/koromon.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/example/assets/koromon.jpeg -------------------------------------------------------------------------------- /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 | 11.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /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 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /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/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/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/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/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/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/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/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/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/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/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/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/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/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/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/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/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/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/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/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/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/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/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/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/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/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/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/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/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/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/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/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/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 | CFBundleDisplayName 8 | Example 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | example 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UIViewControllerBasedStatusBarAppearance 45 | 46 | CADisableMinimumFrameDurationOnPhone 47 | 48 | UIApplicationSupportsIndirectInputEvents 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /example/lib/custom_edges.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:graphite/graphite.dart'; 3 | 4 | const presetComplex = '[' 5 | '{"id":"A","next":[{"outcome":"B","type":"one"}]},' 6 | '{"id":"U","next":[{"outcome":"G","type":"one"}]},' 7 | '{"id":"B","next":[{"outcome":"C","type":"one"},{"outcome":"D","type":"one"},{"outcome":"E","type":"one"},{"outcome":"F","type":"one"},{"outcome":"M","type":"one"}]},' 8 | '{"id":"C","next":[{"outcome":"G","type":"one"}]},' 9 | '{"id":"D","next":[{"outcome":"H","type":"one"}]},' 10 | '{"id":"E","next":[{"outcome":"H","type":"one"}]},' 11 | '{"id":"F","next":[{"outcome":"W","type":"one"},{"outcome":"N","type":"one"},{"outcome":"O","type":"one"}]},' 12 | '{"id":"W","next":[]},' 13 | '{"id":"N","next":[{"outcome":"I","type":"one"}]},' 14 | '{"id":"O","next":[{"outcome":"P","type":"one"}]},' 15 | '{"id":"P","next":[{"outcome":"I","type":"one"}]},' 16 | '{"id":"M","next":[{"outcome":"L","type":"one"}]},' 17 | '{"id":"G","next":[{"outcome":"I","type":"one"}]},' 18 | '{"id":"H","next":[{"outcome":"J","type":"one"}]},' 19 | '{"id":"I","next":[]},' 20 | '{"id":"J","next":[{"outcome":"K","type":"one"}]},' 21 | '{"id":"K","next":[{"outcome":"L","type":"one"}]},' 22 | '{"id":"L","next":[]}' 23 | ']'; 24 | 25 | class CustomEdgesPage extends StatefulWidget { 26 | final Widget Function(BuildContext context) bottomBar; 27 | 28 | const CustomEdgesPage({Key? key, required this.bottomBar}) : super(key: key); 29 | @override 30 | CustomEdgesPageState createState() { 31 | return CustomEdgesPageState(); 32 | } 33 | } 34 | 35 | class CustomEdgesPageState extends State { 36 | List list = nodeInputFromJson(presetComplex); 37 | Map selected = {}; 38 | void _onItemSelected(String nodeId) { 39 | setState(() { 40 | selected[nodeId] = 41 | selected[nodeId] == null || !selected[nodeId]! ? true : false; 42 | }); 43 | } 44 | 45 | @override 46 | Widget build(BuildContext context) { 47 | return Scaffold( 48 | backgroundColor: Colors.grey[200], 49 | appBar: AppBar( 50 | leading: const Icon(Icons.view_comfy), 51 | title: const Text('Custom Edges Example')), 52 | body: InteractiveViewer( 53 | constrained: false, 54 | child: DirectGraph( 55 | list: list, 56 | defaultCellSize: const Size(104.0, 104.0), 57 | cellPadding: const EdgeInsets.all(14), 58 | contactEdgesDistance: 5.0, 59 | orientation: MatrixOrientation.Vertical, 60 | centered: false, 61 | onEdgeTapDown: (details, edge) { 62 | print("${edge.from.id}->${edge.to.id}"); 63 | }, 64 | nodeBuilder: (ctx, node) { 65 | return Card( 66 | child: Center( 67 | child: Text( 68 | node.id, 69 | style: selected[node.id] ?? false 70 | ? const TextStyle( 71 | fontSize: 20.0, 72 | fontWeight: FontWeight.bold, 73 | color: Colors.red) 74 | : const TextStyle(fontSize: 20.0), 75 | ), 76 | ), 77 | ); 78 | }, 79 | styleBuilder: (edge) { 80 | var p = Paint() 81 | ..color = Colors.blueGrey 82 | ..style = PaintingStyle.stroke 83 | ..strokeCap = StrokeCap.round 84 | ..strokeJoin = StrokeJoin.round 85 | ..strokeWidth = 2; 86 | LineStyle lineStyle = LineStyle.solid; 87 | switch (edge.from.id) { 88 | case "U": 89 | lineStyle = LineStyle.dotted; 90 | break; 91 | case "C": 92 | lineStyle = LineStyle.dashed; 93 | break; 94 | case "M": 95 | lineStyle = LineStyle.dashDotted; 96 | break; 97 | } 98 | if ((selected[edge.from.id] ?? false) && 99 | (selected[edge.to.id] ?? false)) { 100 | p.color = Colors.red; 101 | } 102 | return EdgeStyle( 103 | lineStyle: lineStyle, borderRadius: 40, linePaint: p); 104 | }, 105 | onNodeTapDown: (_, node, __) { 106 | _onItemSelected(node.id); 107 | }, 108 | ), 109 | ), 110 | bottomNavigationBar: widget.bottomBar(context), 111 | ); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /example/lib/flowchart.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:graphite/graphite.dart'; 3 | import 'dart:math'; 4 | 5 | List flowChart = [ 6 | NodeInput(id: "start", next: [EdgeInput(outcome: "process")]), 7 | NodeInput(id: "documents", next: [EdgeInput(outcome: "process")]), 8 | NodeInput(id: "process", next: [EdgeInput(outcome: "decision")]), 9 | NodeInput( 10 | id: "decision", 11 | size: const NodeSize(width: 100, height: 100), 12 | next: [EdgeInput(outcome: "processA"), EdgeInput(outcome: "processB")]), 13 | NodeInput(id: "processA", next: [EdgeInput(outcome: "end")]), 14 | NodeInput(id: "processB", next: [EdgeInput(outcome: "end")]), 15 | NodeInput(id: "end", next: []), 16 | ]; 17 | 18 | enum FlowStepType { start, documents, decision, process, end } 19 | 20 | class FlowStep { 21 | final String text; 22 | final FlowStepType type; 23 | 24 | FlowStep({required this.text, required this.type}); 25 | } 26 | 27 | Map data = { 28 | "start": FlowStep(text: "Start", type: FlowStepType.start), 29 | "documents": FlowStep(text: "Documents", type: FlowStepType.documents), 30 | "process": FlowStep(text: "Process", type: FlowStepType.process), 31 | "decision": FlowStep(text: "Decision", type: FlowStepType.decision), 32 | "processA": FlowStep(text: "Process A", type: FlowStepType.process), 33 | "processB": FlowStep(text: "Process B", type: FlowStepType.process), 34 | "end": FlowStep(text: "End", type: FlowStepType.end), 35 | }; 36 | 37 | class FlowchartPage extends StatefulWidget { 38 | final Widget Function(BuildContext context) bottomBar; 39 | 40 | const FlowchartPage({Key? key, required this.bottomBar}) : super(key: key); 41 | @override 42 | FlowchartPageState createState() => FlowchartPageState(); 43 | } 44 | 45 | class FlowchartPageState extends State { 46 | _buildNode(NodeInput node) { 47 | final info = data[node.id]!; 48 | switch (info.type) { 49 | case FlowStepType.start: 50 | return Start(data: info); 51 | case FlowStepType.documents: 52 | return Document(data: info); 53 | case FlowStepType.decision: 54 | return Decision(data: info); 55 | case FlowStepType.process: 56 | return Process(data: info); 57 | case FlowStepType.end: 58 | return End(data: info); 59 | } 60 | } 61 | 62 | @override 63 | Widget build(BuildContext context) { 64 | final list = flowChart; 65 | final screenSize = MediaQuery.of(context).size; 66 | return Scaffold( 67 | appBar: AppBar( 68 | leading: const Icon(Icons.view_module), 69 | title: const Text('Flowchart Example')), 70 | body: InteractiveViewer( 71 | minScale: 0.5, 72 | maxScale: 3, 73 | constrained: false, 74 | child: ConstrainedBox( 75 | constraints: BoxConstraints(minWidth: screenSize.width), 76 | child: Center( 77 | child: DirectGraph( 78 | list: list, 79 | defaultCellSize: const Size(250.0, 100.0), 80 | cellPadding: 81 | const EdgeInsets.symmetric(vertical: 30, horizontal: 5), 82 | contactEdgesDistance: 0, 83 | orientation: MatrixOrientation.Vertical, 84 | nodeBuilder: (BuildContext context, NodeInput node) => Padding( 85 | padding: const EdgeInsets.all(5), child: _buildNode(node)), 86 | centered: true, 87 | minScale: .1, 88 | maxScale: 1, 89 | ), 90 | ), 91 | ), 92 | ), 93 | bottomNavigationBar: widget.bottomBar(context), 94 | ); 95 | } 96 | } 97 | 98 | class Start extends StatelessWidget { 99 | final FlowStep data; 100 | 101 | const Start({super.key, required this.data}); 102 | 103 | @override 104 | Widget build(BuildContext context) { 105 | return Container( 106 | width: double.infinity, 107 | height: double.infinity, 108 | decoration: BoxDecoration( 109 | border: Border.all(width: 3, color: Colors.green), 110 | borderRadius: const BorderRadius.all(Radius.circular(50)), 111 | color: Colors.greenAccent, 112 | ), 113 | child: Center( 114 | child: Text( 115 | data.text, 116 | style: Theme.of(context).textTheme.titleMedium, 117 | ), 118 | ), 119 | ); 120 | } 121 | } 122 | 123 | class Document extends StatelessWidget { 124 | final FlowStep data; 125 | 126 | const Document({super.key, required this.data}); 127 | 128 | @override 129 | Widget build(BuildContext context) { 130 | return Container( 131 | width: double.infinity, 132 | height: double.infinity, 133 | decoration: BoxDecoration( 134 | border: Border.all(width: 3), 135 | borderRadius: const BorderRadius.all(Radius.circular(20)), 136 | color: Colors.grey, 137 | ), 138 | child: Center( 139 | child: Text( 140 | data.text, 141 | style: Theme.of(context).textTheme.titleMedium, 142 | ), 143 | ), 144 | ); 145 | } 146 | } 147 | 148 | class Process extends StatelessWidget { 149 | final FlowStep data; 150 | 151 | const Process({super.key, required this.data}); 152 | 153 | @override 154 | Widget build(BuildContext context) { 155 | return Container( 156 | width: double.infinity, 157 | height: double.infinity, 158 | decoration: BoxDecoration( 159 | border: Border.all(width: 3, color: Colors.orange), 160 | borderRadius: const BorderRadius.all(Radius.circular(20)), 161 | color: Colors.orangeAccent, 162 | ), 163 | child: Center( 164 | child: Text( 165 | data.text, 166 | style: Theme.of(context).textTheme.titleMedium, 167 | ), 168 | ), 169 | ); 170 | } 171 | } 172 | 173 | class Decision extends StatelessWidget { 174 | final FlowStep data; 175 | 176 | const Decision({super.key, required this.data}); 177 | 178 | @override 179 | Widget build(BuildContext context) { 180 | return Stack( 181 | children: [ 182 | Transform.rotate( 183 | angle: pi / 4, 184 | child: Container( 185 | width: double.infinity, 186 | height: double.infinity, 187 | decoration: BoxDecoration( 188 | border: Border.all( 189 | width: 3, 190 | color: Colors.deepOrangeAccent, 191 | ), 192 | borderRadius: const BorderRadius.all(Radius.circular(5)), 193 | color: Colors.orangeAccent, 194 | ), 195 | ), 196 | ), 197 | SizedBox( 198 | child: Center( 199 | child: Text( 200 | data.text, 201 | style: Theme.of(context).textTheme.titleMedium, 202 | ), 203 | ), 204 | ) 205 | ], 206 | ); 207 | } 208 | } 209 | 210 | class End extends StatelessWidget { 211 | final FlowStep data; 212 | 213 | const End({super.key, required this.data}); 214 | 215 | @override 216 | Widget build(BuildContext context) { 217 | return Container( 218 | width: double.infinity, 219 | height: double.infinity, 220 | decoration: BoxDecoration( 221 | border: Border.all(width: 3, color: Colors.red), 222 | borderRadius: const BorderRadius.all(Radius.circular(50)), 223 | color: Colors.redAccent, 224 | ), 225 | child: Center( 226 | child: Text( 227 | data.text, 228 | style: Theme.of(context).textTheme.titleMedium, 229 | ), 230 | ), 231 | ); 232 | } 233 | } 234 | -------------------------------------------------------------------------------- /example/lib/labels.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:graphite/graphite.dart'; 3 | 4 | const presetBasic = '[' 5 | '{"id":"A","next":[{"outcome":"B","type":"one"}],"size":{"width": 75.0, "height": 75.0}},' 6 | '{"id":"B","size":{"width": 200.0, "height": 50.0},"next":[{"outcome":"D","type":"one"},{"outcome":"C","type":"one"},{"outcome":"K","type":"one"},{"outcome":"E","type":"one"}]},' 7 | '{"id":"C","next":[{"outcome":"F","type":"one"},{"outcome":"A","type":"one"}]},' 8 | '{"id":"D","next":[{"outcome":"J","type":"one"}],"size":{"width": 25.0, "height": 175.0}},' 9 | '{"id":"E","next":[{"outcome":"J","type":"one"}]},' 10 | '{"id":"J","size": {"width": 75.0, "height": 75.0},"next":[{"outcome":"I","type":"one"},{"outcome":"@","type":"one"}]},' 11 | '{"id":"I","next":[{"outcome":"H","type":"one"}]},' 12 | '{"id":"F","next":[{"outcome":"K","type":"one"}]},' 13 | '{"id":"K","size":{"width":50.0,"height":50.0},"next":[{"outcome":"L","type":"one"},{"outcome":"C","type":"one"},{"outcome":"X","type":"one"}]},' 14 | '{"id":"H","next":[{"outcome":"L","type":"one"}]},' 15 | '{"id":"L","next":[{"outcome":"I","type":"one"},{"outcome":"P","type":"one"}]},' 16 | '{"id":"P","next":[{"outcome":"M","type":"one"},{"outcome":"N","type":"one"}]},' 17 | '{"id":"M","next":[]},' 18 | '{"id":"X","next":[]},' 19 | '{"id":"N","next":[]},' 20 | '{"id":"@","next":[]}' 21 | ']'; 22 | 23 | class LabelsPage extends StatefulWidget { 24 | final Widget Function(BuildContext context) bottomBar; 25 | 26 | const LabelsPage({Key? key, required this.bottomBar}) : super(key: key); 27 | @override 28 | LabelsPageState createState() => LabelsPageState(); 29 | } 30 | 31 | class LabelsPageState extends State { 32 | bool _isVertical = false; 33 | bool _isCentered = true; 34 | 35 | @override 36 | Widget build(BuildContext context) { 37 | var list = nodeInputFromJson(presetBasic); 38 | return Scaffold( 39 | appBar: AppBar( 40 | leading: const Icon(Icons.view_module), 41 | title: const Text('Edge Labels Example')), 42 | body: Stack( 43 | children: [ 44 | InteractiveViewer( 45 | constrained: false, 46 | child: DirectGraph( 47 | list: list, 48 | defaultCellSize: const Size(100.0, 100.0), 49 | cellPadding: _isVertical 50 | ? const EdgeInsets.symmetric(vertical: 30, horizontal: 5) 51 | : const EdgeInsets.symmetric(vertical: 5, horizontal: 30), 52 | contactEdgesDistance: 10.0, 53 | orientation: _isVertical 54 | ? MatrixOrientation.Vertical 55 | : MatrixOrientation.Horizontal, 56 | edgeLabels: EdgeLabels( 57 | alignment: EdgeLabelTextAlignment.before, 58 | positionPriority: EdgeLabelPositionPriority.horizontal, 59 | builder: (context, edge, isVertical) => Padding( 60 | padding: const EdgeInsets.all(2), 61 | child: isVertical 62 | ? RotatedBox( 63 | quarterTurns: -1, 64 | child: Text( 65 | style: Theme.of(context) 66 | .textTheme 67 | .bodyMedium! 68 | .copyWith( 69 | backgroundColor: Theme.of(context) 70 | .colorScheme 71 | .surface), 72 | "${edge.from.id}=>${edge.to.id}")) 73 | : Text( 74 | style: Theme.of(context) 75 | .textTheme 76 | .bodyMedium! 77 | .copyWith( 78 | backgroundColor: Theme.of(context) 79 | .colorScheme 80 | .surface), 81 | "${edge.from.id}=>${edge.to.id}"), 82 | )), 83 | centered: _isCentered, 84 | minScale: .1, 85 | maxScale: 1, 86 | ), 87 | ), 88 | Positioned( 89 | left: 0, 90 | top: 0, 91 | child: Row( 92 | children: [ 93 | const Icon(Icons.keyboard_arrow_right), 94 | Tooltip( 95 | message: "Matrix alignment", 96 | child: Switch( 97 | value: _isVertical, 98 | onChanged: (value) { 99 | setState(() { 100 | _isVertical = value; 101 | }); 102 | }), 103 | ), 104 | const Icon(Icons.keyboard_arrow_down), 105 | ], 106 | ), 107 | ), 108 | Positioned( 109 | right: 0, 110 | top: 0, 111 | child: Row( 112 | children: [ 113 | const Icon(Icons.format_align_left), 114 | Tooltip( 115 | message: "Centered outcomes", 116 | child: Switch( 117 | value: _isCentered, 118 | onChanged: (value) { 119 | setState(() { 120 | _isCentered = value; 121 | }); 122 | }), 123 | ), 124 | const Icon(Icons.format_align_center), 125 | ], 126 | ), 127 | ) 128 | ], 129 | ), 130 | bottomNavigationBar: widget.bottomBar(context), 131 | ); 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/flowchart.dart'; 2 | import 'package:example/labels.dart'; 3 | import 'package:example/custom_edges.dart'; 4 | import 'package:example/digimon.dart'; 5 | import 'package:flutter/material.dart'; 6 | 7 | void main() => runApp(const MyApp()); 8 | 9 | class MyApp extends StatefulWidget { 10 | const MyApp({super.key}); 11 | 12 | @override 13 | State createState() => _MyAppState(); 14 | } 15 | 16 | class _MyAppState extends State { 17 | int _selectedIndex = 0; 18 | 19 | void _onChangePage(BuildContext context, int index) { 20 | setState(() { 21 | _selectedIndex = index; 22 | Navigator.push( 23 | context, 24 | PageRouteBuilder( 25 | transitionDuration: const Duration(seconds: 1), 26 | pageBuilder: (_, __, ___) => [ 27 | FlowchartPage(bottomBar: _buildBottomBar), 28 | LabelsPage(bottomBar: _buildBottomBar), 29 | DigimonPage(bottomBar: _buildBottomBar), 30 | CustomEdgesPage(bottomBar: _buildBottomBar) 31 | ][index])); 32 | }); 33 | } 34 | 35 | Widget _buildBottomBar(BuildContext context) { 36 | return BottomNavigationBar( 37 | items: [ 38 | BottomNavigationBarItem( 39 | icon: 40 | Icon(Icons.account_tree, color: Theme.of(context).disabledColor), 41 | activeIcon: 42 | Icon(Icons.account_tree, color: Theme.of(context).primaryColor), 43 | label: 'Flowchart', 44 | ), 45 | BottomNavigationBarItem( 46 | icon: Icon(Icons.text_format_outlined, 47 | color: Theme.of(context).disabledColor), 48 | activeIcon: Icon(Icons.text_format_outlined, 49 | color: Theme.of(context).primaryColor), 50 | label: 'Labels', 51 | ), 52 | BottomNavigationBarItem( 53 | icon: Icon(Icons.layers, color: Theme.of(context).disabledColor), 54 | activeIcon: Icon(Icons.layers, color: Theme.of(context).primaryColor), 55 | label: 'Overlays', 56 | ), 57 | BottomNavigationBarItem( 58 | icon: Icon(Icons.stacked_line_chart, 59 | color: Theme.of(context).disabledColor), 60 | activeIcon: Icon(Icons.stacked_line_chart, 61 | color: Theme.of(context).primaryColor), 62 | label: 'Edges', 63 | ), 64 | ], 65 | currentIndex: _selectedIndex, 66 | selectedItemColor: Colors.teal[800], 67 | onTap: (index) => _onChangePage(context, index), 68 | ); 69 | } 70 | 71 | // This widget is the root of your application. 72 | @override 73 | Widget build(BuildContext context) { 74 | return MaterialApp( 75 | title: 'Flutter Graphite', 76 | theme: ThemeData( 77 | colorScheme: ColorScheme.fromSwatch( 78 | primarySwatch: Colors.teal, backgroundColor: Colors.white) 79 | .copyWith(surface: Colors.white), 80 | ), 81 | home: FlowchartPage(bottomBar: _buildBottomBar), 82 | routes: { 83 | '/flowchart': (BuildContext context) => 84 | FlowchartPage(bottomBar: _buildBottomBar), 85 | '/labels': (BuildContext context) => 86 | LabelsPage(bottomBar: _buildBottomBar), 87 | '/digimon': (BuildContext context) => 88 | DigimonPage(bottomBar: _buildBottomBar), 89 | '/complex': (BuildContext context) => 90 | CustomEdgesPage(bottomBar: _buildBottomBar), 91 | }, 92 | ); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /example/linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /example/linux/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.10) 3 | project(runner LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "example") 8 | # The unique GTK application identifier for this application. See: 9 | # https://wiki.gnome.org/HowDoI/ChooseApplicationID 10 | set(APPLICATION_ID "com.example.example") 11 | 12 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 13 | # versions of CMake. 14 | cmake_policy(SET CMP0063 NEW) 15 | 16 | # Load bundled libraries from the lib/ directory relative to the binary. 17 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 18 | 19 | # Root filesystem for cross-building. 20 | if(FLUTTER_TARGET_PLATFORM_SYSROOT) 21 | set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) 22 | set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) 23 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 24 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 25 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 26 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 27 | endif() 28 | 29 | # Define build configuration options. 30 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 31 | set(CMAKE_BUILD_TYPE "Debug" CACHE 32 | STRING "Flutter build mode" FORCE) 33 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 34 | "Debug" "Profile" "Release") 35 | endif() 36 | 37 | # Compilation settings that should be applied to most targets. 38 | # 39 | # Be cautious about adding new options here, as plugins use this function by 40 | # default. In most cases, you should add new options to specific targets instead 41 | # of modifying this function. 42 | function(APPLY_STANDARD_SETTINGS TARGET) 43 | target_compile_features(${TARGET} PUBLIC cxx_std_14) 44 | target_compile_options(${TARGET} PRIVATE -Wall -Werror) 45 | target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") 46 | target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") 47 | endfunction() 48 | 49 | # Flutter library and tool build rules. 50 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 51 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 52 | 53 | # System-level dependencies. 54 | find_package(PkgConfig REQUIRED) 55 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 56 | 57 | add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") 58 | 59 | # Define the application target. To change its name, change BINARY_NAME above, 60 | # not the value here, or `flutter run` will no longer work. 61 | # 62 | # Any new source files that you add to the application should be added here. 63 | add_executable(${BINARY_NAME} 64 | "main.cc" 65 | "my_application.cc" 66 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 67 | ) 68 | 69 | # Apply the standard set of build settings. This can be removed for applications 70 | # that need different build settings. 71 | apply_standard_settings(${BINARY_NAME}) 72 | 73 | # Add dependency libraries. Add any application-specific dependencies here. 74 | target_link_libraries(${BINARY_NAME} PRIVATE flutter) 75 | target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) 76 | 77 | # Run the Flutter tool portions of the build. This must not be removed. 78 | add_dependencies(${BINARY_NAME} flutter_assemble) 79 | 80 | # Only the install-generated bundle's copy of the executable will launch 81 | # correctly, since the resources must in the right relative locations. To avoid 82 | # people trying to run the unbundled copy, put it in a subdirectory instead of 83 | # the default top-level location. 84 | set_target_properties(${BINARY_NAME} 85 | PROPERTIES 86 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" 87 | ) 88 | 89 | # Generated plugin build rules, which manage building the plugins and adding 90 | # them to the application. 91 | include(flutter/generated_plugins.cmake) 92 | 93 | 94 | # === Installation === 95 | # By default, "installing" just makes a relocatable bundle in the build 96 | # directory. 97 | set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") 98 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 99 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 100 | endif() 101 | 102 | # Start with a clean build bundle directory every time. 103 | install(CODE " 104 | file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") 105 | " COMPONENT Runtime) 106 | 107 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 108 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") 109 | 110 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 111 | COMPONENT Runtime) 112 | 113 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 114 | COMPONENT Runtime) 115 | 116 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 117 | COMPONENT Runtime) 118 | 119 | foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) 120 | install(FILES "${bundled_library}" 121 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 122 | COMPONENT Runtime) 123 | endforeach(bundled_library) 124 | 125 | # Fully re-copy the assets directory on each build to avoid having stale files 126 | # from a previous install. 127 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 128 | install(CODE " 129 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 130 | " COMPONENT Runtime) 131 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 132 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 133 | 134 | # Install the AOT library on non-Debug builds only. 135 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") 136 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 137 | COMPONENT Runtime) 138 | endif() 139 | -------------------------------------------------------------------------------- /example/linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.10) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | 12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 13 | # which isn't available in 3.10. 14 | function(list_prepend LIST_NAME PREFIX) 15 | set(NEW_LIST "") 16 | foreach(element ${${LIST_NAME}}) 17 | list(APPEND NEW_LIST "${PREFIX}${element}") 18 | endforeach(element) 19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 20 | endfunction() 21 | 22 | # === Flutter Library === 23 | # System-level dependencies. 24 | find_package(PkgConfig REQUIRED) 25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 28 | 29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 30 | 31 | # Published to parent scope for install step. 32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 36 | 37 | list(APPEND FLUTTER_LIBRARY_HEADERS 38 | "fl_basic_message_channel.h" 39 | "fl_binary_codec.h" 40 | "fl_binary_messenger.h" 41 | "fl_dart_project.h" 42 | "fl_engine.h" 43 | "fl_json_message_codec.h" 44 | "fl_json_method_codec.h" 45 | "fl_message_codec.h" 46 | "fl_method_call.h" 47 | "fl_method_channel.h" 48 | "fl_method_codec.h" 49 | "fl_method_response.h" 50 | "fl_plugin_registrar.h" 51 | "fl_plugin_registry.h" 52 | "fl_standard_message_codec.h" 53 | "fl_standard_method_codec.h" 54 | "fl_string_codec.h" 55 | "fl_value.h" 56 | "fl_view.h" 57 | "flutter_linux.h" 58 | ) 59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 60 | add_library(flutter INTERFACE) 61 | target_include_directories(flutter INTERFACE 62 | "${EPHEMERAL_DIR}" 63 | ) 64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 65 | target_link_libraries(flutter INTERFACE 66 | PkgConfig::GTK 67 | PkgConfig::GLIB 68 | PkgConfig::GIO 69 | ) 70 | add_dependencies(flutter flutter_assemble) 71 | 72 | # === Flutter tool backend === 73 | # _phony_ is a non-existent file to force this command to run every time, 74 | # since currently there's no way to get a full input/output list from the 75 | # flutter tool. 76 | add_custom_command( 77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 79 | COMMAND ${CMAKE_COMMAND} -E env 80 | ${FLUTTER_TOOL_ENVIRONMENT} 81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 83 | VERBATIM 84 | ) 85 | add_custom_target(flutter_assemble DEPENDS 86 | "${FLUTTER_LIBRARY}" 87 | ${FLUTTER_LIBRARY_HEADERS} 88 | ) 89 | -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | 10 | void fl_register_plugins(FlPluginRegistry* registry) { 11 | } 12 | -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | ) 7 | 8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 9 | ) 10 | 11 | set(PLUGIN_BUNDLED_LIBRARIES) 12 | 13 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 18 | endforeach(plugin) 19 | 20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 23 | endforeach(ffi_plugin) 24 | -------------------------------------------------------------------------------- /example/linux/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /example/linux/my_application.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | #include 4 | #ifdef GDK_WINDOWING_X11 5 | #include 6 | #endif 7 | 8 | #include "flutter/generated_plugin_registrant.h" 9 | 10 | struct _MyApplication { 11 | GtkApplication parent_instance; 12 | char** dart_entrypoint_arguments; 13 | }; 14 | 15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) 16 | 17 | // Implements GApplication::activate. 18 | static void my_application_activate(GApplication* application) { 19 | MyApplication* self = MY_APPLICATION(application); 20 | GtkWindow* window = 21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 22 | 23 | // Use a header bar when running in GNOME as this is the common style used 24 | // by applications and is the setup most users will be using (e.g. Ubuntu 25 | // desktop). 26 | // If running on X and not using GNOME then just use a traditional title bar 27 | // in case the window manager does more exotic layout, e.g. tiling. 28 | // If running on Wayland assume the header bar will work (may need changing 29 | // if future cases occur). 30 | gboolean use_header_bar = TRUE; 31 | #ifdef GDK_WINDOWING_X11 32 | GdkScreen* screen = gtk_window_get_screen(window); 33 | if (GDK_IS_X11_SCREEN(screen)) { 34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 36 | use_header_bar = FALSE; 37 | } 38 | } 39 | #endif 40 | if (use_header_bar) { 41 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 42 | gtk_widget_show(GTK_WIDGET(header_bar)); 43 | gtk_header_bar_set_title(header_bar, "example"); 44 | gtk_header_bar_set_show_close_button(header_bar, TRUE); 45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 46 | } else { 47 | gtk_window_set_title(window, "example"); 48 | } 49 | 50 | gtk_window_set_default_size(window, 1280, 720); 51 | gtk_widget_show(GTK_WIDGET(window)); 52 | 53 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 54 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); 55 | 56 | FlView* view = fl_view_new(project); 57 | gtk_widget_show(GTK_WIDGET(view)); 58 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 59 | 60 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 61 | 62 | gtk_widget_grab_focus(GTK_WIDGET(view)); 63 | } 64 | 65 | // Implements GApplication::local_command_line. 66 | static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { 67 | MyApplication* self = MY_APPLICATION(application); 68 | // Strip out the first argument as it is the binary name. 69 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 70 | 71 | g_autoptr(GError) error = nullptr; 72 | if (!g_application_register(application, nullptr, &error)) { 73 | g_warning("Failed to register: %s", error->message); 74 | *exit_status = 1; 75 | return TRUE; 76 | } 77 | 78 | g_application_activate(application); 79 | *exit_status = 0; 80 | 81 | return TRUE; 82 | } 83 | 84 | // Implements 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 "ephemeral/Flutter-Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "ephemeral/Flutter-Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /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/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 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /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/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/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/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/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/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/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/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/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/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/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/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/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/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /example/macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = example 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.example 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2022 com.example. All rights reserved. 15 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /example/macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.server 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /example/macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | $(PRODUCT_COPYRIGHT) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /example/macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController.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 | arrow_path: 5 | dependency: transitive 6 | description: 7 | name: arrow_path 8 | sha256: "07194a2f165242543e81b7fb16d86d433b52ee31adb0dc9afe9273c0a45e2d9e" 9 | url: "https://pub.dev" 10 | source: hosted 11 | version: "2.0.0" 12 | async: 13 | dependency: transitive 14 | description: 15 | name: async 16 | sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" 17 | url: "https://pub.dev" 18 | source: hosted 19 | version: "2.11.0" 20 | boolean_selector: 21 | dependency: transitive 22 | description: 23 | name: boolean_selector 24 | sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" 25 | url: "https://pub.dev" 26 | source: hosted 27 | version: "2.1.1" 28 | characters: 29 | dependency: transitive 30 | description: 31 | name: characters 32 | sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" 33 | url: "https://pub.dev" 34 | source: hosted 35 | version: "1.3.0" 36 | clock: 37 | dependency: transitive 38 | description: 39 | name: clock 40 | sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf 41 | url: "https://pub.dev" 42 | source: hosted 43 | version: "1.1.1" 44 | collection: 45 | dependency: transitive 46 | description: 47 | name: collection 48 | sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a 49 | url: "https://pub.dev" 50 | source: hosted 51 | version: "1.18.0" 52 | cupertino_icons: 53 | dependency: "direct main" 54 | description: 55 | name: cupertino_icons 56 | sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 57 | url: "https://pub.dev" 58 | source: hosted 59 | version: "1.0.8" 60 | fake_async: 61 | dependency: transitive 62 | description: 63 | name: fake_async 64 | sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" 65 | url: "https://pub.dev" 66 | source: hosted 67 | version: "1.3.1" 68 | flutter: 69 | dependency: "direct main" 70 | description: flutter 71 | source: sdk 72 | version: "0.0.0" 73 | flutter_lints: 74 | dependency: "direct dev" 75 | description: 76 | name: flutter_lints 77 | sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 78 | url: "https://pub.dev" 79 | source: hosted 80 | version: "2.0.3" 81 | flutter_test: 82 | dependency: "direct dev" 83 | description: flutter 84 | source: sdk 85 | version: "0.0.0" 86 | graphite: 87 | dependency: "direct main" 88 | description: 89 | path: ".." 90 | relative: true 91 | source: path 92 | version: "1.1.2" 93 | leak_tracker: 94 | dependency: transitive 95 | description: 96 | name: leak_tracker 97 | sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" 98 | url: "https://pub.dev" 99 | source: hosted 100 | version: "10.0.4" 101 | leak_tracker_flutter_testing: 102 | dependency: transitive 103 | description: 104 | name: leak_tracker_flutter_testing 105 | sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" 106 | url: "https://pub.dev" 107 | source: hosted 108 | version: "3.0.3" 109 | leak_tracker_testing: 110 | dependency: transitive 111 | description: 112 | name: leak_tracker_testing 113 | sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" 114 | url: "https://pub.dev" 115 | source: hosted 116 | version: "3.0.1" 117 | lints: 118 | dependency: transitive 119 | description: 120 | name: lints 121 | sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" 122 | url: "https://pub.dev" 123 | source: hosted 124 | version: "2.1.1" 125 | matcher: 126 | dependency: transitive 127 | description: 128 | name: matcher 129 | sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb 130 | url: "https://pub.dev" 131 | source: hosted 132 | version: "0.12.16+1" 133 | material_color_utilities: 134 | dependency: transitive 135 | description: 136 | name: material_color_utilities 137 | sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" 138 | url: "https://pub.dev" 139 | source: hosted 140 | version: "0.8.0" 141 | meta: 142 | dependency: transitive 143 | description: 144 | name: meta 145 | sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" 146 | url: "https://pub.dev" 147 | source: hosted 148 | version: "1.12.0" 149 | path: 150 | dependency: transitive 151 | description: 152 | name: path 153 | sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" 154 | url: "https://pub.dev" 155 | source: hosted 156 | version: "1.9.0" 157 | sky_engine: 158 | dependency: transitive 159 | description: flutter 160 | source: sdk 161 | version: "0.0.99" 162 | source_span: 163 | dependency: transitive 164 | description: 165 | name: source_span 166 | sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" 167 | url: "https://pub.dev" 168 | source: hosted 169 | version: "1.10.0" 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: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" 207 | url: "https://pub.dev" 208 | source: hosted 209 | version: "0.7.0" 210 | touchable: 211 | dependency: transitive 212 | description: 213 | name: touchable 214 | sha256: "50040b39778bb1adc8a480625de8681253bd2134785395cf16abd66bb13d3ed0" 215 | url: "https://pub.dev" 216 | source: hosted 217 | version: "1.0.2" 218 | vector_math: 219 | dependency: transitive 220 | description: 221 | name: vector_math 222 | sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" 223 | url: "https://pub.dev" 224 | source: hosted 225 | version: "2.1.4" 226 | vm_service: 227 | dependency: transitive 228 | description: 229 | name: vm_service 230 | sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" 231 | url: "https://pub.dev" 232 | source: hosted 233 | version: "14.2.1" 234 | sdks: 235 | dart: ">=3.3.0 <4.0.0" 236 | flutter: ">=3.18.0-18.0.pre.54" 237 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: example 2 | description: A new Flutter project. 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 | # The following defines the version and build number for your application. 9 | # A version number is three numbers separated by dots, like 1.2.43 10 | # followed by an optional build number separated by a +. 11 | # Both the version and the builder number may be overridden in flutter 12 | # build by specifying --build-name and --build-number, respectively. 13 | # In Android, build-name is used as versionName while build-number used as versionCode. 14 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 15 | # In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. 16 | # Read more about iOS versioning at 17 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 18 | # In Windows, build-name is used as the major, minor, and patch parts 19 | # of the product and file versions while build-number is used as the build suffix. 20 | version: 1.0.0+1 21 | 22 | environment: 23 | sdk: '>=2.17.6 <3.0.0' 24 | 25 | # Dependencies specify other packages that your package needs in order to work. 26 | # To automatically upgrade your package dependencies to the latest versions 27 | # consider running `flutter pub upgrade --major-versions`. Alternatively, 28 | # dependencies can be manually updated by changing the version numbers below to 29 | # the latest version available on pub.dev. To see which dependencies have newer 30 | # versions available, run `flutter pub outdated`. 31 | dependencies: 32 | flutter: 33 | sdk: flutter 34 | graphite: 35 | path: ../ 36 | 37 | # The following adds the Cupertino Icons font to your application. 38 | # Use with the CupertinoIcons class for iOS style icons. 39 | cupertino_icons: ^1.0.2 40 | 41 | dev_dependencies: 42 | flutter_test: 43 | sdk: flutter 44 | 45 | # The "flutter_lints" package below contains a set of recommended lints to 46 | # encourage good coding practices. The lint set provided by the package is 47 | # activated in the `analysis_options.yaml` file located at the root of your 48 | # package. See that file for information about deactivating specific lint 49 | # rules and activating additional ones. 50 | flutter_lints: ^2.0.0 51 | 52 | # For information on the generic Dart part of this file, see the 53 | # following page: https://dart.dev/tools/pub/pubspec 54 | 55 | # The following section is specific to Flutter packages. 56 | flutter: 57 | 58 | # The following line ensures that the Material Icons font is 59 | # included with your application, so that you can use the icons in 60 | # the material Icons class. 61 | uses-material-design: true 62 | 63 | # To add assets to your application, add an assets section, like this: 64 | assets: 65 | - assets/ 66 | 67 | # An image asset can refer to one or more resolution-specific "variants", see 68 | # https://flutter.dev/assets-and-images/#resolution-aware 69 | 70 | # For details regarding adding assets from package dependencies, see 71 | # https://flutter.dev/assets-and-images/#from-packages 72 | 73 | # To add custom fonts to your application, add a fonts section here, 74 | # in this "flutter" section. Each entry in this list should have a 75 | # "family" key with the font family name, and a "fonts" key with a 76 | # list giving the asset and other descriptors for the font. For 77 | # example: 78 | # fonts: 79 | # - family: Schyler 80 | # fonts: 81 | # - asset: fonts/Schyler-Regular.ttf 82 | # - asset: fonts/Schyler-Italic.ttf 83 | # style: italic 84 | # - family: Trajan Pro 85 | # fonts: 86 | # - asset: fonts/TrajanPro.ttf 87 | # - asset: fonts/TrajanPro_Bold.ttf 88 | # weight: 700 89 | # 90 | # For details regarding fonts from package dependencies, 91 | # see https://flutter.dev/custom-fonts/#from-packages 92 | -------------------------------------------------------------------------------- /example/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/example/web/favicon.png -------------------------------------------------------------------------------- /example/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/example/web/icons/Icon-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/example/web/icons/Icon-512.png -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/example/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/example/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /example/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | example 33 | 34 | 35 | 39 | 40 | 41 | 42 | 43 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /example/web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "short_name": "example", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "A new Flutter project.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /example/windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /example/windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.14) 3 | project(example LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "example") 8 | 9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 10 | # versions of CMake. 11 | cmake_policy(SET CMP0063 NEW) 12 | 13 | # Define build configuration option. 14 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 15 | if(IS_MULTICONFIG) 16 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 17 | CACHE STRING "" FORCE) 18 | else() 19 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 20 | set(CMAKE_BUILD_TYPE "Debug" CACHE 21 | STRING "Flutter build mode" FORCE) 22 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 23 | "Debug" "Profile" "Release") 24 | endif() 25 | endif() 26 | # Define settings for the Profile build mode. 27 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 28 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 29 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 30 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 31 | 32 | # Use Unicode for all projects. 33 | add_definitions(-DUNICODE -D_UNICODE) 34 | 35 | # Compilation settings that should be applied to most targets. 36 | # 37 | # Be cautious about adding new options here, as plugins use this function by 38 | # default. In most cases, you should add new options to specific targets instead 39 | # of modifying this function. 40 | function(APPLY_STANDARD_SETTINGS TARGET) 41 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 42 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 43 | target_compile_options(${TARGET} PRIVATE /EHsc) 44 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 45 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 46 | endfunction() 47 | 48 | # Flutter library and tool build rules. 49 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 50 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 51 | 52 | # Application build; see runner/CMakeLists.txt. 53 | add_subdirectory("runner") 54 | 55 | # Generated plugin build rules, which manage building the plugins and adding 56 | # them to the application. 57 | include(flutter/generated_plugins.cmake) 58 | 59 | 60 | # === Installation === 61 | # Support files are copied into place next to the executable, so that it can 62 | # run in place. This is done instead of making a separate bundle (as on Linux) 63 | # so that building and running from within Visual Studio will work. 64 | set(BUILD_BUNDLE_DIR "$") 65 | # Make the "install" step default, as it's required to run. 66 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 67 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 68 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 69 | endif() 70 | 71 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 72 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 73 | 74 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 75 | COMPONENT Runtime) 76 | 77 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 78 | COMPONENT Runtime) 79 | 80 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 81 | COMPONENT Runtime) 82 | 83 | if(PLUGIN_BUNDLED_LIBRARIES) 84 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 85 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 86 | COMPONENT Runtime) 87 | endif() 88 | 89 | # Fully re-copy the assets directory on each build to avoid having stale files 90 | # from a previous install. 91 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 92 | install(CODE " 93 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 94 | " COMPONENT Runtime) 95 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 96 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 97 | 98 | # Install the AOT library on non-Debug builds only. 99 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 100 | CONFIGURATIONS Profile;Release 101 | COMPONENT Runtime) 102 | -------------------------------------------------------------------------------- /example/windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.14) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 12 | 13 | # === Flutter Library === 14 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 15 | 16 | # Published to parent scope for install step. 17 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 18 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 19 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 20 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 21 | 22 | list(APPEND FLUTTER_LIBRARY_HEADERS 23 | "flutter_export.h" 24 | "flutter_windows.h" 25 | "flutter_messenger.h" 26 | "flutter_plugin_registrar.h" 27 | "flutter_texture_registrar.h" 28 | ) 29 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 30 | add_library(flutter INTERFACE) 31 | target_include_directories(flutter INTERFACE 32 | "${EPHEMERAL_DIR}" 33 | ) 34 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 35 | add_dependencies(flutter flutter_assemble) 36 | 37 | # === Wrapper === 38 | list(APPEND CPP_WRAPPER_SOURCES_CORE 39 | "core_implementations.cc" 40 | "standard_codec.cc" 41 | ) 42 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 43 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 44 | "plugin_registrar.cc" 45 | ) 46 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 47 | list(APPEND CPP_WRAPPER_SOURCES_APP 48 | "flutter_engine.cc" 49 | "flutter_view_controller.cc" 50 | ) 51 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 52 | 53 | # Wrapper sources needed for a plugin. 54 | add_library(flutter_wrapper_plugin STATIC 55 | ${CPP_WRAPPER_SOURCES_CORE} 56 | ${CPP_WRAPPER_SOURCES_PLUGIN} 57 | ) 58 | apply_standard_settings(flutter_wrapper_plugin) 59 | set_target_properties(flutter_wrapper_plugin PROPERTIES 60 | POSITION_INDEPENDENT_CODE ON) 61 | set_target_properties(flutter_wrapper_plugin PROPERTIES 62 | CXX_VISIBILITY_PRESET hidden) 63 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 64 | target_include_directories(flutter_wrapper_plugin PUBLIC 65 | "${WRAPPER_ROOT}/include" 66 | ) 67 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 68 | 69 | # Wrapper sources needed for the runner. 70 | add_library(flutter_wrapper_app STATIC 71 | ${CPP_WRAPPER_SOURCES_CORE} 72 | ${CPP_WRAPPER_SOURCES_APP} 73 | ) 74 | apply_standard_settings(flutter_wrapper_app) 75 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 76 | target_include_directories(flutter_wrapper_app PUBLIC 77 | "${WRAPPER_ROOT}/include" 78 | ) 79 | add_dependencies(flutter_wrapper_app flutter_assemble) 80 | 81 | # === Flutter tool backend === 82 | # _phony_ is a non-existent file to force this command to run every time, 83 | # since currently there's no way to get a full input/output list from the 84 | # flutter tool. 85 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 86 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 87 | add_custom_command( 88 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 89 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 90 | ${CPP_WRAPPER_SOURCES_APP} 91 | ${PHONY_OUTPUT} 92 | COMMAND ${CMAKE_COMMAND} -E env 93 | ${FLUTTER_TOOL_ENVIRONMENT} 94 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 95 | windows-x64 $ 96 | VERBATIM 97 | ) 98 | add_custom_target(flutter_assemble DEPENDS 99 | "${FLUTTER_LIBRARY}" 100 | ${FLUTTER_LIBRARY_HEADERS} 101 | ${CPP_WRAPPER_SOURCES_CORE} 102 | ${CPP_WRAPPER_SOURCES_PLUGIN} 103 | ${CPP_WRAPPER_SOURCES_APP} 104 | ) 105 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | 10 | void RegisterPlugins(flutter::PluginRegistry* registry) { 11 | } 12 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | ) 7 | 8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 9 | ) 10 | 11 | set(PLUGIN_BUNDLED_LIBRARIES) 12 | 13 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 18 | endforeach(plugin) 19 | 20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 23 | endforeach(ffi_plugin) 24 | -------------------------------------------------------------------------------- /example/windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} WIN32 10 | "flutter_window.cpp" 11 | "main.cpp" 12 | "utils.cpp" 13 | "win32_window.cpp" 14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 15 | "Runner.rc" 16 | "runner.exe.manifest" 17 | ) 18 | 19 | # Apply the standard set of build settings. This can be removed for applications 20 | # that need different build settings. 21 | apply_standard_settings(${BINARY_NAME}) 22 | 23 | # Add preprocessor definitions for the build version. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") 25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") 26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") 27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") 28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") 29 | 30 | # Disable Windows macros that collide with C++ standard library functions. 31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 32 | 33 | # Add dependency libraries and include directories. Add any application-specific 34 | # dependencies here. 35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 36 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 37 | 38 | # Run the Flutter tool portions of the build. This must not be removed. 39 | add_dependencies(${BINARY_NAME} flutter_assemble) 40 | -------------------------------------------------------------------------------- /example/windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) 64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0,0 67 | #endif 68 | 69 | #if defined(FLUTTER_VERSION) 70 | #define VERSION_AS_STRING FLUTTER_VERSION 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "com.example" "\0" 93 | VALUE "FileDescription", "example" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "example" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2022 com.example. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "example.exe" "\0" 98 | VALUE "ProductName", "example" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /example/windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | 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"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/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/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 | std::string utf8_string; 52 | if (target_length == 0 || target_length > utf8_string.max_size()) { 53 | return utf8_string; 54 | } 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.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 | -------------------------------------------------------------------------------- /image/cba.svg: -------------------------------------------------------------------------------- 1 | 20 | -------------------------------------------------------------------------------- /image/custom.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/image/custom.gif -------------------------------------------------------------------------------- /image/dig.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/image/dig.gif -------------------------------------------------------------------------------- /image/flo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/image/flo.gif -------------------------------------------------------------------------------- /image/leb.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/image/leb.gif -------------------------------------------------------------------------------- /image/vertical.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lempiy/flutter_graphite/e69b211ae31ea84fb42ba818f4392691ff83582b/image/vertical.gif -------------------------------------------------------------------------------- /lib/core/graph.dart: -------------------------------------------------------------------------------- 1 | import 'package:graphite/core/graph_matrix.dart'; 2 | import 'package:graphite/core/matrix.dart'; 3 | import 'package:graphite/core/traverse_queue.dart'; 4 | import 'package:graphite/core/typings.dart'; 5 | 6 | class Graph extends GraphMatrix { 7 | Graph({required List list, required bool centred}) 8 | : super(list: list, centred: centred); 9 | 10 | void handleSplitNode(NodeOutput item, State state, TraverseQueue levelQueue) { 11 | bool isInserted = processOrSkipNodeOnMatrix(item, state); 12 | if (isInserted) { 13 | insertSplitOutcomes(item, state, levelQueue); 14 | } 15 | } 16 | 17 | void handleSplitJoinNode( 18 | NodeOutput item, State state, TraverseQueue levelQueue) { 19 | var queue = state.queue, mtx = state.mtx; 20 | if (joinHasUnresolvedIncomes(item)) { 21 | queue.push(item); 22 | return; 23 | } 24 | resolveCurrentJoinIncomes(mtx, item); 25 | bool isInserted = processOrSkipNodeOnMatrix(item, state); 26 | if (isInserted) { 27 | final initialY = state.y; 28 | insertJoinIncomes(item, state, levelQueue, false); 29 | state.y = initialY; 30 | insertSplitOutcomes(item, state, levelQueue); 31 | } 32 | } 33 | 34 | void handleJoinNode(NodeOutput item, State state, TraverseQueue levelQueue) { 35 | var queue = state.queue, mtx = state.mtx; 36 | if (joinHasUnresolvedIncomes(item)) { 37 | queue.push(item); 38 | return; 39 | } 40 | resolveCurrentJoinIncomes(mtx, item); 41 | bool isInserted = processOrSkipNodeOnMatrix(item, state); 42 | if (isInserted) { 43 | insertJoinIncomes(item, state, levelQueue, true); 44 | } 45 | } 46 | 47 | void handleSimpleNode( 48 | NodeOutput item, State state, TraverseQueue levelQueue) { 49 | var queue = state.queue; 50 | bool isInserted = processOrSkipNodeOnMatrix(item, state); 51 | if (isInserted) { 52 | queue.add( 53 | incomeId: item.id, 54 | bufferQueue: levelQueue, 55 | items: getOutcomesArray(item.id)); 56 | } 57 | } 58 | 59 | void traverseItem(NodeOutput item, State state, TraverseQueue levelQueue) { 60 | var mtx = state.mtx; 61 | switch (nodeType(item.id)) { 62 | case NodeType.rootSimple: 63 | state.y = mtx.getFreeRowForColumn(0); 64 | continue simple; 65 | simple: 66 | case NodeType.simple: 67 | handleSimpleNode(item, state, levelQueue); 68 | break; 69 | case NodeType.rootSplit: 70 | state.y = mtx.getFreeRowForColumn(0); 71 | continue split; 72 | split: 73 | case NodeType.split: 74 | handleSplitNode(item, state, levelQueue); 75 | break; 76 | case NodeType.join: 77 | handleJoinNode(item, state, levelQueue); 78 | break; 79 | case NodeType.splitJoin: 80 | handleSplitJoinNode(item, state, levelQueue); 81 | break; 82 | default: 83 | throw "Unknown node type ${nodeType(item.id)}"; 84 | } 85 | } 86 | 87 | void traverseLevel(State state) { 88 | var queue = state.queue; 89 | var levelQueue = queue.drain(); 90 | while (levelQueue.length() != 0) { 91 | state.iterations++; 92 | NodeOutput item = levelQueue.shift(); 93 | traverseItem(item, state, levelQueue); 94 | } 95 | } 96 | 97 | Matrix traverseList(State state) { 98 | var mtx = state.mtx, queue = state.queue; 99 | while (queue.length() != 0) { 100 | traverseLevel(state); 101 | state.x++; 102 | } 103 | return mtx; 104 | } 105 | 106 | Matrix traverse() { 107 | var roots = this.roots(); 108 | State state = State(mtx: Matrix(), queue: TraverseQueue(), x: 0, y: 0); 109 | if (roots.length == 0) { 110 | throw "no graph roots found"; 111 | } 112 | var mtx = state.mtx, queue = state.queue; 113 | queue.add(incomeId: null, bufferQueue: null, items: roots); 114 | mtx = traverseList(state); 115 | return mtx; 116 | } 117 | } 118 | 119 | Matrix listToMatrix(List list, bool centred) { 120 | Graph g = Graph(list: list, centred: centred); 121 | return g.traverse(); 122 | } 123 | -------------------------------------------------------------------------------- /lib/core/graph_basic.dart: -------------------------------------------------------------------------------- 1 | import 'package:graphite/core/typings.dart'; 2 | 3 | bool isMultiple(Map> m, String id) { 4 | return m.containsKey(id) && m[id]!.length > 1; 5 | } 6 | 7 | void addUniqueRelation(Map> rm, String key, String value) { 8 | var ok = rm.containsKey(key); 9 | if (!ok) { 10 | rm[key] = [value]; 11 | } 12 | if (!rm[key]!.contains(value)) { 13 | rm[key]!.add(value); 14 | } 15 | } 16 | 17 | class GraphBasic { 18 | GraphBasic({required List list, required bool centred}) { 19 | this.centred = centred; 20 | this.list = list; 21 | this.nodesMap = this.list.fold(Map(), (m, node) { 22 | if (m.containsKey(node.id)) { 23 | throw 'Duplicate node ${node.id}'; 24 | } 25 | m[node.id] = node; 26 | return m; 27 | }); 28 | 29 | this.detectIncomesAndOutcomes(); 30 | } 31 | 32 | void detectIncomesAndOutcomes() { 33 | Set totalSet = Set(); 34 | this.list.forEach((node) { 35 | if (totalSet.contains(node.id)) { 36 | return; 37 | } 38 | Set branchSet = Set(); 39 | this.traverseVertically(node, branchSet, totalSet); 40 | }); 41 | } 42 | 43 | Set traverseVertically( 44 | NodeInput node, Set branchSet, Set totalSet) { 45 | if (branchSet.contains(node.id)) { 46 | throw 'duplicate incomes for node id ${node.id}'; 47 | } 48 | branchSet.add(node.id); 49 | totalSet.add(node.id); 50 | node.next.forEach((out) { 51 | if (this.isLoopEdge(node.id, out.outcome)) { 52 | return; 53 | } 54 | if (branchSet.contains((out.outcome))) { 55 | addUniqueRelation(this.loopsByNodeIdMap, node.id, out.outcome); 56 | return; 57 | } 58 | addUniqueRelation(incomesByNodeIdMap, out.outcome, node.id); 59 | addUniqueRelation(outcomesByNodeIdMap, node.id, out.outcome); 60 | final nextNode = this.nodesMap[out.outcome]; 61 | if (nextNode == null) { 62 | throw 'node ${out.outcome} not found'; 63 | } 64 | if (totalSet.contains(out.outcome)) return; 65 | totalSet = 66 | this.traverseVertically(nextNode, Set.from(branchSet), totalSet); 67 | }); 68 | return totalSet; 69 | } 70 | 71 | bool isLoopEdge(String nodeId, String outcomeId) { 72 | if (!this.loopsByNodeIdMap.containsKey(nodeId)) { 73 | return false; 74 | } 75 | return this.loopsByNodeIdMap[nodeId]?.contains(outcomeId) ?? false; 76 | } 77 | 78 | List roots() { 79 | return this.list.where((NodeInput node) { 80 | return this.isRoot(node.id); 81 | }).toList(); 82 | } 83 | 84 | bool isRoot(String id) { 85 | return !this.incomesByNodeIdMap.containsKey(id) || 86 | this.incomesByNodeIdMap[id]?.length == 0; 87 | } 88 | 89 | bool isSplit(String id) { 90 | return isMultiple(this.outcomesByNodeIdMap, id); 91 | } 92 | 93 | bool isJoin(String id) { 94 | return isMultiple(this.incomesByNodeIdMap, id); 95 | } 96 | 97 | List loops(String id) { 98 | return this.loopsByNodeIdMap[id] ?? []; 99 | } 100 | 101 | List outcomes(String id) { 102 | return this.outcomesByNodeIdMap[id] ?? []; 103 | } 104 | 105 | List incomes(String id) { 106 | return this.incomesByNodeIdMap[id] ?? []; 107 | } 108 | 109 | NodeInput node(String id) { 110 | return this.nodesMap[id]!; 111 | } 112 | 113 | NodeType nodeType(String id) { 114 | if (isRoot(id) && isSplit(id)) return NodeType.rootSplit; 115 | if (isRoot(id)) return NodeType.rootSimple; 116 | if (isSplit(id) && isJoin(id)) return NodeType.splitJoin; 117 | if (isSplit(id)) return NodeType.split; 118 | if (isJoin(id)) return NodeType.join; 119 | return NodeType.simple; 120 | } 121 | 122 | List getOutcomesArray(String itemId) { 123 | List outcomes = this.outcomes(itemId); 124 | if (outcomes.length == 0) return []; 125 | return outcomes.map((String id) { 126 | return this.node(id); 127 | }).toList(growable: true); 128 | } 129 | 130 | List list = []; 131 | Map nodesMap = {}; 132 | Map> incomesByNodeIdMap = {}; 133 | Map> outcomesByNodeIdMap = {}; 134 | Map> loopsByNodeIdMap = {}; 135 | bool centred = false; 136 | } 137 | -------------------------------------------------------------------------------- /lib/core/traverse_queue.dart: -------------------------------------------------------------------------------- 1 | import 'package:graphite/core/typings.dart'; 2 | 3 | class TraverseQueue { 4 | TraverseQueue() : this.s = []; 5 | 6 | add({ 7 | String? incomeId, 8 | TraverseQueue? bufferQueue, 9 | required List items, 10 | }) { 11 | items.forEach((itm) { 12 | var item = this.find((NodeOutput el) { 13 | return el.id == itm.id; 14 | }); 15 | if (item == null && bufferQueue != null) { 16 | item = bufferQueue.find((NodeOutput el) { 17 | return el.id == itm.id; 18 | }); 19 | } 20 | if (item != null && incomeId != null) { 21 | item.passedIncomes.add(incomeId); 22 | return; 23 | } 24 | List incomes = incomeId == null ? [] : [incomeId]; 25 | List renderIncomes = incomeId == null ? [] : [incomeId]; 26 | this.s.add(NodeOutput( 27 | id: itm.id, 28 | next: itm.next, 29 | size: itm.size, 30 | passedIncomes: incomes, 31 | renderIncomes: renderIncomes, 32 | childrenOnMatrix: 0, 33 | isAnchor: false, 34 | )); 35 | }); 36 | } 37 | 38 | NodeOutput? find(bool Function(NodeOutput) f) { 39 | int idx = this.s.indexWhere(f); 40 | return idx != -1 ? this.s[idx] : null; 41 | } 42 | 43 | push(NodeOutput item) { 44 | this.s.add(item); 45 | } 46 | 47 | int length() { 48 | return this.s.length; 49 | } 50 | 51 | bool some(bool Function(NodeOutput) f) { 52 | return this.s.any(f); 53 | } 54 | 55 | NodeOutput shift() { 56 | if (this.s.length == 0) throw 'Queue is empty'; 57 | return this.s.removeAt(0); 58 | } 59 | 60 | TraverseQueue drain() { 61 | var queue = TraverseQueue(); 62 | queue.s.addAll(this.s); 63 | this.s = []; 64 | return queue; 65 | } 66 | 67 | List s; 68 | } 69 | -------------------------------------------------------------------------------- /lib/core/typings.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | enum NodeType { 4 | unknown, 5 | rootSimple, 6 | rootSplit, 7 | simple, 8 | split, 9 | join, 10 | splitJoin, 11 | } 12 | 13 | enum AnchorOrientation { 14 | none, 15 | topLeft, 16 | topRight, 17 | bottomLeft, 18 | bottomRight, 19 | } 20 | 21 | enum AnchorMargin { none, start, end } 22 | 23 | enum MatrixOrientation { 24 | Horizontal, 25 | Vertical, 26 | } 27 | 28 | List nodeInputFromJson(String str) => 29 | List.from(json.decode(str).map((x) => NodeInput.fromJson(x))); 30 | 31 | String nodeInputToJson(List data) => 32 | json.encode(List.from(data.map((x) => x.toJson()))); 33 | 34 | enum EdgeArrowType { none, one, both } 35 | 36 | class EdgeInput { 37 | /// Input data for node's edge. 38 | /// [outcome] *unique* identifier of the outcome node. Outcome node should exist 39 | /// in [DirectGraph.list]. 40 | /// [type] style of arrows to be drawn on the edge if [DirectGraph.pathBuilder] is not 41 | /// defined and default builder is used. 42 | EdgeInput({ 43 | required this.outcome, 44 | this.type = EdgeArrowType.one, 45 | }); 46 | 47 | /// [outcome] *unique* identifier of the outcome node. Outcome node should exist 48 | /// in [DirectGraph.list]. 49 | final String outcome; 50 | 51 | /// style of arrows to be drawn on the edge 52 | /// [EdgeArrowType.none] draw no arrows. 53 | /// [EdgeArrowType.one] draw arrow only at the end of the edge. 54 | /// [EdgeArrowType.both] draw arrows on both sides of the edge. 55 | final EdgeArrowType type; 56 | 57 | factory EdgeInput.fromJson(Map json) => EdgeInput( 58 | outcome: json["outcome"] == null ? null : json["outcome"], 59 | type: json["type"] == null 60 | ? EdgeArrowType.one 61 | : EdgeInput.typeFromString(json["type"]), 62 | ); 63 | 64 | static EdgeArrowType typeFromString(String typeAsString) { 65 | switch (typeAsString) { 66 | case "both": 67 | return EdgeArrowType.both; 68 | case "none": 69 | return EdgeArrowType.none; 70 | default: 71 | return EdgeArrowType.one; 72 | } 73 | } 74 | 75 | String typeToString() { 76 | switch (type) { 77 | case EdgeArrowType.both: 78 | return "both"; 79 | case EdgeArrowType.none: 80 | return "none"; 81 | default: 82 | return "one"; 83 | } 84 | } 85 | 86 | Map toJson() => { 87 | "outcome": outcome, 88 | "type": typeToString(), 89 | }; 90 | } 91 | 92 | class NodeSize { 93 | final double width; 94 | final double height; 95 | 96 | const NodeSize({ 97 | required this.width, 98 | required this.height, 99 | }); 100 | 101 | factory NodeSize.fromJson(Map json) => NodeSize( 102 | width: json["width"] == null ? 0 : (json["width"] as double), 103 | height: json["height"] == null ? 0 : (json["height"] as double), 104 | ); 105 | 106 | Map toJson() => { 107 | "width": width, 108 | "height": height, 109 | }; 110 | } 111 | 112 | class NodeInput { 113 | /// Input data for graphite graph's node. 114 | /// [id] *unique* id of the node. 115 | /// [next] outcomes list for the node defined as list of [EdgeInput]'s. 116 | /// custom [size] of the node to override [DirectGraph.defaultCellSize]. 117 | NodeInput({ 118 | required this.id, 119 | required this.next, 120 | this.size, 121 | }); 122 | 123 | /// [NodeSize] of the node to override [DirectGraph.defaultCellSize] . 124 | final NodeSize? size; 125 | 126 | /// *unique* identifier of the node. 127 | final String id; 128 | 129 | /// outcomes list for the node defined as list of [EdgeInput]'s. 130 | final List next; 131 | 132 | double? getWidth() { 133 | return size == null ? 0 : size!.width; 134 | } 135 | 136 | double? getHeight() { 137 | return size == null ? 0 : size!.height; 138 | } 139 | 140 | factory NodeInput.fromJson(Map json) => NodeInput( 141 | id: json["id"] == null ? null : json["id"], 142 | next: 143 | List.from(json["next"].map((x) => EdgeInput.fromJson(x))), 144 | size: json["size"] == null ? null : NodeSize.fromJson(json["size"])); 145 | 146 | Map toJson() => { 147 | "id": id, 148 | "next": List.from(next.map((x) => x.toJson())), 149 | "size": size == null ? null : size!.toJson(), 150 | }; 151 | } 152 | 153 | enum AnchorType { 154 | unknown, 155 | join, 156 | split, 157 | loop, 158 | } 159 | 160 | class MatrixNode extends NodeOutput { 161 | MatrixNode({ 162 | required this.x, 163 | required this.y, 164 | required String id, 165 | required List next, 166 | NodeSize? size, 167 | AnchorType? anchorType, 168 | String? from, 169 | String? to, 170 | AnchorOrientation? orientation, 171 | bool isAnchor = false, 172 | AnchorMargin? anchorMargin, 173 | List passedIncomes = const [], 174 | List renderIncomes = const [], 175 | int? childrenOnMatrix, 176 | }) : super( 177 | id: id, 178 | next: next, 179 | size: size, 180 | anchorType: anchorType, 181 | from: from, 182 | to: to, 183 | orientation: orientation, 184 | isAnchor: isAnchor, 185 | anchorMargin: anchorMargin, 186 | passedIncomes: passedIncomes, 187 | renderIncomes: renderIncomes, 188 | childrenOnMatrix: childrenOnMatrix, 189 | ); 190 | static MatrixNode fromNodeOutput( 191 | {required int x, required int y, required NodeOutput nodeOutput}) { 192 | return MatrixNode( 193 | x: x, 194 | y: y, 195 | size: nodeOutput.size, 196 | id: nodeOutput.id, 197 | next: nodeOutput.next, 198 | anchorType: nodeOutput.anchorType, 199 | from: nodeOutput.from, 200 | to: nodeOutput.to, 201 | orientation: nodeOutput.orientation, 202 | isAnchor: nodeOutput.isAnchor, 203 | anchorMargin: nodeOutput.anchorMargin, 204 | passedIncomes: nodeOutput.passedIncomes, 205 | renderIncomes: nodeOutput.renderIncomes, 206 | childrenOnMatrix: nodeOutput.childrenOnMatrix, 207 | ); 208 | } 209 | 210 | /// column index of node inside two dimensional matrix 211 | final int x; 212 | 213 | /// row index of node inside two dimensional matrix 214 | final int y; 215 | 216 | NodeInput toInput() { 217 | return NodeInput(id: id, next: next, size: size); 218 | } 219 | } 220 | 221 | class NodeOutput extends NodeInput { 222 | NodeOutput({ 223 | required String id, 224 | required List next, 225 | NodeSize? size, 226 | this.anchorType, 227 | this.from, 228 | this.to, 229 | this.orientation, 230 | this.isAnchor = false, 231 | this.passedIncomes = const [], 232 | this.renderIncomes = const [], 233 | this.childrenOnMatrix, 234 | this.anchorMargin, 235 | }) : super(id: id, next: next, size: size); 236 | 237 | Map anchors = {}; 238 | NodeOutput? node; 239 | 240 | AnchorType? anchorType; 241 | String? from; 242 | String? to; 243 | AnchorOrientation? orientation; 244 | AnchorMargin? anchorMargin; 245 | 246 | bool isAnchor; 247 | List passedIncomes = []; 248 | List renderIncomes = []; 249 | int? childrenOnMatrix; 250 | } 251 | 252 | class LoopNode { 253 | LoopNode({ 254 | required this.id, 255 | required this.node, 256 | required this.x, 257 | required this.y, 258 | this.isSelfLoop = false, 259 | }); 260 | 261 | String id; 262 | NodeOutput node; 263 | int x; 264 | int y; 265 | bool isSelfLoop; 266 | } 267 | 268 | class Edge { 269 | final List> points; 270 | final MatrixNode from; 271 | final MatrixNode to; 272 | final EdgeArrowType arrowType; 273 | 274 | Edge(this.points, this.from, this.to, this.arrowType); 275 | } 276 | -------------------------------------------------------------------------------- /lib/graphite_cell.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | import 'package:graphite/core/typings.dart'; 3 | import 'package:graphite/graphite_typings.dart'; 4 | 5 | Widget _defaultNodeCellBuilder(BuildContext context, MatrixNode node) { 6 | return Container( 7 | decoration: BoxDecoration(border: Border.all()), 8 | alignment: Alignment.center, 9 | child: Text(node.id), 10 | ); 11 | } 12 | 13 | class GraphiteCell extends StatefulWidget { 14 | final MatrixNode node; 15 | final Rect rect; 16 | 17 | final Key? key; 18 | 19 | final NodeCellBuilder? builder; 20 | 21 | final GestureNodeTapDownCallback? onNodeTapDown; 22 | 23 | final GestureNodeTapUpCallback? onNodeTapUp; 24 | final GestureNodeLongPressStartCallback? onNodeLongPressStart; 25 | 26 | final GestureNodeLongPressEndCallback? onNodeLongPressEnd; 27 | final GestureNodeLongPressMoveUpdateCallback? onNodeLongPressMoveUpdate; 28 | 29 | final GestureNodeForcePressStartCallback? onNodeForcePressStart; 30 | final GestureNodeForcePressEndCallback? onNodeForcePressEnd; 31 | 32 | final GestureNodeForcePressPeakCallback? onNodeForcePressPeak; 33 | final GestureNodeForcePressUpdateCallback? onNodeForcePressUpdate; 34 | 35 | final GestureNodePanStartCallback? onNodePanStart; 36 | final GestureNodePanUpdateCallback? onNodePanUpdate; 37 | 38 | final GestureNodePanDownCallback? onNodePanDown; 39 | final GestureNodeTapDownCallback? onNodeSecondaryTapDown; 40 | 41 | final GestureNodeTapUpCallback? onNodeSecondaryTapUp; 42 | 43 | const GraphiteCell({ 44 | this.key, 45 | required this.node, 46 | required this.rect, 47 | this.onNodeTapDown, 48 | this.onNodeTapUp, 49 | this.onNodeLongPressStart, 50 | this.onNodeLongPressEnd, 51 | this.onNodeLongPressMoveUpdate, 52 | this.onNodeForcePressStart, 53 | this.onNodeForcePressEnd, 54 | this.onNodeForcePressPeak, 55 | this.onNodeForcePressUpdate, 56 | this.onNodePanStart, 57 | this.onNodePanUpdate, 58 | this.onNodePanDown, 59 | this.onNodeSecondaryTapDown, 60 | this.onNodeSecondaryTapUp, 61 | this.builder, 62 | }); 63 | @override 64 | _GraphiteCellState createState() => _GraphiteCellState(); 65 | } 66 | 67 | class _GraphiteCellState extends State { 68 | @override 69 | Widget build(BuildContext context) { 70 | var node = widget.node; 71 | return Container( 72 | child: GestureDetector( 73 | onTapDown: widget.onNodeTapDown != null 74 | ? (details) => widget.onNodeTapDown!(details, node, widget.rect) 75 | : null, 76 | onTapUp: widget.onNodeTapUp != null 77 | ? (details) => widget.onNodeTapUp!(details, node, widget.rect) 78 | : null, 79 | onLongPressStart: widget.onNodeLongPressStart != null 80 | ? (details) => 81 | widget.onNodeLongPressStart!(details, node, widget.rect) 82 | : null, 83 | onLongPressEnd: widget.onNodeLongPressEnd != null 84 | ? (details) => 85 | widget.onNodeLongPressEnd!(details, node, widget.rect) 86 | : null, 87 | onLongPressMoveUpdate: widget.onNodeLongPressMoveUpdate != null 88 | ? (details) => 89 | widget.onNodeLongPressMoveUpdate!(details, node, widget.rect) 90 | : null, 91 | onForcePressStart: widget.onNodeForcePressStart != null 92 | ? (details) => 93 | widget.onNodeForcePressStart!(details, node, widget.rect) 94 | : null, 95 | onForcePressEnd: widget.onNodeForcePressEnd != null 96 | ? (details) => 97 | widget.onNodeForcePressEnd!(details, node, widget.rect) 98 | : null, 99 | onForcePressPeak: widget.onNodeForcePressPeak != null 100 | ? (details) => 101 | widget.onNodeForcePressPeak!(details, node, widget.rect) 102 | : null, 103 | onForcePressUpdate: widget.onNodeForcePressUpdate != null 104 | ? (details) => 105 | widget.onNodeForcePressUpdate!(details, node, widget.rect) 106 | : null, 107 | onPanStart: widget.onNodePanStart != null 108 | ? (details) => widget.onNodePanStart!(details, node, widget.rect) 109 | : null, 110 | onPanUpdate: widget.onNodePanUpdate != null 111 | ? (details) => widget.onNodePanUpdate!(details, node, widget.rect) 112 | : null, 113 | onPanDown: widget.onNodePanDown != null 114 | ? (details) => widget.onNodePanDown!(details, node, widget.rect) 115 | : null, 116 | onSecondaryTapDown: widget.onNodeSecondaryTapDown != null 117 | ? (details) => 118 | widget.onNodeSecondaryTapDown!(details, node, widget.rect) 119 | : null, 120 | onSecondaryTapUp: widget.onNodeSecondaryTapUp != null 121 | ? (details) => 122 | widget.onNodeSecondaryTapUp!(details, node, widget.rect) 123 | : null, 124 | child: Builder(builder: (ctx) { 125 | return widget.builder == null 126 | ? _defaultNodeCellBuilder(ctx, node) 127 | : widget.builder!(ctx, node); 128 | }), 129 | //child: Container(), 130 | ), 131 | ); 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /lib/graphite_root.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | import 'package:graphite/core/matrix.dart'; 3 | import 'package:graphite/core/typings.dart'; 4 | import 'package:graphite/graphite_canvas.dart'; 5 | import 'package:graphite/graphite_typings.dart'; 6 | 7 | class GraphiteRoot extends StatefulWidget { 8 | final Matrix mtx; 9 | final Size defaultCellSize; 10 | final EdgeInsets cellPadding; 11 | final double contactEdgesDistance; 12 | final MatrixOrientation orientation; 13 | final double maxScale; 14 | final double minScale; 15 | final Clip clipBehavior; 16 | 17 | // Node 18 | final NodeCellBuilder? builder; 19 | 20 | // Overlay 21 | final OverlayBuilder? overlayBuilder; 22 | 23 | // Edge label 24 | final EdgeLabels? edgeLabels; 25 | 26 | final GestureNodeTapDownCallback? onNodeTapDown; 27 | 28 | final GestureNodeTapUpCallback? onNodeTapUp; 29 | final GestureNodeLongPressStartCallback? onNodeLongPressStart; 30 | 31 | final GestureNodeLongPressEndCallback? onNodeLongPressEnd; 32 | final GestureNodeLongPressMoveUpdateCallback? onNodeLongPressMoveUpdate; 33 | 34 | final GestureNodeForcePressStartCallback? onNodeForcePressStart; 35 | final GestureNodeForcePressEndCallback? onNodeForcePressEnd; 36 | 37 | final GestureNodeForcePressPeakCallback? onNodeForcePressPeak; 38 | final GestureNodeForcePressUpdateCallback? onNodeForcePressUpdate; 39 | 40 | final GestureNodePanStartCallback? onNodePanStart; 41 | final GestureNodePanUpdateCallback? onNodePanUpdate; 42 | 43 | final GestureNodePanDownCallback? onNodePanDown; 44 | final GestureNodeTapDownCallback? onNodeSecondaryTapDown; 45 | 46 | final GestureNodeTapUpCallback? onNodeSecondaryTapUp; 47 | 48 | // Edge 49 | final EdgeStyleBuilder? styleBuilder; 50 | final EdgePathBuilder? pathBuilder; 51 | 52 | final GestureBackgroundTapCallback? onCanvasTap; 53 | final GestureEdgeTapDownCallback? onEdgeTapDown; 54 | 55 | final GestureEdgeTapUpCallback? onEdgeTapUp; 56 | final GestureEdgeLongPressStartCallback? onEdgeLongPressStart; 57 | 58 | final GestureEdgeLongPressEndCallback? onEdgeLongPressEnd; 59 | final GestureEdgeLongPressMoveUpdateCallback? onEdgeLongPressMoveUpdate; 60 | 61 | final GestureEdgeForcePressStartCallback? onEdgeForcePressStart; 62 | final GestureEdgeForcePressEndCallback? onEdgeForcePressEnd; 63 | 64 | final GestureEdgeForcePressPeakCallback? onEdgeForcePressPeak; 65 | final GestureEdgeForcePressUpdateCallback? onEdgeForcePressUpdate; 66 | 67 | final GestureEdgeTapDownCallback? onEdgeSecondaryTapDown; 68 | 69 | final GestureEdgeTapUpCallback? onEdgeSecondaryTapUp; 70 | 71 | GraphiteRoot({ 72 | required this.mtx, 73 | required this.defaultCellSize, 74 | required this.cellPadding, 75 | required this.maxScale, 76 | required this.minScale, 77 | required this.orientation, 78 | required this.contactEdgesDistance, 79 | required this.clipBehavior, 80 | this.overlayBuilder, 81 | this.edgeLabels, 82 | this.onEdgeTapDown, 83 | this.onEdgeTapUp, 84 | this.onCanvasTap, 85 | this.onEdgeLongPressStart, 86 | this.onEdgeLongPressEnd, 87 | this.onEdgeLongPressMoveUpdate, 88 | this.onEdgeForcePressStart, 89 | this.onEdgeForcePressEnd, 90 | this.onEdgeForcePressPeak, 91 | this.onEdgeForcePressUpdate, 92 | this.onEdgeSecondaryTapDown, 93 | this.onEdgeSecondaryTapUp, 94 | this.styleBuilder, 95 | this.onNodeTapDown, 96 | this.onNodeTapUp, 97 | this.onNodeLongPressStart, 98 | this.onNodeLongPressEnd, 99 | this.onNodeLongPressMoveUpdate, 100 | this.onNodeForcePressStart, 101 | this.onNodeForcePressEnd, 102 | this.onNodeForcePressPeak, 103 | this.onNodeForcePressUpdate, 104 | this.onNodePanStart, 105 | this.onNodePanUpdate, 106 | this.onNodePanDown, 107 | this.onNodeSecondaryTapDown, 108 | this.onNodeSecondaryTapUp, 109 | this.builder, 110 | this.pathBuilder, 111 | }); 112 | @override 113 | _GraphiteRootState createState() => _GraphiteRootState(); 114 | } 115 | 116 | class _GraphiteRootState extends State { 117 | @override 118 | Widget build(BuildContext context) { 119 | return GraphiteCanvas( 120 | matrix: widget.mtx, 121 | defaultCellSize: widget.defaultCellSize, 122 | overlayBuilder: widget.overlayBuilder, 123 | clipBehavior: widget.clipBehavior, 124 | edgeLabels: widget.edgeLabels, 125 | cellPadding: widget.cellPadding, 126 | contactEdgesDistance: widget.contactEdgesDistance, 127 | orientation: widget.orientation, 128 | styleBuilder: widget.styleBuilder, 129 | onCanvasTap: widget.onCanvasTap, 130 | onEdgeTapDown: widget.onEdgeTapDown, 131 | onEdgeTapUp: widget.onEdgeTapUp, 132 | onEdgeLongPressStart: widget.onEdgeLongPressStart, 133 | onEdgeLongPressEnd: widget.onEdgeLongPressEnd, 134 | onEdgeLongPressMoveUpdate: widget.onEdgeLongPressMoveUpdate, 135 | onEdgeForcePressStart: widget.onEdgeForcePressStart, 136 | onEdgeForcePressEnd: widget.onEdgeForcePressEnd, 137 | onEdgeForcePressPeak: widget.onEdgeForcePressPeak, 138 | onEdgeForcePressUpdate: widget.onEdgeForcePressUpdate, 139 | onEdgeSecondaryTapDown: widget.onEdgeSecondaryTapDown, 140 | onEdgeSecondaryTapUp: widget.onEdgeSecondaryTapUp, 141 | maxScale: widget.maxScale, 142 | minScale: widget.minScale, 143 | pathBuilder: widget.pathBuilder, 144 | builder: widget.builder, 145 | onNodeTapDown: widget.onNodeTapDown, 146 | onNodeTapUp: widget.onNodeTapUp, 147 | onNodeLongPressStart: widget.onNodeLongPressStart, 148 | onNodeLongPressEnd: widget.onNodeLongPressEnd, 149 | onNodeLongPressMoveUpdate: widget.onNodeLongPressMoveUpdate, 150 | onNodeForcePressStart: widget.onNodeForcePressStart, 151 | onNodeForcePressEnd: widget.onNodeForcePressEnd, 152 | onNodeForcePressPeak: widget.onNodeForcePressPeak, 153 | onNodeForcePressUpdate: widget.onNodeForcePressUpdate, 154 | onNodePanStart: widget.onNodePanStart, 155 | onNodePanUpdate: widget.onNodePanUpdate, 156 | onNodePanDown: widget.onNodePanDown, 157 | onNodeSecondaryTapDown: widget.onNodeSecondaryTapDown, 158 | onNodeSecondaryTapUp: widget.onNodeSecondaryTapUp); 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /lib/graphite_typings.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:flutter/widgets.dart'; 4 | import 'package:graphite/core/typings.dart'; 5 | 6 | typedef NodeCellBuilder = Widget Function(BuildContext context, NodeInput node); 7 | 8 | typedef OverlayBuilder = List Function( 9 | BuildContext context, 10 | List nodes, 11 | List edges, 12 | ); 13 | 14 | typedef EdgeLabelBuilder = Widget Function( 15 | BuildContext context, Edge edge, bool isVertical); 16 | 17 | typedef ContentWrapperBuilder = Widget Function( 18 | BuildContext context, Size size, Widget child); 19 | 20 | enum EdgeLabelTextAlignment { 21 | before, 22 | after, 23 | } 24 | 25 | enum EdgeLabelPositionPriority { horizontal, vertical, none } 26 | 27 | /// List of params to draw labels on top or above the edges. Useful to comment 28 | /// relations between entities. 29 | class EdgeLabels { 30 | /// Label widget's builder function. Provides [Edge] details. 31 | final EdgeLabelBuilder builder; 32 | 33 | /// If set to [EdgeLabelTextAlignment.before] draws label before edge's line. Default value. 34 | /// If set to [EdgeLabelTextAlignment.after] draws label after edge's line. 35 | final EdgeLabelTextAlignment alignment; 36 | 37 | /// [EdgeLabelPositionPriority.horizontal] means to stick label to horizontal 38 | /// line inside edge path if possible. 39 | /// [EdgeLabelPositionPriority.vertical] means to stick label to vertical 40 | /// line inside edge path if possible. 41 | /// [EdgeLabelPositionPriority.none] default value, means to stick label to 42 | /// vertical line if graph's orientation is [MatrixOrientation.Horizontal] 43 | /// and to horizontal line of graph's orientation is [MatrixOrientation.Vertical]. 44 | final EdgeLabelPositionPriority positionPriority; 45 | 46 | const EdgeLabels({ 47 | required this.builder, 48 | this.alignment = EdgeLabelTextAlignment.before, 49 | this.positionPriority = EdgeLabelPositionPriority.none, 50 | }); 51 | } 52 | 53 | typedef GestureNodeTapDownCallback = void Function( 54 | TapDownDetails details, MatrixNode node, Rect rect); 55 | typedef GestureNodeTapUpCallback = void Function( 56 | TapUpDetails details, MatrixNode node, Rect rect); 57 | 58 | typedef GestureNodeLongPressStartCallback = void Function( 59 | LongPressStartDetails details, MatrixNode node, Rect rect); 60 | typedef GestureNodeLongPressEndCallback = void Function( 61 | LongPressEndDetails details, MatrixNode node, Rect rect); 62 | typedef GestureNodeLongPressMoveUpdateCallback = void Function( 63 | LongPressMoveUpdateDetails details, MatrixNode node, Rect rect); 64 | typedef GestureNodeForcePressStartCallback = void Function( 65 | ForcePressDetails details, MatrixNode node, Rect rect); 66 | typedef GestureNodeForcePressEndCallback = void Function( 67 | ForcePressDetails details, MatrixNode node, Rect rect); 68 | typedef GestureNodeForcePressPeakCallback = void Function( 69 | ForcePressDetails details, MatrixNode node, Rect rect); 70 | typedef GestureNodeForcePressUpdateCallback = void Function( 71 | ForcePressDetails details, MatrixNode node, Rect rect); 72 | typedef GestureNodePanStartCallback = void Function( 73 | DragStartDetails details, MatrixNode node, Rect rect); 74 | typedef GestureNodePanUpdateCallback = void Function( 75 | DragUpdateDetails details, MatrixNode node, Rect rect); 76 | typedef GestureNodePanDownCallback = void Function( 77 | DragDownDetails details, MatrixNode node, Rect rect); 78 | 79 | typedef GestureBackgroundTapCallback = void Function(TapDownDetails details); 80 | typedef EdgeStyleBuilder = EdgeStyle Function(Edge edge); 81 | typedef GestureEdgeTapDownCallback = void Function( 82 | TapDownDetails details, Edge edge); 83 | typedef GestureEdgeTapUpCallback = void Function( 84 | TapUpDetails details, Edge edge); 85 | 86 | typedef GestureEdgeLongPressStartCallback = void Function( 87 | LongPressStartDetails details, Edge edge); 88 | typedef GestureEdgeLongPressEndCallback = void Function( 89 | LongPressEndDetails details, Edge edge); 90 | typedef GestureEdgeLongPressMoveUpdateCallback = void Function( 91 | LongPressMoveUpdateDetails details, Edge edge); 92 | typedef GestureEdgeForcePressStartCallback = void Function( 93 | ForcePressDetails details, Edge edge); 94 | typedef GestureEdgeForcePressEndCallback = void Function( 95 | ForcePressDetails details, Edge edge); 96 | typedef GestureEdgeForcePressPeakCallback = void Function( 97 | ForcePressDetails details, Edge edge); 98 | typedef GestureEdgeForcePressUpdateCallback = void Function( 99 | ForcePressDetails details, Edge edge); 100 | typedef GestureEdgeDragStartCallback = void Function( 101 | DragStartDetails details, Edge edge); 102 | typedef GestureEdgeDragUpdateCallback = void Function( 103 | DragUpdateDetails details, Edge edge); 104 | typedef GestureEdgeDragDownCallback = void Function( 105 | DragDownDetails details, Edge edge); 106 | 107 | typedef EdgePathBuilder = Path Function(NodeInput income, NodeInput node, 108 | List> points, EdgeStyle style); 109 | 110 | enum LineStyle { solid, dashed, dotted, dashDotted } 111 | 112 | class EdgeStyle { 113 | /// [LineStyle] of edges to draw. 114 | final LineStyle lineStyle; 115 | 116 | /// [Paint] of edges to use in drawing. 117 | final Paint linePaint; 118 | 119 | /// border radius of edges angles. 120 | final double borderRadius; 121 | 122 | /// length of dash in [LineStyle.dashed] 123 | /// and [LineStyle.dashDotted] styles. Ignored if 124 | /// style is [LineStyle.solid] or [LineStyle.dotted]. 125 | final double dashLength; 126 | 127 | /// length of a gap in [LineStyle.dotted], [LineStyle.dashed] 128 | /// and [LineStyle.dashDotted] styles. Ignored if 129 | /// style is [LineStyle.solid]. 130 | final double gapLength; 131 | 132 | /// diameter of dot in [LineStyle.dotted] 133 | /// and [LineStyle.dashDotted] styles. Ignored if 134 | /// style is [LineStyle.solid] or [LineStyle.dashed]. 135 | final double dotLength; 136 | 137 | /// the type of arrows on the edge. 138 | final EdgeArrowType arrowType; 139 | 140 | /// is the length (in pixels) of each of the 2 lines making the arrow. 141 | /// Ignored if using custom [pathBuilder] is set. 142 | final double tipLength; 143 | 144 | /// [tipAngle] is the angle (in radians) between each of the 2 lines making the arrow and the curve at this point. 145 | /// Ignored if using custom [pathBuilder] is set. 146 | final double tipAngle; 147 | 148 | EdgeStyle({ 149 | Paint? linePaint, 150 | this.lineStyle = LineStyle.solid, 151 | this.borderRadius = 0, 152 | this.dashLength = 10, 153 | this.gapLength = 5, 154 | this.dotLength = 2, 155 | this.arrowType = EdgeArrowType.one, 156 | this.tipAngle = pi * 0.1, 157 | this.tipLength = 10.0, 158 | }) : this.linePaint = linePaint ?? 159 | (Paint() 160 | ..color = Color(0xFF000000) 161 | ..style = PaintingStyle.stroke 162 | ..strokeCap = StrokeCap.round 163 | ..strokeJoin = StrokeJoin.round 164 | ..strokeWidth = 2); 165 | } 166 | -------------------------------------------------------------------------------- /lib/utils.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:flutter/widgets.dart'; 4 | import 'package:graphite/core/matrix.dart'; 5 | import 'package:graphite/core/typings.dart'; 6 | 7 | double getHighestHeightInARow(Matrix matrix, double defaultCellHeight, int y) { 8 | return matrix.s[y].fold( 9 | 0, 10 | (acc, cell) => max( 11 | acc, 12 | cell == null 13 | ? defaultCellHeight 14 | : cell.all.fold( 15 | 0, 16 | (prev, node) => node.size == null 17 | ? defaultCellHeight 18 | : node.size!.height))); 19 | } 20 | 21 | double getWidestWidthInAColumn(Matrix matrix, double defaultCellWidth, int x) { 22 | double acc = 0; 23 | for (var y = 0; y < matrix.height(); y++) { 24 | final cell = matrix.getByCoords(x, y); 25 | acc = max( 26 | acc, 27 | cell == null 28 | ? defaultCellWidth 29 | : cell.all.fold( 30 | 0, 31 | (prev, node) => 32 | node.size == null ? defaultCellWidth : node.size!.width)); 33 | } 34 | return acc; 35 | } 36 | 37 | double getWidthOfCanvas( 38 | Matrix matrix, double defaultCellWidth, EdgeInsets cellPadding) { 39 | double width = 0.0; 40 | for (int x = 0; x < matrix.width(); x++) { 41 | width += (getWidestWidthInAColumn(matrix, defaultCellWidth, x) + 42 | cellPadding.left + 43 | cellPadding.right); 44 | } 45 | return width; 46 | } 47 | 48 | double getHeightOfCanvas( 49 | Matrix matrix, double defaultCellHeight, EdgeInsets cellPadding) { 50 | double height = 0.0; 51 | for (int y = 0; y < matrix.height(); y++) { 52 | height += (getHighestHeightInARow(matrix, defaultCellHeight, y) + 53 | cellPadding.top + 54 | cellPadding.bottom); 55 | } 56 | return height; 57 | } 58 | 59 | List> getHorizontalLine(List> points) { 60 | for (int i = 0, j = 1; j < points.length; i++, j++) { 61 | final p1 = points[i], p2 = points[j]; 62 | if (p1[1] == p2[1]) return [p1, p2]; 63 | } 64 | return []; 65 | } 66 | 67 | List> getVerticalLine(List> points) { 68 | for (int i = 0, j = 1; j < points.length; i++, j++) { 69 | final p1 = points[i], p2 = points[j]; 70 | if (p1[0] == p2[0]) return [p1, p2]; 71 | } 72 | return []; 73 | } 74 | 75 | List getEdgeMargins(MatrixNode node, MatrixNode income) { 76 | if (node.isAnchor && income.isAnchor) { 77 | return [node.anchorMargin!, income.anchorMargin!]; 78 | } else if (node.isAnchor) { 79 | return [node.anchorMargin!, node.anchorMargin!]; 80 | } else if (income.isAnchor) { 81 | return [income.anchorMargin!, income.anchorMargin!]; 82 | } else { 83 | return [AnchorMargin.none, AnchorMargin.none]; 84 | } 85 | } 86 | 87 | List applyMargin(AnchorMargin margin, List point, 88 | double distance, MatrixOrientation orientation) { 89 | if (margin == AnchorMargin.none) return point; 90 | if (orientation == MatrixOrientation.Horizontal && 91 | margin == AnchorMargin.start) return [point[0] - distance, point[1]]; 92 | if (orientation == MatrixOrientation.Vertical && margin == AnchorMargin.start) 93 | return [point[0], point[1] - distance]; 94 | if (orientation == MatrixOrientation.Horizontal && margin == AnchorMargin.end) 95 | return [point[0] + distance, point[1]]; 96 | if (orientation == MatrixOrientation.Vertical && margin == AnchorMargin.end) 97 | return [point[0], point[1] + distance]; 98 | return point; 99 | } 100 | 101 | enum Direction { top, bottom, left, right } 102 | 103 | double getPaddingFromDirection(EdgeInsets padding, Direction direction) { 104 | switch (direction) { 105 | case Direction.top: 106 | return padding.top; 107 | case Direction.bottom: 108 | return padding.bottom; 109 | case Direction.left: 110 | return padding.left; 111 | case Direction.right: 112 | return padding.right; 113 | } 114 | } 115 | 116 | Direction getXVertexDirection(int x1, int x2) { 117 | return x1 < x2 ? Direction.right : Direction.left; 118 | } 119 | 120 | Direction getYVertexDirection(int y1, int y2) { 121 | return y1 < y2 ? Direction.bottom : Direction.top; 122 | } 123 | 124 | Direction getVectorDirection(int x1, int y1, int x2, int y2) { 125 | return y1 == y2 ? getXVertexDirection(x1, x2) : getYVertexDirection(y1, y2); 126 | } 127 | 128 | double getMargin(AnchorMargin margin, double distance) { 129 | if (margin == AnchorMargin.none) return 0; 130 | return margin == AnchorMargin.start ? -distance : distance; 131 | } 132 | 133 | const pointResolversMap = { 134 | Direction.top: [Direction.top, Direction.bottom], 135 | Direction.bottom: [Direction.bottom, Direction.top], 136 | Direction.right: [Direction.right, Direction.left], 137 | Direction.left: [Direction.left, Direction.right] 138 | }; 139 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | arrow_path: 5 | dependency: "direct main" 6 | description: 7 | name: arrow_path 8 | sha256: "794651f27eca2e9b4749d307b1e7fb8254fb8343124cc24ee6497f3ceff94651" 9 | url: "https://pub.dev" 10 | source: hosted 11 | version: "3.1.0" 12 | async: 13 | dependency: transitive 14 | description: 15 | name: async 16 | sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" 17 | url: "https://pub.dev" 18 | source: hosted 19 | version: "2.11.0" 20 | boolean_selector: 21 | dependency: transitive 22 | description: 23 | name: boolean_selector 24 | sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" 25 | url: "https://pub.dev" 26 | source: hosted 27 | version: "2.1.1" 28 | characters: 29 | dependency: transitive 30 | description: 31 | name: characters 32 | sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" 33 | url: "https://pub.dev" 34 | source: hosted 35 | version: "1.3.0" 36 | clock: 37 | dependency: transitive 38 | description: 39 | name: clock 40 | sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf 41 | url: "https://pub.dev" 42 | source: hosted 43 | version: "1.1.1" 44 | collection: 45 | dependency: transitive 46 | description: 47 | name: collection 48 | sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a 49 | url: "https://pub.dev" 50 | source: hosted 51 | version: "1.18.0" 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_test: 66 | dependency: "direct dev" 67 | description: flutter 68 | source: sdk 69 | version: "0.0.0" 70 | leak_tracker: 71 | dependency: transitive 72 | description: 73 | name: leak_tracker 74 | sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" 75 | url: "https://pub.dev" 76 | source: hosted 77 | version: "10.0.4" 78 | leak_tracker_flutter_testing: 79 | dependency: transitive 80 | description: 81 | name: leak_tracker_flutter_testing 82 | sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" 83 | url: "https://pub.dev" 84 | source: hosted 85 | version: "3.0.3" 86 | leak_tracker_testing: 87 | dependency: transitive 88 | description: 89 | name: leak_tracker_testing 90 | sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" 91 | url: "https://pub.dev" 92 | source: hosted 93 | version: "3.0.1" 94 | matcher: 95 | dependency: transitive 96 | description: 97 | name: matcher 98 | sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb 99 | url: "https://pub.dev" 100 | source: hosted 101 | version: "0.12.16+1" 102 | material_color_utilities: 103 | dependency: transitive 104 | description: 105 | name: material_color_utilities 106 | sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" 107 | url: "https://pub.dev" 108 | source: hosted 109 | version: "0.8.0" 110 | meta: 111 | dependency: transitive 112 | description: 113 | name: meta 114 | sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" 115 | url: "https://pub.dev" 116 | source: hosted 117 | version: "1.12.0" 118 | path: 119 | dependency: transitive 120 | description: 121 | name: path 122 | sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" 123 | url: "https://pub.dev" 124 | source: hosted 125 | version: "1.9.0" 126 | sky_engine: 127 | dependency: transitive 128 | description: flutter 129 | source: sdk 130 | version: "0.0.99" 131 | source_span: 132 | dependency: transitive 133 | description: 134 | name: source_span 135 | sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" 136 | url: "https://pub.dev" 137 | source: hosted 138 | version: "1.10.0" 139 | stack_trace: 140 | dependency: transitive 141 | description: 142 | name: stack_trace 143 | sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" 144 | url: "https://pub.dev" 145 | source: hosted 146 | version: "1.11.1" 147 | stream_channel: 148 | dependency: transitive 149 | description: 150 | name: stream_channel 151 | sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 152 | url: "https://pub.dev" 153 | source: hosted 154 | version: "2.1.2" 155 | string_scanner: 156 | dependency: transitive 157 | description: 158 | name: string_scanner 159 | sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" 160 | url: "https://pub.dev" 161 | source: hosted 162 | version: "1.2.0" 163 | term_glyph: 164 | dependency: transitive 165 | description: 166 | name: term_glyph 167 | sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 168 | url: "https://pub.dev" 169 | source: hosted 170 | version: "1.2.1" 171 | test_api: 172 | dependency: transitive 173 | description: 174 | name: test_api 175 | sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" 176 | url: "https://pub.dev" 177 | source: hosted 178 | version: "0.7.0" 179 | touchable: 180 | dependency: "direct main" 181 | description: 182 | name: touchable 183 | sha256: "50040b39778bb1adc8a480625de8681253bd2134785395cf16abd66bb13d3ed0" 184 | url: "https://pub.dev" 185 | source: hosted 186 | version: "1.0.2" 187 | vector_math: 188 | dependency: transitive 189 | description: 190 | name: vector_math 191 | sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" 192 | url: "https://pub.dev" 193 | source: hosted 194 | version: "2.1.4" 195 | vm_service: 196 | dependency: transitive 197 | description: 198 | name: vm_service 199 | sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" 200 | url: "https://pub.dev" 201 | source: hosted 202 | version: "14.2.1" 203 | sdks: 204 | dart: ">=3.3.0 <4.0.0" 205 | flutter: ">=3.18.0-18.0.pre.54" 206 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: graphite 2 | description: Flutter widget to easily draw direct graphs, trees, flowcharts. Includes gesture API to create graphs interactions. 3 | version: 1.2.1 4 | homepage: https://github.com/lempiy/flutter_graphite 5 | 6 | environment: 7 | sdk: '>=2.17.6 <4.0.0' 8 | 9 | dependencies: 10 | flutter: 11 | sdk: flutter 12 | touchable: ^1.0.2 13 | arrow_path: ^3.1.0 14 | 15 | dev_dependencies: 16 | flutter_test: 17 | sdk: flutter 18 | 19 | # For information on the generic Dart part of this file, see the 20 | # following page: https://dart.dev/tools/pub/pubspec 21 | 22 | # The following section is specific to Flutter. 23 | flutter: 24 | 25 | # To add assets to your package, add an assets section, like this: 26 | # assets: 27 | # - images/a_dot_burr.jpeg 28 | # - images/a_dot_ham.jpeg 29 | # 30 | # For details regarding assets in packages, see 31 | # https://flutter.dev/assets-and-images/#from-packages 32 | # 33 | # An image asset can refer to one or more resolution-specific "variants", see 34 | # https://flutter.dev/assets-and-images/#resolution-aware. 35 | 36 | # To add custom fonts to your package, add a fonts section here, 37 | # in this "flutter" section. Each entry in this list should have a 38 | # "family" key with the font family name, and a "fonts" key with a 39 | # list giving the asset and other descriptors for the font. For 40 | # example: 41 | # fonts: 42 | # - family: Schyler 43 | # fonts: 44 | # - asset: fonts/Schyler-Regular.ttf 45 | # - asset: fonts/Schyler-Italic.ttf 46 | # style: italic 47 | # - family: Trajan Pro 48 | # fonts: 49 | # - asset: fonts/TrajanPro.ttf 50 | # - asset: fonts/TrajanPro_Bold.ttf 51 | # weight: 700 52 | # 53 | # For details regarding fonts in packages, see 54 | # https://flutter.dev/custom-fonts/#from-packages 55 | -------------------------------------------------------------------------------- /test/graphite_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_test/flutter_test.dart'; 2 | import 'package:graphite/core/typings.dart'; 3 | import 'package:graphite/core/graph.dart'; 4 | import 'package:graphite/core/graph_basic.dart'; 5 | 6 | const presetBasic = 7 | '[{"id":"A","next":[{"outcome":"B","type":"one"}]},{"id":"B","next":[{"outcome":"C","type":"one"},{"outcome":"D","type":"one"},{"outcome":"E","type":"one"}]},{"id":"C","next":[{"outcome":"F","type":"one"}]},{"id":"D","next":[{"outcome":"J","type":"one"}]},{"id":"E","next":[{"outcome":"J","type":"one"}]},{"id":"J","next":[{"outcome":"I","type":"one"}]},{"id":"I","next":[{"outcome":"H","type":"one"}]},{"id":"F","next":[{"outcome":"K","type":"one"}]},{"id":"K","next":[{"outcome":"L","type":"one"}]},{"id":"H","next":[{"outcome":"L","type":"one"}]},{"id":"L","next":[{"outcome":"P","type":"one"}]},{"id":"P","next":[{"outcome":"M","type":"one"},{"outcome":"N","type":"one"}]},{"id":"M","next":[]},{"id":"N","next":[]}]'; 8 | const expectBasic = ''' 9 | A │B │C │F │K │ │L │P │M │ 10 | │B-D│D │J │I │H │H-L│P-N│N │ 11 | │B-E│E │E-J│ │ │ │ │ │ 12 | '''; 13 | const expectRotated = ''' 14 | A │ │ │ 15 | B │B-D│B-E│ 16 | C │D │E │ 17 | F │J │E-J│ 18 | K │I │ │ 19 | │H │ │ 20 | L │H-L│ │ 21 | P │P-N│ │ 22 | M │N │ │ 23 | '''; 24 | const presetComplex = 25 | '[{"id":"A","next":[{"outcome":"B","type":"one"}]},{"id":"U","next":[{"outcome":"G","type":"one"}]},{"id":"B","next":[{"outcome":"C","type":"one"},{"outcome":"D","type":"one"},{"outcome":"E","type":"one"},{"outcome":"F","type":"one"},{"outcome":"M","type":"one"}]},{"id":"C","next":[{"outcome":"G","type":"one"}]},{"id":"D","next":[{"outcome":"H","type":"one"}]},{"id":"E","next":[{"outcome":"H","type":"one"}]},{"id":"F","next":[{"outcome":"W","type":"one"},{"outcome":"N","type":"one"},{"outcome":"O","type":"one"}]},{"id":"W","next":[]},{"id":"N","next":[{"outcome":"I","type":"one"}]},{"id":"O","next":[{"outcome":"P","type":"one"}]},{"id":"P","next":[{"outcome":"I","type":"one"}]},{"id":"M","next":[{"outcome":"L","type":"one"}]},{"id":"G","next":[{"outcome":"I","type":"one"}]},{"id":"H","next":[{"outcome":"J","type":"one"}]},{"id":"I","next":[]},{"id":"J","next":[{"outcome":"K","type":"one"}]},{"id":"K","next":[{"outcome":"L","type":"one"}]},{"id":"L","next":[]}]'; 26 | 27 | const expectComplex = ''' 28 | A │B │C │ │ │ │ │G │I │ 29 | │B-D│D │H │J │K │L │ │ │ 30 | │B-E│E │E-H│ │ │ │ │ │ 31 | │B-F│F │W │ │ │ │ │ │ 32 | │ │F-N│N │ │ │ │ │N-I│ 33 | │ │F-O│O │P │ │ │ │P-I│ 34 | │B-M│M │ │ │ │M-L│ │ │ 35 | U │ │ │ │ │ │ │U-G│ │ 36 | '''; 37 | 38 | const expectComplexCentered = ''' 39 | │B-C│C │ │ │ │ │G │G-I│ 40 | │B-D│D │H │J │K │L │ │ │ 41 | A │B │E │E-H│ │ │ │ │ │ 42 | │ │F-W│W │ │ │ │ │ │ 43 | │B-F│F │N │ │ │ │ │I │ 44 | │ │F-O│O │P │ │ │ │P-I│ 45 | │B-M│M │ │ │ │M-L│ │ │ 46 | U │ │ │ │ │ │ │U-G│ │ 47 | '''; 48 | 49 | void main() { 50 | test('basic matrix with splits and joins', () { 51 | List list = nodeInputFromJson(presetBasic); 52 | final mtx = listToMatrix(list, false); 53 | expect(mtx.toString().trim(), expectBasic.trim()); 54 | }); 55 | test('basic matrix rotation', () { 56 | List list = nodeInputFromJson(presetBasic); 57 | final mtx = listToMatrix(list, false); 58 | final rotated = mtx.rotate(); 59 | expect(mtx.toString().trim(), expectBasic.trim()); 60 | expect(rotated.toString().trim(), expectRotated.trim()); 61 | }); 62 | test('complex matrix with splits and joins', () { 63 | List list = nodeInputFromJson(presetComplex); 64 | final mtx = listToMatrix(list, true); 65 | expect(mtx.toString().trim(), expectComplexCentered.trim()); 66 | final mtx2 = listToMatrix(list, false); 67 | expect(mtx2.toString().trim(), expectComplex.trim()); 68 | }); 69 | test('creating graph without matching nodes throws an exception', () { 70 | List list = [ 71 | NodeInput(id: '0', next: [EdgeInput(outcome: '1')]), 72 | NodeInput(id: '1', next: [EdgeInput(outcome: '2')]) 73 | ]; 74 | expect(() => GraphBasic(list: list, centred: false), 75 | throwsA('node 2 not found')); 76 | }); 77 | } 78 | --------------------------------------------------------------------------------