├── .github └── workflows │ └── web.yml ├── .gitignore ├── .metadata ├── LICENSE ├── README.md ├── analysis_options.yaml ├── android ├── .gitignore ├── app │ ├── build.gradle │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── path_finding │ │ │ │ └── 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 ├── a_star.gif ├── bfs.gif ├── dfs.gif ├── dijkstra.gif ├── fonts │ ├── UnitRoundedOT.otf │ └── UnitRoundedOTBold.otf ├── images │ ├── algorithm_choosing.png │ ├── cost_controls.png │ ├── delete_reset.png │ └── time_control.png ├── lotties │ ├── delete.json │ ├── flag_with_sparkle.json │ ├── maze.json │ └── path_finding.json ├── maze.gif ├── svg │ ├── brick.svg │ ├── eraser.svg │ ├── eraser_colored.svg │ ├── flag.svg │ ├── github_logo.svg │ ├── play_button.svg │ ├── route_tracked.svg │ └── stopwatch.svg └── tutorial_controls.gif ├── ios ├── .gitignore ├── Flutter │ ├── AppFrameworkInfo.plist │ ├── Debug.xcconfig │ └── Release.xcconfig ├── Podfile ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── WorkspaceSettings.xcsettings └── Runner │ ├── AppDelegate.swift │ ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── Icon-App-1024x1024@1x.png │ │ ├── Icon-App-20x20@1x.png │ │ ├── Icon-App-20x20@2x.png │ │ ├── Icon-App-20x20@3x.png │ │ ├── Icon-App-29x29@1x.png │ │ ├── Icon-App-29x29@2x.png │ │ ├── Icon-App-29x29@3x.png │ │ ├── Icon-App-40x40@1x.png │ │ ├── Icon-App-40x40@2x.png │ │ ├── Icon-App-40x40@3x.png │ │ ├── Icon-App-60x60@2x.png │ │ ├── Icon-App-60x60@3x.png │ │ ├── Icon-App-76x76@1x.png │ │ ├── Icon-App-76x76@2x.png │ │ └── Icon-App-83.5x83.5@2x.png │ └── LaunchImage.imageset │ │ ├── Contents.json │ │ ├── LaunchImage.png │ │ ├── LaunchImage@2x.png │ │ ├── LaunchImage@3x.png │ │ └── README.md │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ └── Runner-Bridging-Header.h ├── lib ├── common │ ├── models │ │ └── node.dart │ └── utils.dart ├── data │ ├── astar_algorithm.dart │ ├── breadth_first_search.dart │ ├── depth_first_search.dart │ ├── dijkstras_algorithm.dart │ ├── drunk_algorithm.dart │ ├── nodes_repository.dart │ ├── recursive_division_algorithm.dart │ └── visualize_algorithm.dart ├── main.dart ├── notifiers │ ├── animation_time_state_notifier.dart │ ├── diagonal_path_cost_state_notifier.dart │ ├── dragged_states_provider.dart │ ├── horizontal_and_vertical_path_cost_state_notifier.dart │ ├── is_diagonal_movement_enabled_state_provider.dart │ ├── is_learning_mode_on_state_provider.dart │ ├── is_panel_opened_provider.dart │ ├── node_provider.dart │ ├── nodes_state_notifier.dart │ ├── onboarding_page_state_notifier.dart │ ├── selected_action_provider │ │ ├── selected_action.dart │ │ ├── selected_action.freezed.dart │ │ └── selected_action_provider.dart │ └── selected_shortest_path_algorithm_state_notifier.dart └── ui │ ├── colors.dart │ ├── common │ ├── blue_text_button.dart │ ├── playable_lottie │ │ ├── playable_lottie.dart │ │ ├── playable_lottie_asset.dart │ │ ├── playable_lottie_state.dart │ │ └── playable_lottie_state.freezed.dart │ └── text │ │ ├── fonts.dart │ │ ├── texts.dart │ │ └── unit_rounded_text.dart │ └── widgets │ ├── actions_panel │ └── actions_panel.dart │ ├── brick_painter.dart │ ├── onboarding │ ├── onboarding_a_star.dart │ ├── onboarding_algorithms.dart │ ├── onboarding_breadth_first_search.dart │ ├── onboarding_controlls.dart │ ├── onboarding_depth_first_search.dart │ ├── onboarding_dialog.dart │ ├── onboarding_dijkstra.dart │ ├── onboarding_play_algorithm.dart │ └── onboarding_welcome.dart │ ├── panel │ ├── algorithm_button_picker.dart │ ├── panel.dart │ ├── panel_body.dart │ ├── panel_sliding.dart │ ├── reset_buttons.dart │ └── sliders.dart │ ├── square.dart │ ├── url_launchable_title.dart │ └── world.dart ├── linux ├── .gitignore ├── CMakeLists.txt ├── flutter │ ├── CMakeLists.txt │ ├── generated_plugin_registrant.cc │ ├── generated_plugin_registrant.h │ └── generated_plugins.cmake ├── main.cc ├── my_application.cc └── my_application.h ├── macos ├── .gitignore ├── Flutter │ ├── Flutter-Debug.xcconfig │ ├── Flutter-Release.xcconfig │ └── GeneratedPluginRegistrant.swift ├── Podfile ├── Podfile.lock ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── Runner │ ├── AppDelegate.swift │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── app_icon_1024.png │ │ ├── app_icon_128.png │ │ ├── app_icon_16.png │ │ ├── app_icon_256.png │ │ ├── app_icon_32.png │ │ ├── app_icon_512.png │ │ └── app_icon_64.png │ ├── Base.lproj │ └── MainMenu.xib │ ├── Configs │ ├── AppInfo.xcconfig │ ├── Debug.xcconfig │ ├── Release.xcconfig │ └── Warnings.xcconfig │ ├── DebugProfile.entitlements │ ├── Info.plist │ ├── MainFlutterWindow.swift │ └── Release.entitlements ├── pubspec.lock ├── pubspec.yaml ├── test └── widget_test.dart ├── web ├── favicon.png ├── icons │ ├── Icon-192.png │ ├── Icon-512.png │ ├── Icon-maskable-192.png │ └── Icon-maskable-512.png ├── index.html └── manifest.json └── windows ├── .gitignore ├── CMakeLists.txt ├── flutter ├── CMakeLists.txt ├── generated_plugin_registrant.cc ├── generated_plugin_registrant.h └── generated_plugins.cmake └── runner ├── CMakeLists.txt ├── Runner.rc ├── flutter_window.cpp ├── flutter_window.h ├── main.cpp ├── resource.h ├── resources └── app_icon.ico ├── runner.exe.manifest ├── utils.cpp ├── utils.h ├── win32_window.cpp └── win32_window.h /.github/workflows/web.yml: -------------------------------------------------------------------------------- 1 | name: Gh-Pages 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - uses: actions/checkout@v2 # Only works with v2 13 | - uses: subosito/flutter-action@v1 14 | - uses: bluefireteam/flutter-gh-pages@v7 15 | with: 16 | baseHref: /flutter_algorithms_visualization/ -------------------------------------------------------------------------------- /.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 | # VSCode releated 20 | .vscode 21 | 22 | # The .vscode folder contains launch configuration and tasks you configure in 23 | # VS Code which you may wish to be included in version control, so this line 24 | # is commented out by default. 25 | #.vscode/ 26 | 27 | # Flutter/Dart/Pub related 28 | **/doc/api/ 29 | **/ios/Flutter/.last_build_id 30 | .dart_tool/ 31 | .flutter-plugins 32 | .flutter-plugins-dependencies 33 | .packages 34 | .pub-cache/ 35 | .pub/ 36 | /build/ 37 | 38 | # Web related 39 | 40 | # Symbolication related 41 | app.*.symbols 42 | 43 | # Obfuscation related 44 | app.*.map.json 45 | 46 | # Android Studio will place build artifacts here 47 | /android/app/debug 48 | /android/app/profile 49 | /android/app/release 50 | -------------------------------------------------------------------------------- /.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: f1875d570e39de09040c8f79aa13cc56baab8db1 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: f1875d570e39de09040c8f79aa13cc56baab8db1 17 | base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 18 | - platform: android 19 | create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 20 | base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 21 | - platform: ios 22 | create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 23 | base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 24 | - platform: linux 25 | create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 26 | base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 27 | - platform: macos 28 | create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 29 | base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 30 | - platform: web 31 | create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 32 | base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 33 | - platform: windows 34 | create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 35 | base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 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 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Ivan Štajcer 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 | ## Algorithm visualization with Flutter & Dart 2 | 3 | This project aims to visualize different algorithms using Flutter in & Dart. Starting from path finding algorithms, but wishing to go further to arrays, trees, graphs... 4 | 5 | Feel free to contribute by opening some PR's :fire: 6 | 7 | ![](https://github.com/igniti0n/flutter_algorithms_visualization/blob/main/assets/dijkstra.gif) 8 | ![](https://github.com/igniti0n/flutter_algorithms_visualization/blob/main/assets/a_star.gif) 9 | ![](https://github.com/igniti0n/flutter_algorithms_visualization/blob/main/assets/maze.gif) 10 | 11 | # Learning 12 | 13 | Dijkstra's algorithm explained, with the help of this visualization project 14 | 15 | [https://github.com/igniti0n/flutter_algorithms_visualization](https://medium.com/p/32b73722406a) 16 | 17 | A* algorithm explained 18 | 19 | https://www.youtube.com/watch?v=ySN5Wnu88nE 20 | 21 | # Ideas :sparkles: 22 | 23 | - :white_check_mark: Add time control, to increase/decrease time step 24 | - :white_check_mark: Enable/disable diagonal nodes 25 | - :white_check_mark: DFS/BFS 26 | - :white_square_button: Ability to move the end/start node and see the change 27 | - :white_square_button: Impmenent sorting of nodes with heap rather then sorting a list for Dijkstra/A* 28 | - :white_check_mark: Maze generator 29 | 30 | 31 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | 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.path_finding" 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 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 15 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/example/path_finding/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.path_finding 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip 7 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /assets/a_star.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/assets/a_star.gif -------------------------------------------------------------------------------- /assets/bfs.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/assets/bfs.gif -------------------------------------------------------------------------------- /assets/dfs.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/assets/dfs.gif -------------------------------------------------------------------------------- /assets/dijkstra.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/assets/dijkstra.gif -------------------------------------------------------------------------------- /assets/fonts/UnitRoundedOT.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/assets/fonts/UnitRoundedOT.otf -------------------------------------------------------------------------------- /assets/fonts/UnitRoundedOTBold.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/assets/fonts/UnitRoundedOTBold.otf -------------------------------------------------------------------------------- /assets/images/algorithm_choosing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/assets/images/algorithm_choosing.png -------------------------------------------------------------------------------- /assets/images/cost_controls.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/assets/images/cost_controls.png -------------------------------------------------------------------------------- /assets/images/delete_reset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/assets/images/delete_reset.png -------------------------------------------------------------------------------- /assets/images/time_control.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/assets/images/time_control.png -------------------------------------------------------------------------------- /assets/maze.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/assets/maze.gif -------------------------------------------------------------------------------- /assets/svg/brick.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/eraser.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/eraser_colored.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/flag.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/github_logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/play_button.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/route_tracked.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 12 | 16 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /assets/svg/stopwatch.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | stopwatch 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /assets/tutorial_controls.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/assets/tutorial_controls.gif -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 9.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '11.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | end 36 | 37 | post_install do |installer| 38 | installer.pods_project.targets.each do |target| 39 | flutter_additional_ios_build_settings(target) 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.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 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Path Finding 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | path_finding 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 | 49 | 50 | -------------------------------------------------------------------------------- /ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /lib/common/models/node.dart: -------------------------------------------------------------------------------- 1 | import 'package:uuid/uuid.dart'; 2 | 3 | class NodeCoordinate { 4 | final int x; 5 | final int y; 6 | NodeCoordinate(this.x, this.y); 7 | } 8 | 9 | class Node { 10 | final String id = const Uuid().v4(); 11 | final int x; 12 | final int y; 13 | bool isGoalNode; 14 | bool isInStack; 15 | bool isTopPriority; 16 | bool isStart; 17 | bool isOnTraceablePathToGoal; 18 | bool isWall; 19 | bool isVisited; 20 | bool isCurrentlyBeingVisited; 21 | double currentPathCost; 22 | double distanceToGoal = 0; 23 | Node? cameFromNode; 24 | 25 | Node({ 26 | this.isGoalNode = false, 27 | required this.x, 28 | required this.y, 29 | this.isVisited = false, 30 | this.isStart = false, 31 | this.isWall = false, 32 | this.isInStack = false, 33 | this.isTopPriority = false, 34 | this.currentPathCost = double.infinity, 35 | this.isOnTraceablePathToGoal = false, 36 | this.cameFromNode, 37 | this.isCurrentlyBeingVisited = false, 38 | }); 39 | 40 | void updateCostIfNecessary(double calculatedCost) { 41 | if (currentPathCost > calculatedCost) { 42 | currentPathCost = calculatedCost; 43 | } 44 | } 45 | 46 | Node copyWith({ 47 | bool? isGoalNode = false, 48 | int? x, 49 | int? y, 50 | bool? isVisited, 51 | bool? isOnTraceablePathToGoal, 52 | bool? isWall, 53 | double? currentCost, 54 | Node? cameFromNode, 55 | bool? isStart, 56 | bool? isInStack, 57 | bool? isTopPriority, 58 | bool? isCurrentlyBeingVisited, 59 | }) => 60 | Node( 61 | x: x ?? this.x, 62 | y: y ?? this.y, 63 | isGoalNode: isGoalNode ?? this.isGoalNode, 64 | isVisited: isVisited ?? this.isVisited, 65 | isWall: isWall ?? this.isWall, 66 | currentPathCost: currentCost ?? currentPathCost, 67 | isStart: isStart ?? this.isStart, 68 | isInStack: isInStack ?? this.isInStack, 69 | isTopPriority: isTopPriority ?? this.isTopPriority, 70 | isCurrentlyBeingVisited: 71 | isCurrentlyBeingVisited ?? this.isCurrentlyBeingVisited, 72 | isOnTraceablePathToGoal: 73 | isOnTraceablePathToGoal ?? this.isOnTraceablePathToGoal, 74 | ); 75 | 76 | bool isDifferent(Node node) => 77 | node.isWall != isWall || 78 | node.x != x || 79 | node.y != y || 80 | node.isStart != isStart || 81 | node.isVisited != isVisited || 82 | node.isOnTraceablePathToGoal != isOnTraceablePathToGoal || 83 | node.isInStack != isInStack || 84 | node.currentPathCost != currentPathCost || 85 | node.isGoalNode != isGoalNode || 86 | node.isCurrentlyBeingVisited != isCurrentlyBeingVisited || 87 | node.isTopPriority != isTopPriority; 88 | 89 | bool get isGoalNodeAndFound => isGoalNode && isOnTraceablePathToGoal; 90 | 91 | bool get isIdle => 92 | !isGoalNode && 93 | !isVisited && 94 | !isWall && 95 | !isOnTraceablePathToGoal && 96 | !isInStack && 97 | !isCurrentlyBeingVisited && 98 | !isTopPriority; 99 | 100 | void reset() { 101 | isGoalNode = false; 102 | isVisited = false; 103 | isWall = false; 104 | isStart = false; 105 | isInStack = false; 106 | isTopPriority = false; 107 | isCurrentlyBeingVisited = false; 108 | currentPathCost = double.infinity; 109 | isOnTraceablePathToGoal = false; 110 | cameFromNode = null; 111 | } 112 | 113 | void resetVisualAlgorithmSteps() { 114 | isVisited = false; 115 | currentPathCost = double.infinity; 116 | isOnTraceablePathToGoal = false; 117 | isInStack = false; 118 | isTopPriority = false; 119 | isCurrentlyBeingVisited = false; 120 | cameFromNode = null; 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /lib/common/utils.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math' as math; 2 | 3 | import 'package:path_finding/common/models/node.dart'; 4 | 5 | double calculateDistance(startX, startY, endX, endY) { 6 | final distX = (startX - endX).abs(); 7 | final distY = (startY - endY).abs(); 8 | return math.sqrt(distX * distX + distY * distY); 9 | } 10 | 11 | bool isNodeOnDiagonal( 12 | {required Node currentlyLookingNode, required Node parentNode}) => 13 | isNodeOnDiagonalForCoordinates( 14 | startX: currentlyLookingNode.x, 15 | startY: currentlyLookingNode.y, 16 | endX: parentNode.x, 17 | endY: parentNode.y); 18 | 19 | bool isNodeOnDiagonalForCoordinates({ 20 | required int startX, 21 | required int startY, 22 | required int endX, 23 | required int endY, 24 | }) => 25 | (endX != startX && endY != startY); 26 | -------------------------------------------------------------------------------- /lib/data/astar_algorithm.dart: -------------------------------------------------------------------------------- 1 | import 'package:path_finding/common/models/node.dart'; 2 | import 'package:path_finding/common/utils.dart'; 3 | import 'package:path_finding/data/dijkstras_algorithm.dart'; 4 | 5 | class AstarAlgorithm extends DijkstraAlgorithm { 6 | AstarAlgorithm({required super.onStepUpdate, super.nodesToStartWith}); 7 | 8 | @override 9 | Future visitNode(Node currentlyLookingNode, Node parentNode) async { 10 | // Calculate cost to go to node 11 | final isOnDiagonal = isNodeOnDiagonal(currentlyLookingNode: currentlyLookingNode, parentNode: parentNode); 12 | var costToGoToNode = parentNode.currentPathCost + (isOnDiagonal ? diagonalPathCost : horizontalAndVerticalPathCost); 13 | // Calculate distance to goal, and save it in the node 14 | final distanceToGoalNode = 15 | calculateDistance(currentlyLookingNode.x, currentlyLookingNode.y, goalNode.x, goalNode.y); 16 | allNodes[currentlyLookingNode.x][currentlyLookingNode.y].distanceToGoal = distanceToGoalNode * 10; 17 | // only the path cost is being looked for when moving to the node 18 | if (costToGoToNode < currentlyLookingNode.currentPathCost) { 19 | currentlyLookingNode.currentPathCost = costToGoToNode; 20 | currentlyLookingNode.cameFromNode = parentNode; 21 | nodesStack.add(currentlyLookingNode); 22 | } 23 | } 24 | 25 | // distance to goal is taken into account when prioritizing what node to look at next 26 | @override 27 | void sortNodesStackAfterOneTurn(List nodesStack) { 28 | nodesStack.sort( 29 | (a, b) => (b.currentPathCost + b.distanceToGoal).compareTo(a.currentPathCost + a.distanceToGoal), 30 | ); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/data/breadth_first_search.dart: -------------------------------------------------------------------------------- 1 | import 'package:path_finding/common/models/node.dart'; 2 | import 'package:path_finding/common/utils.dart'; 3 | import 'package:path_finding/data/visualize_algorithm.dart'; 4 | 5 | class BreadthFirstSearch extends VisualizeAlgorithm { 6 | BreadthFirstSearch({required super.onStepUpdate, super.nodesToStartWith}); 7 | int lowerHorizontalBoundary = 0; 8 | int upperHorizontalBoundary = 0; 9 | 10 | @override 11 | Future algorithmImplementation(Node startNode) async { 12 | lowerHorizontalBoundary = 0; 13 | upperHorizontalBoundary = allNodes.length; 14 | final goalNodeX = goalNode.x; 15 | if (goalNodeX <= startNode.x) { 16 | lowerHorizontalBoundary = startNode.x + 1; 17 | } else { 18 | upperHorizontalBoundary = startNode.x - 1; 19 | } 20 | while (nodesStack.isNotEmpty) { 21 | await doBFS(); 22 | } 23 | } 24 | 25 | Future doBFS() async { 26 | final node = nodesStack.removeAt(0); 27 | for (var j = node.y - 1; j <= node.y + 1; j++) { 28 | for (var i = node.x - 1; i <= node.x + 1; i++) { 29 | if (!isRunning) { 30 | return; 31 | } 32 | if (shouldIgnoreNode(i, j, node)) { 33 | continue; 34 | } 35 | final currentlyLookingNode = allNodes[i][j]; 36 | currentlyLookingNode.cameFromNode = node; 37 | if (currentlyLookingNode.isGoalNode) { 38 | await showShortestPath(currentlyLookingNode); 39 | isRunning = false; 40 | return; 41 | } else { 42 | currentlyLookingNode.isVisited = true; 43 | await showUpdatedNodes(); 44 | nodesStack.add(currentlyLookingNode); 45 | } 46 | } 47 | } 48 | } 49 | 50 | bool shouldIgnoreNode(int i, int j, Node node) { 51 | if (isNodeParentNodeOrOutsideOfBounds(i: i, j: j, parentNode: node)) { 52 | return true; 53 | } 54 | if (isNodeOnDiagonalForCoordinates(startX: i, startY: j, endX: node.x, endY: node.y)) { 55 | return true; 56 | } 57 | if (i >= lowerHorizontalBoundary && i <= upperHorizontalBoundary) { 58 | return true; 59 | } 60 | if (isNodeWallOrDone(node: allNodes[i][j])) { 61 | return true; 62 | } 63 | if (allNodes[i][j].isVisited) { 64 | return true; 65 | } 66 | return false; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /lib/data/depth_first_search.dart: -------------------------------------------------------------------------------- 1 | import 'package:path_finding/common/models/node.dart'; 2 | import 'package:path_finding/common/utils.dart'; 3 | import 'package:path_finding/data/visualize_algorithm.dart'; 4 | 5 | class DepthFirstSearch extends VisualizeAlgorithm { 6 | DepthFirstSearch({required super.onStepUpdate, super.nodesToStartWith}); 7 | int lowerHorizontalBoundary = 0; 8 | int upperHorizontalBoundary = 0; 9 | 10 | @override 11 | Future algorithmImplementation(Node startNode) async { 12 | lowerHorizontalBoundary = 0; 13 | upperHorizontalBoundary = allNodes[0].length; 14 | final goalNodeX = goalNode.x; 15 | if (goalNodeX <= startNode.x) { 16 | lowerHorizontalBoundary = startNode.x + 1; 17 | } else { 18 | upperHorizontalBoundary = startNode.x - 1; 19 | } 20 | await doDFS(startNode); 21 | } 22 | 23 | Future doDFS(Node node) async { 24 | for (var j = node.y - 1; j <= node.y + 1; j++) { 25 | for (var i = node.x - 1; i <= node.x + 1; i++) { 26 | if (!isRunning) { 27 | return; 28 | } 29 | if (shouldIgnoreNode(i, j, node)) { 30 | continue; 31 | } 32 | 33 | final currentlyLookingNode = allNodes[i][j]; 34 | currentlyLookingNode.cameFromNode = node; 35 | if (currentlyLookingNode.isGoalNode) { 36 | await showShortestPath(currentlyLookingNode); 37 | isRunning = false; 38 | return; 39 | } else { 40 | currentlyLookingNode.isVisited = true; 41 | await showUpdatedNodes(); 42 | await doDFS(allNodes[i][j]); 43 | } 44 | } 45 | } 46 | } 47 | 48 | bool shouldIgnoreNode(int i, int j, Node node) { 49 | if (isNodeParentNodeOrOutsideOfBounds(i: i, j: j, parentNode: node)) { 50 | return true; 51 | } 52 | if (isNodeOnDiagonalForCoordinates(startX: i, startY: j, endX: node.x, endY: node.y)) { 53 | return true; 54 | } 55 | if (i >= lowerHorizontalBoundary && i <= upperHorizontalBoundary) { 56 | return true; 57 | } 58 | if (isNodeWallOrDone(node: allNodes[i][j])) { 59 | return true; 60 | } 61 | if (allNodes[i][j].isVisited) { 62 | return true; 63 | } 64 | return false; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /lib/data/dijkstras_algorithm.dart: -------------------------------------------------------------------------------- 1 | import 'dart:developer'; 2 | 3 | import 'package:path_finding/common/models/node.dart'; 4 | import 'package:path_finding/common/utils.dart'; 5 | import 'package:path_finding/data/nodes_repository.dart'; 6 | import 'package:path_finding/data/visualize_algorithm.dart'; 7 | 8 | /// Defines what a path finding algorithm needs and tools to visualize it 9 | class DijkstraAlgorithm extends VisualizeAlgorithm { 10 | DijkstraAlgorithm({ 11 | required Function(NodesArray nodes) onStepUpdate, 12 | List>? nodesToStartWith, 13 | }) : super(onStepUpdate: onStepUpdate, nodesToStartWith: nodesToStartWith); 14 | 15 | /// Assembles core steps of a path finding algorithm, based on the starting point 16 | @override 17 | Future algorithmImplementation(Node startNode) async { 18 | while (true) { 19 | if (!isRunning) { 20 | resetAlgorithmToStart(); 21 | break; 22 | } 23 | if (nodesStack.isEmpty) { 24 | log('Stack is empty, done!'); 25 | break; 26 | } 27 | final currentNode = nodesStack.removeAt(nodesStack.length - 1); 28 | if (currentNode.isGoalNode == true) { 29 | log('Found shortest path! At: ${currentNode.x} - ${currentNode.y}'); 30 | await showShortestPath(currentNode); 31 | return; 32 | } 33 | await goThroughChildren(currentNode); 34 | sortNodesStackAfterOneTurn(nodesStack); 35 | nodesStack.last.isTopPriority = true; 36 | 37 | await showUpdatedNodes(); 38 | } 39 | } 40 | 41 | /// Goes through all children of the node, so all the neighbors. 42 | /// Skips any node that is a wall, a parent node and if currently looking at a child node is already done 43 | Future goThroughChildren(Node parentNode) async { 44 | final nodeX = parentNode.x; 45 | final nodeY = parentNode.y; 46 | 47 | for (int i = nodeX - 1; i <= (nodeX + 1); i++) { 48 | for (int j = nodeY - 1; j <= (nodeY + 1); j++) { 49 | if (isNodeParentNodeOrOutsideOfBounds(i: i, j: j, parentNode: parentNode)) { 50 | continue; 51 | } 52 | final currentlyLookingNode = allNodes[i][j]; 53 | if (isNodeWallOrDone(node: currentlyLookingNode)) { 54 | continue; 55 | } 56 | final isOnDiagonal = isNodeOnDiagonal(currentlyLookingNode: currentlyLookingNode, parentNode: parentNode); 57 | if (isOnDiagonal && !isDiagonalMovementEnabled) { 58 | continue; 59 | } 60 | // currentlyLookingNode.isCurrentlyBeingVisited = true; 61 | // await showUpdatedNodes(); 62 | visitNode(currentlyLookingNode, parentNode); 63 | // currentlyLookingNode.isCurrentlyBeingVisited = false; 64 | // await showUpdatedNodes(); 65 | } 66 | } 67 | doneNodes.add(parentNode); 68 | allNodes[nodeX][nodeY].isVisited = true; 69 | } 70 | 71 | /// Evaluates the cost to go to the [Node], and updates it if cost is better then the already calculated one 72 | void visitNode(Node currentlyLookingNode, Node parentNode) { 73 | final isOnDiagonal = isNodeOnDiagonal(currentlyLookingNode: currentlyLookingNode, parentNode: parentNode); 74 | var costToGoToNode = parentNode.currentPathCost + (isOnDiagonal ? diagonalPathCost : horizontalAndVerticalPathCost); 75 | // only the path cost is being look for when moving to the node 76 | if (costToGoToNode < currentlyLookingNode.currentPathCost) { 77 | currentlyLookingNode.currentPathCost = costToGoToNode; 78 | currentlyLookingNode.cameFromNode = parentNode; 79 | nodesStack.add(currentlyLookingNode); 80 | currentlyLookingNode.isInStack = true; 81 | } 82 | } 83 | 84 | void sortNodesStackAfterOneTurn(List nodesStack) { 85 | nodesStack.sort( 86 | (a, b) => (b.currentPathCost).compareTo(a.currentPathCost), 87 | ); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /lib/data/drunk_algorithm.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:path_finding/common/models/node.dart'; 4 | import 'package:path_finding/data/dijkstras_algorithm.dart'; 5 | 6 | class DrunkAlgorithm extends DijkstraAlgorithm { 7 | DrunkAlgorithm({required super.onStepUpdate, super.nodesToStartWith}); 8 | 9 | /// Evaluates the cost to go to the [Node], and updates it if cost is better then the already calculated one 10 | @override 11 | Future visitNode(Node currentlyLookingNode, Node parentNode) async { 12 | var costToGoToNode = Random().nextDouble() * 10; 13 | // only the path cost is being look for when moving to the node 14 | if (costToGoToNode < currentlyLookingNode.currentPathCost) { 15 | currentlyLookingNode.currentPathCost = costToGoToNode; 16 | currentlyLookingNode.cameFromNode = parentNode; 17 | nodesStack.add(currentlyLookingNode); 18 | } 19 | } 20 | 21 | @override 22 | void sortNodesStackAfterOneTurn(List nodesStack) { 23 | nodesStack.sort( 24 | (a, b) => (b.currentPathCost).compareTo(a.currentPathCost), 25 | ); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lib/data/recursive_division_algorithm.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import '../common/models/node.dart'; 4 | 5 | /// Algo works like this: 6 | /// - Slice V or H 7 | /// - Take a random point to slice the array V or H with a wall 8 | /// - Take a random point to make a gap in the wall 9 | /// - Make wall V or H at the chosen point, leave a gap in the wall 10 | /// - Make corrections if the wall is blocking any previously created passages 11 | /// - Repeat for the both slices of arrays 12 | Future recursiveDivisionMazeGenerate(List> allNodes, int xLow, int xHigh, int yLow, int yHigh, 13 | void Function({int? overriddenAnimationDelayInMilliseconds}) showUpdates) async { 14 | final random = Random(); 15 | final xLength = xHigh - xLow; 16 | final yLength = yHigh - yLow; 17 | final isCutVertical = xLength > yLength; 18 | if (xLength < 2 || yLength < 2 || xLength == 2 && yLength == 2) { 19 | return; 20 | } 21 | await Future.delayed(const Duration(milliseconds: 300)); 22 | showUpdates.call(); 23 | 24 | final xPoint = (xLow + random.nextInt((xHigh - xLow) ~/ 2)).clamp(xLow + 1, xHigh - 1); 25 | final yPoint = (yLow + random.nextInt((yHigh - yLow) ~/ 2)).clamp(yLow + 1, yHigh - 1); 26 | 27 | if (isCutVertical) { 28 | // Make vertical wall with a random gap 29 | for (var y = yLow; y < yHigh; y++) { 30 | if (y != yPoint) { 31 | allNodes[xPoint][y].isWall = true; 32 | } 33 | } 34 | // Unblock any previously created passages 35 | final isTopOnPassage = allNodes[xPoint][yLow - 1].isWall == false; 36 | final isBottomOnPassage = allNodes[xPoint][yHigh].isWall == false; 37 | if ((isTopOnPassage || isBottomOnPassage) && yLength > 2) { 38 | allNodes[xPoint][yPoint].isWall = true; 39 | } 40 | if (isTopOnPassage) { 41 | allNodes[xPoint][yLow].isWall = false; 42 | } 43 | if (isBottomOnPassage) { 44 | allNodes[xPoint][yHigh - 1].isWall = false; 45 | } 46 | // Repeat for the splitted arrays 47 | recursiveDivisionMazeGenerate(allNodes, xLow, xPoint, yLow, yHigh, showUpdates); 48 | recursiveDivisionMazeGenerate(allNodes, xPoint + 1, xHigh, yLow, yHigh, showUpdates); 49 | } else { 50 | // Make horizontal wall with a random gap 51 | for (var x = xLow; x < xHigh; x++) { 52 | if (x != xPoint) { 53 | allNodes[x][yPoint].isWall = true; 54 | } 55 | } 56 | // Unblock any previously created passages 57 | final isLeftOnPassage = allNodes[xLow - 1][yPoint].isWall == false; 58 | final isRightOnPassage = allNodes[xHigh][yPoint].isWall == false; 59 | if ((isLeftOnPassage || isRightOnPassage) && xLength > 2) { 60 | allNodes[xPoint][yPoint].isWall = true; 61 | } 62 | if (isLeftOnPassage) { 63 | allNodes[xLow][yPoint].isWall = false; 64 | } 65 | if (isRightOnPassage) { 66 | allNodes[xHigh - 1][yPoint].isWall = false; 67 | } 68 | // Repeat for the splitted arrays 69 | recursiveDivisionMazeGenerate(allNodes, xLow, xHigh, yLow, yPoint, showUpdates); 70 | recursiveDivisionMazeGenerate(allNodes, xLow, xHigh, yPoint + 1, yHigh, showUpdates); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:path_finding/ui/widgets/world.dart'; 4 | 5 | void main() { 6 | runApp(const MyApp()); 7 | } 8 | 9 | class MyApp extends StatelessWidget { 10 | const MyApp({Key? key}) : super(key: key); 11 | 12 | @override 13 | Widget build(BuildContext context) { 14 | return ProviderScope( 15 | child: MaterialApp( 16 | title: 'Path Finding Demo', 17 | theme: ThemeData( 18 | primarySwatch: Colors.blue, 19 | ), 20 | home: const World(), 21 | ), 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/notifiers/animation_time_state_notifier.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 2 | import 'package:path_finding/data/nodes_repository.dart'; 3 | 4 | final animationTimeStateNotifierProvider = 5 | StateNotifierProvider( 6 | (ref) => AnimationTimeNotifier(ref.read(nodesRepositoryProvider))); 7 | 8 | class AnimationTimeNotifier extends StateNotifier { 9 | final NodesRepository _nodesRepository; 10 | AnimationTimeNotifier(this._nodesRepository) : super(1350) { 11 | setAnimationTimeDelay(1350); 12 | } 13 | 14 | void setAnimationTimeDelay(int milliseconds) async { 15 | _nodesRepository.setAnimationTimeDelayTo(milliseconds: milliseconds); 16 | state = milliseconds; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lib/notifiers/diagonal_path_cost_state_notifier.dart: -------------------------------------------------------------------------------- 1 | import 'package:path_finding/data/nodes_repository.dart'; 2 | import 'package:riverpod/riverpod.dart'; 3 | 4 | final diagonalPathCostStateNotifierProvider = 5 | StateNotifierProvider( 6 | (ref) => NodesNotifier(ref.read(nodesRepositoryProvider))); 7 | 8 | class NodesNotifier extends StateNotifier { 9 | final NodesRepository _nodesRepository; 10 | NodesNotifier(this._nodesRepository) : super(2); 11 | 12 | void setDiagonalCost(double cost) async { 13 | _nodesRepository.setDiagonalPathCostTo(cost: cost); 14 | state = cost; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/notifiers/dragged_states_provider.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 2 | 3 | final isGoalDraggedStateProvider = StateProvider((ref) => false); 4 | 5 | final isStartDraggedStateProvider = StateProvider((ref) => false); 6 | -------------------------------------------------------------------------------- /lib/notifiers/horizontal_and_vertical_path_cost_state_notifier.dart: -------------------------------------------------------------------------------- 1 | import 'package:path_finding/data/nodes_repository.dart'; 2 | import 'package:riverpod/riverpod.dart'; 3 | 4 | final horizontalAndVerticalPathCostStateNotifierProvider = 5 | StateNotifierProvider( 6 | (ref) => NodesNotifier(ref.read(nodesRepositoryProvider))); 7 | 8 | class NodesNotifier extends StateNotifier { 9 | final NodesRepository _nodesRepository; 10 | NodesNotifier(this._nodesRepository) : super(1); 11 | 12 | void setHorizontalPathCost(double cost) async { 13 | _nodesRepository.setHorizontalAndVerticalPathCostTo(cost: cost); 14 | state = cost; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/notifiers/is_diagonal_movement_enabled_state_provider.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 2 | 3 | final isDiagonalMovementEnableStateProvider = StateProvider( 4 | (ref) => false, 5 | ); 6 | -------------------------------------------------------------------------------- /lib/notifiers/is_learning_mode_on_state_provider.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 2 | 3 | final isLearningModeOnStateProvider = StateProvider((ref) => false); 4 | -------------------------------------------------------------------------------- /lib/notifiers/is_panel_opened_provider.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 2 | 3 | final isPanelOpenedProvider = StateProvider((ref) => false); 4 | -------------------------------------------------------------------------------- /lib/notifiers/node_provider.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 2 | import 'package:path_finding/common/models/node.dart'; 3 | import 'package:path_finding/notifiers/nodes_state_notifier.dart'; 4 | 5 | final nodeProvider = 6 | StateProvider.family((ref, coordinates) { 7 | final nodes = ref.watch(nodesStateNotifierProvider); 8 | final node = nodes.elementAt(coordinates.x).elementAt(coordinates.y); 9 | final someNode = node.copyWith( 10 | x: node.x, 11 | y: node.y, 12 | isGoalNode: node.isGoalNode, 13 | isWall: node.isWall, 14 | isVisited: node.isVisited, 15 | isStart: node.isStart, 16 | isOnTraceablePathToGoal: node.isOnTraceablePathToGoal, 17 | cameFromNode: node.cameFromNode, 18 | isInStack: node.isInStack, 19 | isCurrentlyBeingVisited: node.isCurrentlyBeingVisited, 20 | isTopPriority: node.isTopPriority); 21 | return someNode; 22 | }); 23 | -------------------------------------------------------------------------------- /lib/notifiers/nodes_state_notifier.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:path_finding/data/nodes_repository.dart'; 4 | import 'package:path_finding/notifiers/is_diagonal_movement_enabled_state_provider.dart'; 5 | import 'package:riverpod/riverpod.dart'; 6 | 7 | final nodesStateNotifierProvider = 8 | StateNotifierProvider((ref) => NodesNotifier(ref.read(nodesRepositoryProvider), ref)); 9 | 10 | class NodesNotifier extends StateNotifier { 11 | final NodesRepository _nodesRepository; 12 | final Ref _ref; 13 | late final StreamSubscription _nodesUpdateSubscription; 14 | NodesNotifier( 15 | this._nodesRepository, 16 | this._ref, 17 | ) : super([]) { 18 | state = _nodesRepository.allNodes; 19 | _nodesUpdateSubscription = _nodesRepository.nodesArrayUpdateStream.listen(_onNodesArrayUpdate); 20 | _ref.listen( 21 | isDiagonalMovementEnableStateProvider, 22 | (_, isDiagonalMovementEnabled) => 23 | _nodesRepository.setIsDiagonalMovementEnabled(toValue: isDiagonalMovementEnabled), 24 | ); 25 | setWallAt(0, 0); 26 | resetAt(0, 0); 27 | } 28 | 29 | @override 30 | void dispose() { 31 | _nodesUpdateSubscription.cancel(); 32 | super.dispose(); 33 | } 34 | 35 | NodesArray getAllNodes() => _nodesRepository.allNodes; 36 | 37 | void _onNodesArrayUpdate(NodesArray updatedArray) { 38 | state = []; 39 | state = updatedArray; 40 | } 41 | 42 | void init({required int numberOfNodesInRow, required int numberOfNodesInColumn}) => 43 | _nodesRepository.init(numberOfNodesInRow: numberOfNodesInRow, numberOfNodesInColumn: numberOfNodesInColumn); 44 | 45 | Future startAlgorithmAt() async => _nodesRepository.startAlgorithmAt(); 46 | 47 | Future makeMaze() async => _nodesRepository.makeMaze(); 48 | 49 | void setGoalAt(int x, int y) async => _nodesRepository.setGoalAt(x, y); 50 | 51 | void removeGoalAt(int x, int y) async => _nodesRepository.removeGoalAt(x, y); 52 | 53 | void setStartAt(int x, int y) async => _nodesRepository.setStartAt(x, y); 54 | 55 | void removeStartAt(int x, int y) async => _nodesRepository.removeStartAt(x, y); 56 | 57 | void setWallAt(int x, int y) async => _nodesRepository.setWallAt(x, y); 58 | 59 | void resetAt(int x, int y) async => _nodesRepository.resetAt(x, y); 60 | 61 | void resetAll() async => _nodesRepository.resetAll(); 62 | 63 | void resetAlgorithmToStart() async => _nodesRepository.resetAlgorithmToStart(); 64 | } 65 | -------------------------------------------------------------------------------- /lib/notifiers/onboarding_page_state_notifier.dart: -------------------------------------------------------------------------------- 1 | import 'package:riverpod/riverpod.dart'; 2 | 3 | final onboardingPageStateNotifierProvider = 4 | StateNotifierProvider( 5 | (ref) => OnboardingPageNotifier()); 6 | 7 | class OnboardingPageNotifier extends StateNotifier { 8 | OnboardingPageNotifier() : super(0); 9 | 10 | void goToNextPage() => state = state + 1; 11 | 12 | void goToPreviousPage() => state = state - 1; 13 | } 14 | -------------------------------------------------------------------------------- /lib/notifiers/selected_action_provider/selected_action.dart: -------------------------------------------------------------------------------- 1 | import 'package:freezed_annotation/freezed_annotation.dart'; 2 | 3 | part 'selected_action.freezed.dart'; 4 | 5 | @freezed 6 | class SelectedAction with _$SelectedAction { 7 | const factory SelectedAction.idle() = Idle; 8 | const factory SelectedAction.makeWall() = MakeWall; 9 | const factory SelectedAction.makeGoalNode() = MakeGoalNode; 10 | const factory SelectedAction.doAlgorithm() = DoAlgorithm; 11 | const factory SelectedAction.reset() = ResetNode; 12 | } 13 | -------------------------------------------------------------------------------- /lib/notifiers/selected_action_provider/selected_action_provider.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 2 | import 'package:path_finding/notifiers/selected_action_provider/selected_action.dart'; 3 | 4 | final selectedActionProvider = 5 | StateProvider((ref) => const SelectedAction.idle()); 6 | -------------------------------------------------------------------------------- /lib/notifiers/selected_shortest_path_algorithm_state_notifier.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 2 | import 'package:path_finding/data/nodes_repository.dart'; 3 | import 'package:path_finding/notifiers/animation_time_state_notifier.dart'; 4 | 5 | final selectedShortestPathAlgorithmStateNotifier = 6 | StateNotifierProvider((ref) { 7 | return SelectedShortestPathAlgorithmNotifier( 8 | ref.read(nodesRepositoryProvider), 9 | ref, 10 | ); 11 | }); 12 | 13 | class SelectedShortestPathAlgorithmNotifier extends StateNotifier { 14 | final NodesRepository _nodesRepository; 15 | final Ref _ref; 16 | SelectedShortestPathAlgorithmNotifier(this._nodesRepository, this._ref) : super(PathFindingAlgorithmType.dijkstras); 17 | 18 | void setSelectedAlgorithm(PathFindingAlgorithmType type) { 19 | _nodesRepository.setCurrentlySelectedAlgorithmTo( 20 | pathFindingAlgorithmType: type, 21 | animationTimeDelay: _ref.read(animationTimeStateNotifierProvider), 22 | ); 23 | state = type; 24 | } 25 | } 26 | 27 | enum PathFindingAlgorithmType { dijkstras, astar, drunk, dfs, bfs } 28 | 29 | extension AlgorithmProperties on PathFindingAlgorithmType { 30 | static final _name = { 31 | PathFindingAlgorithmType.dijkstras: 'Dijkstras', 32 | PathFindingAlgorithmType.astar: 'A*', 33 | PathFindingAlgorithmType.dfs: 'DFS', 34 | PathFindingAlgorithmType.drunk: 'Drunk', 35 | PathFindingAlgorithmType.bfs: 'BFS', 36 | }; 37 | 38 | String get title => _name[this]!; 39 | } 40 | -------------------------------------------------------------------------------- /lib/ui/colors.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class AppColors { 4 | static const wallColor = Colors.black87; 5 | static const idleColor = Colors.orangeAccent; 6 | static const goalColor = Colors.deepPurpleAccent; 7 | static const pathColor = Colors.redAccent; 8 | static const actionSelected = Colors.white; 9 | static const actionUnselected = Colors.grey; 10 | static const textDark = Colors.black87; 11 | static const sliderColor = Colors.blueGrey; 12 | static const panelBackground = Color(0xFFEEEEEE); 13 | } 14 | -------------------------------------------------------------------------------- /lib/ui/common/blue_text_button.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:path_finding/ui/common/text/unit_rounded_text.dart'; 3 | 4 | class BlueTextButton extends StatelessWidget { 5 | final String text; 6 | final Function()? onPressed; 7 | const BlueTextButton({ 8 | Key? key, 9 | required this.text, 10 | this.onPressed, 11 | }) : super(key: key); 12 | 13 | @override 14 | Widget build(BuildContext context) { 15 | return TextButton( 16 | style: ButtonStyle( 17 | shape: MaterialStateProperty.resolveWith( 18 | (Set states) { 19 | if (states.contains(MaterialState.hovered)) { 20 | return ContinuousRectangleBorder( 21 | side: BorderSide(color: Colors.blue.withOpacity(0.8)), 22 | borderRadius: const BorderRadius.all(Radius.circular(10))); 23 | } 24 | 25 | return const ContinuousRectangleBorder( 26 | side: BorderSide(color: Colors.blue), 27 | borderRadius: BorderRadius.all(Radius.circular(10))); 28 | }, 29 | ), 30 | foregroundColor: MaterialStateProperty.resolveWith( 31 | (Set states) { 32 | return Colors.white; // Defer to the widget's default. 33 | }, 34 | ), 35 | backgroundColor: MaterialStateProperty.resolveWith( 36 | (Set states) { 37 | if (states.contains(MaterialState.hovered)) { 38 | return Colors.blue.withOpacity(0.8); 39 | } 40 | 41 | return Colors.blue; // De/ Defer to the widget's default. 42 | }, 43 | ), 44 | ), 45 | onPressed: onPressed, 46 | child: UnitRoundedText( 47 | text, 48 | color: Colors.white, 49 | fontSize: 18, 50 | ), 51 | ); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /lib/ui/common/playable_lottie/playable_lottie.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui' as ui; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_hooks/flutter_hooks.dart'; 5 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 6 | import 'package:lottie/lottie.dart'; 7 | import 'package:path_finding/ui/common/playable_lottie/playable_lottie_asset.dart'; 8 | import 'package:path_finding/ui/common/playable_lottie/playable_lottie_state.dart'; 9 | 10 | final playableLottieStateNotifierProvider = StateNotifierProvider.family< 11 | PlayableLottieNotifier, PlayableLottieState, PlayableLottieAsset>( 12 | (ref, playableLottieAsset) => PlayableLottieNotifier(playableLottieAsset), 13 | ); 14 | 15 | class PlayableLottieNotifier extends StateNotifier { 16 | final PlayableLottieAsset playableAsset; 17 | PlayableLottieNotifier(this.playableAsset) 18 | : super(PlayableLottieState.initial()); 19 | 20 | void playForward() => state = PlayableLottieState.playForward(); 21 | 22 | void playBackwards() => state = PlayableLottieState.playBackwards(); 23 | 24 | void resetAnimation() => state = PlayableLottieState.reset(); 25 | } 26 | 27 | class PlayableLottie extends HookConsumerWidget { 28 | final PlayableLottieAsset playableLottieAsset; 29 | final Function()? onTap; 30 | final List gradientColors; 31 | final bool isInitialValueAnimationEnd; 32 | final Duration? duration; 33 | const PlayableLottie({ 34 | super.key, 35 | required this.playableLottieAsset, 36 | this.onTap, 37 | this.isInitialValueAnimationEnd = false, 38 | this.gradientColors = const [], 39 | this.duration, 40 | }); 41 | 42 | @override 43 | Widget build(BuildContext context, WidgetRef ref) { 44 | final AnimationController animationController = useAnimationController( 45 | initialValue: isInitialValueAnimationEnd ? 1.0 : 0, 46 | duration: duration ?? 47 | const Duration( 48 | milliseconds: 1200, 49 | ), 50 | ); 51 | final animation = useListenable( 52 | CurvedAnimation(parent: animationController, curve: Curves.easeOut)); 53 | 54 | ref.listen( 55 | playableLottieStateNotifierProvider(playableLottieAsset), 56 | (previous, next) { 57 | next.whenOrNull( 58 | playForward: () => animationController.forward(), 59 | playBackwards: () => animationController.reverse(), 60 | reset: () => animationController.reset(), 61 | ); 62 | }); 63 | 64 | return GestureDetector( 65 | onTap: onTap, 66 | child: gradientColors.isEmpty 67 | ? Lottie.asset( 68 | playableLottieAsset.pathToAsset, 69 | width: 48, 70 | height: 48, 71 | controller: animation, 72 | ) 73 | : ShaderMask( 74 | shaderCallback: (bounds) => ui.Gradient.linear( 75 | bounds.topLeft, 76 | bounds.bottomRight, 77 | gradientColors, 78 | ), 79 | child: Lottie.asset( 80 | playableLottieAsset.pathToAsset, 81 | width: 48, 82 | height: 48, 83 | controller: animation, 84 | ), 85 | ), 86 | ); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /lib/ui/common/playable_lottie/playable_lottie_asset.dart: -------------------------------------------------------------------------------- 1 | enum PlayableLottieAsset { 2 | goalFlag, 3 | trashBin, 4 | maze, 5 | } 6 | 7 | extension PlayableLottieAssetUtils on PlayableLottieAsset { 8 | static const String _basePath = 'assets/lotties/'; 9 | static const _paths = { 10 | PlayableLottieAsset.goalFlag: '${_basePath}flag_with_sparkle.json', 11 | PlayableLottieAsset.trashBin: '${_basePath}delete.json', 12 | PlayableLottieAsset.maze: '${_basePath}maze.json' 13 | }; 14 | 15 | String get pathToAsset => _paths[this]!; 16 | } 17 | -------------------------------------------------------------------------------- /lib/ui/common/playable_lottie/playable_lottie_state.dart: -------------------------------------------------------------------------------- 1 | import 'package:freezed_annotation/freezed_annotation.dart'; 2 | 3 | part 'playable_lottie_state.freezed.dart'; 4 | 5 | @freezed 6 | abstract class PlayableLottieState with _$PlayableLottieState { 7 | factory PlayableLottieState.initial() = _PlayableLottieInitial; 8 | factory PlayableLottieState.playForward() = _PlayableLottiePlay; 9 | factory PlayableLottieState.playBackwards() = _PlayableLottieRewind; 10 | factory PlayableLottieState.reset() = _PlayableLottieReset; 11 | } 12 | -------------------------------------------------------------------------------- /lib/ui/common/text/fonts.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | const unitRoundedTextStyle = TextStyle( 4 | fontSize: 16.0, 5 | color: Colors.black, 6 | fontFamily: 'UnitRounded', 7 | ); 8 | -------------------------------------------------------------------------------- /lib/ui/common/text/texts.dart: -------------------------------------------------------------------------------- 1 | class Texts { 2 | static const algorithms = ''' 3 | 4 | Explore Dijsktra's and A* shortest path-finding algorithms. They are used - or serves as a basis - in areas such as telecommunications, maze-solving, and navigation systems. 5 | 6 | Visualize Breadth-first search (BFS) & Depth-first search (DFS). These algorithm are used for traversing or searching tree or graph data structures. 7 | 8 | Drunk - How a drunk person would look for the shortest path, no real use here, just for fun :D 9 | 10 | '''; 11 | 12 | static const dijsktraExplanation = ''' 13 | 14 | - Guarantees the shortest path 15 | - Has NO sense of direction to where the end node is. 16 | 17 | The algorithm serves as a basis in areas such as telecommunications, maze-solving, and navigation systems. 18 | 19 | '''; 20 | 21 | static const aStarExplanation = ''' 22 | 23 | - Guarantees the shortest path 24 | - Prioritizes nodes closest to the end node 25 | 26 | This additional condition makes A* algorithm much more effective. 27 | '''; 28 | 29 | static const breadthFirstExplanation = ''' 30 | 31 | BFS starts at the tree root and explores all nodes at the present depth prior to moving on to the nodes at the next depth level. 32 | 33 | It can be used to find the shortest path between two vertices in an unweighted graph. So, changing the costs won't have effect on this algorithm :) 34 | '''; 35 | 36 | static const depthFirstExplanation = ''' 37 | 38 | DFS starts at the root node and explores as far as possible along each branch before backtracking. 39 | 40 | Like BFS, DFS is unweighted. So, changing the costs won't have effect on this algorithm :) 41 | '''; 42 | } 43 | -------------------------------------------------------------------------------- /lib/ui/common/text/unit_rounded_text.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:path_finding/ui/colors.dart'; 3 | import 'package:path_finding/ui/common/text/fonts.dart'; 4 | 5 | class UnitRoundedText extends StatelessWidget { 6 | final String text; 7 | final bool bold; 8 | final Color color; 9 | final bool centerText; 10 | final int? maxLines; 11 | final double fontSize; 12 | final bool underline; 13 | final bool hasShadow; 14 | 15 | const UnitRoundedText( 16 | this.text, { 17 | super.key, 18 | this.color = AppColors.textDark, 19 | this.centerText = false, 20 | this.underline = false, 21 | this.bold = false, 22 | this.fontSize = 16, 23 | this.maxLines, 24 | this.hasShadow = false, 25 | }); 26 | 27 | @override 28 | Widget build(BuildContext context) { 29 | return Text( 30 | text, 31 | style: unitRoundedTextStyle.copyWith( 32 | fontWeight: bold ? FontWeight.w700 : null, 33 | fontSize: fontSize, 34 | color: color, 35 | decoration: underline ? TextDecoration.underline : null, 36 | shadows: !hasShadow 37 | ? [] 38 | : [ 39 | BoxShadow( 40 | color: AppColors.textDark.withOpacity(0.2), 41 | blurRadius: 13, 42 | offset: const Offset(0, 13), 43 | ), 44 | ], 45 | ), 46 | maxLines: maxLines, 47 | textAlign: centerText ? TextAlign.center : null, 48 | ); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /lib/ui/widgets/brick_painter.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:path_finding/ui/widgets/square.dart'; 5 | 6 | // Not used because performance loss for now :(, does make a nice brick wall tough... 7 | class Brick extends StatelessWidget { 8 | const Brick({super.key}); 9 | 10 | @override 11 | Widget build(BuildContext context) { 12 | return ClipRect( 13 | child: CustomPaint( 14 | willChange: false, 15 | size: const Size(Square.size, Square.size), 16 | isComplex: false, 17 | painter: BrickPainter(), 18 | ), 19 | ); 20 | } 21 | } 22 | 23 | class BrickPainter extends CustomPainter { 24 | static const radius = 2.0; 25 | static const spacing = 2; 26 | late final double middleRowOffset; 27 | late final double bottomRowOffset; 28 | 29 | BrickPainter() : super() { 30 | middleRowOffset = Random().nextDouble() * 8; 31 | bottomRowOffset = Random().nextDouble() * 8; 32 | } 33 | 34 | @override 35 | void paint(Canvas canvas, Size size) { 36 | final brickPaint = Paint()..color = Colors.deepOrangeAccent.withOpacity(0.3); 37 | final brickWidth = size.width / 1.9; 38 | final brickHeight = size.height / 3.5; 39 | 40 | // top row 41 | var rRect2 = RRect.fromLTRBAndCorners( 42 | 0, 43 | 0, 44 | brickWidth, 45 | brickHeight, 46 | bottomLeft: const Radius.circular(radius), 47 | bottomRight: const Radius.circular(radius), 48 | topLeft: const Radius.circular(radius), 49 | topRight: const Radius.circular(radius), 50 | ); 51 | 52 | var rRect = RRect.fromLTRBAndCorners( 53 | brickWidth + spacing, 54 | 0, 55 | brickWidth + spacing + brickWidth, 56 | brickHeight, 57 | bottomLeft: const Radius.circular(radius), 58 | bottomRight: const Radius.circular(radius), 59 | topLeft: const Radius.circular(radius), 60 | topRight: const Radius.circular(radius), 61 | ); 62 | 63 | // middle row 64 | var rRect3 = RRect.fromLTRBAndCorners( 65 | 0 - middleRowOffset, 66 | brickHeight + spacing, 67 | brickWidth - middleRowOffset, 68 | brickHeight + spacing + brickHeight, 69 | bottomLeft: const Radius.circular(radius), 70 | bottomRight: const Radius.circular(radius), 71 | topLeft: const Radius.circular(radius), 72 | topRight: const Radius.circular(radius), 73 | ); 74 | 75 | var rRect4 = RRect.fromLTRBAndCorners( 76 | brickWidth + spacing - middleRowOffset, 77 | brickHeight + spacing, 78 | brickWidth + spacing + brickWidth - middleRowOffset + 10, 79 | brickHeight + spacing + brickHeight, 80 | bottomLeft: const Radius.circular(radius), 81 | bottomRight: const Radius.circular(radius), 82 | topLeft: const Radius.circular(radius), 83 | topRight: const Radius.circular(radius), 84 | ); 85 | // bottom row 86 | var rRect5 = RRect.fromLTRBAndCorners( 87 | -10 + bottomRowOffset, 88 | brickHeight * 2 + spacing * 2, 89 | brickWidth + bottomRowOffset, 90 | brickHeight * 3 + spacing * 2, 91 | bottomLeft: const Radius.circular(radius), 92 | bottomRight: const Radius.circular(radius), 93 | topLeft: const Radius.circular(radius), 94 | topRight: const Radius.circular(radius), 95 | ); 96 | 97 | var rRect6 = RRect.fromLTRBAndCorners( 98 | brickWidth + spacing + bottomRowOffset, 99 | brickHeight * 2 + spacing * 2, 100 | brickWidth + spacing + brickWidth + bottomRowOffset, 101 | brickHeight * 3 + spacing * 2, 102 | bottomLeft: const Radius.circular(radius), 103 | bottomRight: const Radius.circular(radius), 104 | topLeft: const Radius.circular(radius), 105 | topRight: const Radius.circular(radius), 106 | ); 107 | 108 | canvas.drawRRect(rRect, brickPaint); 109 | canvas.drawRRect(rRect2, brickPaint); 110 | canvas.drawRRect(rRect3, brickPaint); 111 | canvas.drawRRect(rRect4, brickPaint); 112 | canvas.drawRRect(rRect5, brickPaint); 113 | canvas.drawRRect(rRect6, brickPaint); 114 | } 115 | 116 | @override 117 | bool shouldRepaint(covariant CustomPainter oldDelegate) => false; 118 | } 119 | -------------------------------------------------------------------------------- /lib/ui/widgets/onboarding/onboarding_a_star.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:path_finding/notifiers/onboarding_page_state_notifier.dart'; 4 | import 'package:path_finding/ui/common/blue_text_button.dart'; 5 | import 'package:path_finding/ui/common/text/texts.dart'; 6 | import 'package:path_finding/ui/common/text/unit_rounded_text.dart'; 7 | import 'package:path_finding/ui/widgets/url_launchable_title.dart'; 8 | import 'package:url_launcher/url_launcher.dart'; 9 | 10 | class OnboardingAstar extends ConsumerWidget { 11 | const OnboardingAstar({super.key}); 12 | 13 | @override 14 | Widget build(BuildContext context, WidgetRef ref) { 15 | return IntrinsicHeight( 16 | child: Column( 17 | mainAxisAlignment: MainAxisAlignment.center, 18 | children: [ 19 | UrlLaunchableTitle( 20 | text: 'A* algorithm', 21 | onPressed: () => launchUrl(Uri.parse('https://www.youtube.com/watch?v=ySN5Wnu88nE')), 22 | ), 23 | const SizedBox( 24 | height: 20, 25 | ), 26 | Expanded( 27 | child: Image.asset( 28 | "assets/a_star.gif", 29 | ), 30 | ), 31 | const UnitRoundedText( 32 | Texts.aStarExplanation, 33 | ), 34 | const SizedBox( 35 | height: 20, 36 | ), 37 | Row( 38 | mainAxisAlignment: MainAxisAlignment.center, 39 | children: [ 40 | BlueTextButton( 41 | text: 'Previous', 42 | onPressed: () => ref.read(onboardingPageStateNotifierProvider.notifier).goToPreviousPage(), 43 | ), 44 | const SizedBox( 45 | width: 60, 46 | ), 47 | BlueTextButton( 48 | text: 'BFS & DFS?', 49 | onPressed: () => ref.read(onboardingPageStateNotifierProvider.notifier).goToNextPage(), 50 | ), 51 | ], 52 | ), 53 | ], 54 | ), 55 | ); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /lib/ui/widgets/onboarding/onboarding_algorithms.dart: -------------------------------------------------------------------------------- 1 | // import 'package:flutter/material.dart'; 2 | // import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | // import 'package:path_finding/notifiers/onboarding_page_state_notifier.dart'; 4 | // import 'package:path_finding/ui/common/blue_text_button.dart'; 5 | // import 'package:path_finding/ui/common/text/texts.dart'; 6 | // import 'package:path_finding/ui/common/text/unit_rounded_text.dart'; 7 | 8 | // class OnboardingAlgorithms extends ConsumerWidget { 9 | // const OnboardingAlgorithms({super.key}); 10 | 11 | // @override 12 | // Widget build(BuildContext context, WidgetRef ref) { 13 | // return IntrinsicHeight( 14 | // child: Column( 15 | // mainAxisAlignment: MainAxisAlignment.center, 16 | // children: [ 17 | // Expanded( 18 | // child: Column( 19 | // children: const [ 20 | // UnitRoundedText( 21 | // 'Algorithms', 22 | // bold: true, 23 | // fontSize: 22, 24 | // ), 25 | // SizedBox( 26 | // height: 20, 27 | // ), 28 | // UnitRoundedText( 29 | // Texts.algorithms, 30 | // ), 31 | // SizedBox( 32 | // height: 20, 33 | // ), 34 | // ], 35 | // ), 36 | // ), 37 | // Row( 38 | // mainAxisAlignment: MainAxisAlignment.center, 39 | // children: [ 40 | // BlueTextButton( 41 | // text: 'Previous', 42 | // onPressed: () => ref 43 | // .read(onboardingPageStateNotifierProvider.notifier) 44 | // .goToPreviousPage(), 45 | // ), 46 | // const SizedBox( 47 | // width: 60, 48 | // ), 49 | // BlueTextButton( 50 | // text: 'What\'s Dijkstra?', 51 | // onPressed: () => ref 52 | // .read(onboardingPageStateNotifierProvider.notifier) 53 | // .goToNextPage(), 54 | // ), 55 | // ], 56 | // ), 57 | // ], 58 | // ), 59 | // ); 60 | // } 61 | // } 62 | -------------------------------------------------------------------------------- /lib/ui/widgets/onboarding/onboarding_breadth_first_search.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:path_finding/notifiers/onboarding_page_state_notifier.dart'; 4 | import 'package:path_finding/ui/common/blue_text_button.dart'; 5 | import 'package:path_finding/ui/common/text/texts.dart'; 6 | import 'package:path_finding/ui/common/text/unit_rounded_text.dart'; 7 | import 'package:path_finding/ui/widgets/url_launchable_title.dart'; 8 | import 'package:url_launcher/url_launcher.dart'; 9 | 10 | class OnboardingBreadthFirstSearch extends ConsumerWidget { 11 | const OnboardingBreadthFirstSearch({super.key}); 12 | 13 | @override 14 | Widget build(BuildContext context, WidgetRef ref) { 15 | return IntrinsicHeight( 16 | child: Column( 17 | mainAxisAlignment: MainAxisAlignment.center, 18 | children: [ 19 | UrlLaunchableTitle( 20 | text: 'Breadth-first search', 21 | onPressed: () => launchUrl(Uri.parse('https://en.wikipedia.org/wiki/Breadth-first_search')), 22 | ), 23 | const SizedBox( 24 | height: 20, 25 | ), 26 | Expanded( 27 | child: Image.asset( 28 | "assets/bfs.gif", 29 | ), 30 | ), 31 | const UnitRoundedText( 32 | Texts.breadthFirstExplanation, 33 | ), 34 | const SizedBox( 35 | height: 20, 36 | ), 37 | Row( 38 | mainAxisAlignment: MainAxisAlignment.center, 39 | children: [ 40 | BlueTextButton( 41 | text: 'Previous', 42 | onPressed: () => ref.read(onboardingPageStateNotifierProvider.notifier).goToPreviousPage(), 43 | ), 44 | const SizedBox( 45 | width: 60, 46 | ), 47 | BlueTextButton( 48 | text: 'How about DFS?', 49 | onPressed: () => ref.read(onboardingPageStateNotifierProvider.notifier).goToNextPage(), 50 | ), 51 | ], 52 | ), 53 | ], 54 | ), 55 | ); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /lib/ui/widgets/onboarding/onboarding_controlls.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:path_finding/notifiers/onboarding_page_state_notifier.dart'; 4 | import 'package:path_finding/ui/common/blue_text_button.dart'; 5 | import 'package:path_finding/ui/common/text/unit_rounded_text.dart'; 6 | 7 | class OnboardingControls extends ConsumerWidget { 8 | const OnboardingControls({super.key}); 9 | 10 | @override 11 | Widget build(BuildContext context, WidgetRef ref) { 12 | return IntrinsicHeight( 13 | child: Column( 14 | children: [ 15 | const UnitRoundedText( 16 | 'Controls', 17 | bold: true, 18 | fontSize: 22, 19 | ), 20 | Expanded( 21 | child: Column( 22 | mainAxisAlignment: MainAxisAlignment.spaceEvenly, 23 | children: const [ 24 | _TextWithImage( 25 | text: 'Choose what algorithm you wanna use :)', 26 | imagePath: 'assets/images/algorithm_choosing.png', 27 | ), 28 | _TextWithImage( 29 | text: 'Control costs of horizontal & diagonal movement, turn on/off diagonal movement.', 30 | imagePath: 'assets/images/cost_controls.png', 31 | ), 32 | _TextWithImage( 33 | text: 'Slow down time to see the algorithm work better 🪄', 34 | imagePath: 'assets/images/time_control.png', 35 | ), 36 | _TextWithImage( 37 | text: 'Delete all with the trash can, or reset the algorithm to start.', 38 | imagePath: 'assets/images/delete_reset.png', 39 | ), 40 | ], 41 | ), 42 | ), 43 | Row( 44 | mainAxisAlignment: MainAxisAlignment.center, 45 | children: [ 46 | BlueTextButton( 47 | text: 'Previous', 48 | onPressed: () => ref.read(onboardingPageStateNotifierProvider.notifier).goToPreviousPage(), 49 | ), 50 | const SizedBox( 51 | width: 60, 52 | ), 53 | BlueTextButton( 54 | text: 'How algorithms work?', 55 | onPressed: () => ref.read(onboardingPageStateNotifierProvider.notifier).goToNextPage(), 56 | ), 57 | ], 58 | ), 59 | ], 60 | ), 61 | ); 62 | } 63 | } 64 | 65 | class _TextWithImage extends StatelessWidget { 66 | final String text; 67 | final String imagePath; 68 | const _TextWithImage({ 69 | required this.text, 70 | required this.imagePath, 71 | }); 72 | 73 | @override 74 | Widget build(BuildContext context) { 75 | return Row( 76 | children: [ 77 | Expanded( 78 | child: UnitRoundedText( 79 | text, 80 | ), 81 | ), 82 | const SizedBox( 83 | width: 12, 84 | ), 85 | Image.asset( 86 | imagePath, 87 | height: 64, 88 | ), 89 | const SizedBox( 90 | width: 12, 91 | ), 92 | ], 93 | ); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /lib/ui/widgets/onboarding/onboarding_depth_first_search.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:path_finding/notifiers/onboarding_page_state_notifier.dart'; 4 | import 'package:path_finding/ui/common/blue_text_button.dart'; 5 | import 'package:path_finding/ui/common/text/texts.dart'; 6 | import 'package:path_finding/ui/common/text/unit_rounded_text.dart'; 7 | import 'package:path_finding/ui/widgets/url_launchable_title.dart'; 8 | import 'package:url_launcher/url_launcher.dart'; 9 | 10 | class OnboardingDepthFirstSearch extends ConsumerWidget { 11 | const OnboardingDepthFirstSearch({super.key}); 12 | 13 | @override 14 | Widget build(BuildContext context, WidgetRef ref) { 15 | return IntrinsicHeight( 16 | child: Column( 17 | mainAxisAlignment: MainAxisAlignment.center, 18 | children: [ 19 | UrlLaunchableTitle( 20 | text: 'Depth-first search', 21 | onPressed: () => launchUrl(Uri.parse('https://en.wikipedia.org/wiki/Depth-first_search')), 22 | ), 23 | const SizedBox( 24 | height: 20, 25 | ), 26 | Expanded( 27 | child: Image.asset( 28 | "assets/dfs.gif", 29 | ), 30 | ), 31 | const UnitRoundedText( 32 | Texts.depthFirstExplanation, 33 | ), 34 | const SizedBox( 35 | height: 20, 36 | ), 37 | Row( 38 | mainAxisAlignment: MainAxisAlignment.center, 39 | children: [ 40 | BlueTextButton( 41 | text: 'Previous', 42 | onPressed: () => ref.read(onboardingPageStateNotifierProvider.notifier).goToPreviousPage(), 43 | ), 44 | const SizedBox( 45 | width: 60, 46 | ), 47 | BlueTextButton( 48 | text: 'Got it!', 49 | onPressed: () => Navigator.of(context).pop(), 50 | ), 51 | ], 52 | ), 53 | ], 54 | ), 55 | ); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /lib/ui/widgets/onboarding/onboarding_dialog.dart: -------------------------------------------------------------------------------- 1 | import 'dart:developer'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_hooks/flutter_hooks.dart'; 5 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 6 | import 'package:path_finding/notifiers/onboarding_page_state_notifier.dart'; 7 | import 'package:path_finding/ui/widgets/onboarding/onboarding_a_star.dart'; 8 | import 'package:path_finding/ui/widgets/onboarding/onboarding_breadth_first_search.dart'; 9 | import 'package:path_finding/ui/widgets/onboarding/onboarding_controlls.dart'; 10 | import 'package:path_finding/ui/widgets/onboarding/onboarding_depth_first_search.dart'; 11 | import 'package:path_finding/ui/widgets/onboarding/onboarding_dijkstra.dart'; 12 | import 'package:path_finding/ui/widgets/onboarding/onboarding_welcome.dart'; 13 | 14 | class OnboardingDialog extends HookConsumerWidget { 15 | const OnboardingDialog({super.key}); 16 | 17 | final pages = const [ 18 | OnboardingWelcome(), 19 | OnboardingControls(), 20 | OnboardingDijkstra(), 21 | OnboardingAstar(), 22 | OnboardingBreadthFirstSearch(), 23 | OnboardingDepthFirstSearch(), 24 | ]; 25 | 26 | @override 27 | Widget build(BuildContext context, WidgetRef ref) { 28 | final pageController = usePageController(); 29 | 30 | ref.listen(onboardingPageStateNotifierProvider, (_, nextPageIndex) { 31 | log('Changed to $nextPageIndex'); 32 | pageController.animateToPage(nextPageIndex, duration: const Duration(milliseconds: 400), curve: Curves.easeInOut); 33 | }); 34 | 35 | return Dialog( 36 | shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(24))), 37 | backgroundColor: const Color.fromARGB(255, 243, 243, 243), 38 | child: ConstrainedBox( 39 | constraints: const BoxConstraints(maxHeight: 600, maxWidth: 600), 40 | child: Stack( 41 | children: [ 42 | Padding( 43 | padding: const EdgeInsets.symmetric(horizontal: 26, vertical: 24), 44 | child: PageView.builder( 45 | controller: pageController, 46 | itemCount: pages.length, 47 | itemBuilder: (context, index) => pages[index], 48 | ), 49 | ), 50 | Positioned( 51 | top: 0, 52 | right: 0, 53 | child: Transform.translate( 54 | offset: const Offset(6, -6), 55 | child: Container( 56 | decoration: const BoxDecoration( 57 | color: Color.fromARGB(255, 243, 243, 243), 58 | borderRadius: BorderRadius.only( 59 | topRight: Radius.circular(20), 60 | topLeft: Radius.circular(24), 61 | bottomRight: Radius.circular(24), 62 | bottomLeft: Radius.circular(24), 63 | ), 64 | ), 65 | child: IconButton( 66 | onPressed: () => Navigator.of(context).pop(), 67 | icon: const Icon(Icons.close_rounded), 68 | hoverColor: Colors.transparent, 69 | ), 70 | ), 71 | ), 72 | ) 73 | ], 74 | ), 75 | ), 76 | ); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /lib/ui/widgets/onboarding/onboarding_dijkstra.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:path_finding/notifiers/onboarding_page_state_notifier.dart'; 4 | import 'package:path_finding/ui/common/blue_text_button.dart'; 5 | import 'package:path_finding/ui/common/text/texts.dart'; 6 | import 'package:path_finding/ui/common/text/unit_rounded_text.dart'; 7 | import 'package:path_finding/ui/widgets/url_launchable_title.dart'; 8 | import 'package:url_launcher/url_launcher.dart'; 9 | 10 | class OnboardingDijkstra extends ConsumerWidget { 11 | const OnboardingDijkstra({super.key}); 12 | 13 | @override 14 | Widget build(BuildContext context, WidgetRef ref) { 15 | return IntrinsicHeight( 16 | child: Column( 17 | mainAxisAlignment: MainAxisAlignment.center, 18 | children: [ 19 | UrlLaunchableTitle( 20 | text: 'Dijsktra\'s algorithm', 21 | onPressed: () => launchUrl(Uri.parse('https://medium.com/p/32b73722406a/edit')), 22 | ), 23 | const SizedBox( 24 | height: 20, 25 | ), 26 | Expanded( 27 | child: Image.asset( 28 | "assets/dijkstra.gif", 29 | ), 30 | ), 31 | const UnitRoundedText(Texts.dijsktraExplanation), 32 | const SizedBox( 33 | height: 20, 34 | ), 35 | Row( 36 | mainAxisAlignment: MainAxisAlignment.center, 37 | children: [ 38 | BlueTextButton( 39 | text: 'Previous', 40 | onPressed: () => ref.read(onboardingPageStateNotifierProvider.notifier).goToPreviousPage(), 41 | ), 42 | const SizedBox( 43 | width: 60, 44 | ), 45 | BlueTextButton( 46 | text: 'Whats A* algorithm?', 47 | onPressed: () => ref.read(onboardingPageStateNotifierProvider.notifier).goToNextPage(), 48 | ), 49 | ], 50 | ), 51 | ], 52 | ), 53 | ); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /lib/ui/widgets/onboarding/onboarding_play_algorithm.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:path_finding/notifiers/onboarding_page_state_notifier.dart'; 4 | import 'package:path_finding/ui/common/blue_text_button.dart'; 5 | import 'package:path_finding/ui/common/text/unit_rounded_text.dart'; 6 | 7 | class OnboardingPlayAlgorithm extends ConsumerWidget { 8 | const OnboardingPlayAlgorithm({super.key}); 9 | 10 | @override 11 | Widget build(BuildContext context, WidgetRef ref) { 12 | return IntrinsicHeight( 13 | child: Column( 14 | mainAxisAlignment: MainAxisAlignment.center, 15 | children: [ 16 | const UnitRoundedText( 17 | 'Use the mouse to place start & end points, as well as build/remove walls.', 18 | ), 19 | const SizedBox( 20 | height: 20, 21 | ), 22 | Expanded( 23 | child: Image.asset( 24 | "assets/tutorial_controls.gif", 25 | ), 26 | ), 27 | const SizedBox( 28 | height: 20, 29 | ), 30 | Row( 31 | mainAxisAlignment: MainAxisAlignment.center, 32 | children: [ 33 | BlueTextButton( 34 | text: 'Previous', 35 | onPressed: () => ref.read(onboardingPageStateNotifierProvider.notifier).goToPreviousPage(), 36 | ), 37 | const SizedBox( 38 | width: 60, 39 | ), 40 | BlueTextButton( 41 | text: 'Continue', 42 | onPressed: () => ref.read(onboardingPageStateNotifierProvider.notifier).goToNextPage(), 43 | ), 44 | ], 45 | ), 46 | ], 47 | ), 48 | ); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /lib/ui/widgets/onboarding/onboarding_welcome.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/gestures.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 4 | import 'package:lottie/lottie.dart'; 5 | import 'package:path_finding/notifiers/onboarding_page_state_notifier.dart'; 6 | import 'package:path_finding/ui/common/blue_text_button.dart'; 7 | import 'package:path_finding/ui/common/text/fonts.dart'; 8 | import 'package:path_finding/ui/common/text/unit_rounded_text.dart'; 9 | import 'package:url_launcher/url_launcher.dart'; 10 | 11 | class OnboardingWelcome extends ConsumerWidget { 12 | const OnboardingWelcome({super.key}); 13 | 14 | @override 15 | Widget build(BuildContext context, WidgetRef ref) { 16 | return IntrinsicHeight( 17 | child: Column( 18 | mainAxisAlignment: MainAxisAlignment.center, 19 | children: [ 20 | const UnitRoundedText( 21 | 'Welcome to the Path finding visualization with Flutter!', 22 | bold: true, 23 | fontSize: 22, 24 | ), 25 | const SizedBox( 26 | height: 20, 27 | ), 28 | const Padding( 29 | padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10), 30 | child: UnitRoundedText( 31 | 'Play around with different ways to visualize path finding, I hope you enjoy it as much as I did making it :D', 32 | ), 33 | ), 34 | const Padding( 35 | padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10), 36 | child: UnitRoundedText( 37 | 'Learn some info by clicking through this modal, or press the \'X\' to close at any time you wish.', 38 | ), 39 | ), 40 | RichText( 41 | text: TextSpan( 42 | style: unitRoundedTextStyle, 43 | text: 'If you want to see the code, take a look at my ', 44 | children: [ 45 | TextSpan( 46 | text: 'github.', 47 | style: unitRoundedTextStyle.copyWith( 48 | fontStyle: FontStyle.italic, 49 | decoration: TextDecoration.underline, 50 | ), 51 | recognizer: TapGestureRecognizer() 52 | ..onTap = () => launchUrl( 53 | Uri.parse( 54 | 'https://github.com/igniti0n/flutter_algorithms_visualization', 55 | ), 56 | ), 57 | ), 58 | ], 59 | ), 60 | ), 61 | Expanded( 62 | child: Padding( 63 | padding: const EdgeInsets.all(4), 64 | child: Lottie.asset( 65 | 'assets/lotties/path_finding.json', 66 | height: 164, 67 | ), 68 | ), 69 | ), 70 | const SizedBox( 71 | height: 40, 72 | ), 73 | BlueTextButton( 74 | text: 'Continue', 75 | onPressed: () => ref.read(onboardingPageStateNotifierProvider.notifier).goToNextPage(), 76 | ), 77 | ], 78 | ), 79 | ); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /lib/ui/widgets/panel/algorithm_button_picker.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:path_finding/notifiers/selected_shortest_path_algorithm_state_notifier.dart'; 4 | import 'package:path_finding/ui/colors.dart'; 5 | import 'package:path_finding/ui/common/text/unit_rounded_text.dart'; 6 | 7 | class AlgorithmButtonPicker extends StatelessWidget { 8 | const AlgorithmButtonPicker({super.key}); 9 | 10 | @override 11 | Widget build(BuildContext context) { 12 | return Wrap( 13 | direction: Axis.vertical, 14 | alignment: WrapAlignment.center, 15 | runSpacing: 8, 16 | spacing: 8, 17 | children: PathFindingAlgorithmType.values 18 | .map((type) => _SelectAlgorithmButton(pathFindingAlgorithmType: type)) 19 | .toList(), 20 | ); 21 | } 22 | } 23 | 24 | class _SelectAlgorithmButton extends ConsumerWidget { 25 | final PathFindingAlgorithmType pathFindingAlgorithmType; 26 | const _SelectAlgorithmButton({required this.pathFindingAlgorithmType}); 27 | 28 | @override 29 | Widget build(BuildContext context, WidgetRef ref) { 30 | final currentlySelectedAlgorithm = ref.watch(selectedShortestPathAlgorithmStateNotifier); 31 | 32 | final isSelected = currentlySelectedAlgorithm == pathFindingAlgorithmType; 33 | 34 | return GestureDetector( 35 | onTap: () => 36 | ref.read(selectedShortestPathAlgorithmStateNotifier.notifier).setSelectedAlgorithm(pathFindingAlgorithmType), 37 | child: Container( 38 | width: 100, 39 | padding: const EdgeInsets.all(8), 40 | decoration: BoxDecoration( 41 | color: isSelected ? AppColors.actionSelected : AppColors.actionUnselected, 42 | border: isSelected 43 | ? Border.all(color: Colors.black87, width: 1.4) 44 | : Border.all(color: Colors.black38, width: 1.4), 45 | borderRadius: const BorderRadius.all(Radius.circular(8))), 46 | child: UnitRoundedText( 47 | pathFindingAlgorithmType.title, 48 | centerText: true, 49 | fontSize: 18, 50 | ), 51 | ), 52 | ); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /lib/ui/widgets/panel/panel.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_hooks/flutter_hooks.dart'; 3 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 4 | import 'package:path_finding/notifiers/is_panel_opened_provider.dart'; 5 | import 'package:path_finding/ui/widgets/panel/panel_body.dart'; 6 | import 'package:path_finding/ui/widgets/panel/panel_sliding.dart'; 7 | 8 | class Panel extends HookConsumerWidget { 9 | const Panel({Key? key}) : super(key: key); 10 | 11 | @override 12 | Widget build(BuildContext context, WidgetRef ref) { 13 | final animationController = useAnimationController(duration: const Duration(milliseconds: 350)); 14 | final offsetAnimation = Tween( 15 | begin: const Offset(0, -PanelBody.height), 16 | end: Offset.zero, 17 | ).animate(CurvedAnimation(parent: animationController, curve: Curves.easeInOut)); 18 | 19 | ref.listen(isPanelOpenedProvider, (_, isOpened) { 20 | if (isOpened) { 21 | animationController.forward(); 22 | } else { 23 | animationController.reverse(); 24 | } 25 | }); 26 | 27 | return AnimatedBuilder( 28 | animation: offsetAnimation, 29 | builder: (context, child) => Transform.translate( 30 | offset: offsetAnimation.value, 31 | child: child, 32 | ), 33 | child: Stack( 34 | children: [ 35 | Align( 36 | alignment: Alignment.topCenter, 37 | child: ConstrainedBox( 38 | constraints: const BoxConstraints(maxHeight: PanelBody.height), 39 | child: const PanelBody(), 40 | ), 41 | ), 42 | Positioned( 43 | top: PanelBody.height, 44 | left: 44, 45 | child: Transform.translate( 46 | offset: const Offset(0, -16), 47 | child: const SlidingPanel(), 48 | ), 49 | ), 50 | ], 51 | ), 52 | ); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /lib/ui/widgets/panel/panel_body.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui' as ui; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 5 | import 'package:path_finding/notifiers/is_diagonal_movement_enabled_state_provider.dart'; 6 | import 'package:path_finding/ui/colors.dart'; 7 | import 'package:path_finding/ui/widgets/panel/algorithm_button_picker.dart'; 8 | import 'package:path_finding/ui/widgets/panel/sliders.dart'; 9 | 10 | class PanelBody extends ConsumerWidget { 11 | static const double height = 180; 12 | const PanelBody({Key? key}) : super(key: key); 13 | 14 | @override 15 | Widget build(BuildContext context, WidgetRef ref) { 16 | return DecoratedBox( 17 | decoration: const BoxDecoration( 18 | color: AppColors.panelBackground, 19 | borderRadius: BorderRadius.only( 20 | bottomLeft: Radius.circular(20), 21 | bottomRight: Radius.circular(20), 22 | ), 23 | ), 24 | child: Padding( 25 | padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 24), 26 | child: Row( 27 | // mainAxisAlignment: MainAxisAlignment.spaceBetween, 28 | children: const [ 29 | SizedBox(width: 120), 30 | AlgorithmButtonPicker(), 31 | SizedBox(width: 24), 32 | _DiagonalCosts(), 33 | SizedBox( 34 | width: 10, 35 | ), 36 | HorizontalAndVerticalPathCostSlider(), 37 | SizedBox( 38 | width: 10, 39 | ), 40 | // AnimationTimeDelaySlider(), 41 | ], 42 | ), 43 | ), 44 | ); 45 | } 46 | } 47 | 48 | class _DiagonalCosts extends ConsumerWidget { 49 | const _DiagonalCosts({ 50 | Key? key, 51 | }) : super(key: key); 52 | 53 | @override 54 | Widget build(BuildContext context, WidgetRef ref) { 55 | final isDiagonalMovementEnabled = ref.watch(isDiagonalMovementEnableStateProvider); 56 | 57 | return Column( 58 | mainAxisSize: MainAxisSize.min, 59 | children: [ 60 | ShaderMask( 61 | blendMode: isDiagonalMovementEnabled ? BlendMode.dst : BlendMode.modulate, 62 | shaderCallback: (bounds) => ui.Gradient.linear( 63 | bounds.topRight, 64 | bounds.bottomRight, 65 | isDiagonalMovementEnabled 66 | ? [Colors.transparent, Colors.transparent] 67 | : [Colors.grey[900]!, Colors.grey[900]!], 68 | ), 69 | child: const DiagonalPathCostSlider(), 70 | ), 71 | const SizedBox( 72 | height: 10, 73 | ), 74 | Checkbox( 75 | value: isDiagonalMovementEnabled, 76 | onChanged: (newValue) => ref.read(isDiagonalMovementEnableStateProvider.notifier).state = newValue ?? false, 77 | ) 78 | ], 79 | ); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /lib/ui/widgets/panel/panel_sliding.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:path_finding/notifiers/is_panel_opened_provider.dart'; 4 | import 'package:path_finding/ui/colors.dart'; 5 | 6 | class SlidingPanel extends ConsumerWidget { 7 | const SlidingPanel({Key? key}) : super(key: key); 8 | 9 | @override 10 | Widget build(BuildContext context, WidgetRef ref) { 11 | final isPanelOpened = ref.watch(isPanelOpenedProvider); 12 | 13 | return GestureDetector( 14 | onTap: () => ref.read(isPanelOpenedProvider.notifier).state = !isPanelOpened, 15 | child: Container( 16 | decoration: const BoxDecoration( 17 | color: AppColors.panelBackground, 18 | backgroundBlendMode: BlendMode.src, 19 | borderRadius: BorderRadius.only( 20 | bottomLeft: Radius.circular(20), 21 | bottomRight: Radius.circular(20), 22 | ), 23 | ), 24 | height: 58, 25 | width: 64, 26 | child: Icon( 27 | isPanelOpened ? Icons.arrow_drop_up_rounded : Icons.arrow_drop_down_rounded, 28 | size: 68, 29 | ), 30 | ), 31 | ); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/ui/widgets/panel/reset_buttons.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:path_finding/notifiers/nodes_state_notifier.dart'; 4 | import 'package:path_finding/ui/colors.dart'; 5 | import 'package:path_finding/ui/common/playable_lottie/playable_lottie.dart'; 6 | import 'package:path_finding/ui/common/playable_lottie/playable_lottie_asset.dart'; 7 | 8 | class ResetButtons extends ConsumerWidget { 9 | const ResetButtons({Key? key}) : super(key: key); 10 | 11 | @override 12 | Widget build(BuildContext context, WidgetRef ref) { 13 | return Row( 14 | mainAxisAlignment: MainAxisAlignment.spaceBetween, 15 | children: [ 16 | Padding( 17 | padding: const EdgeInsets.all(8.0), 18 | child: Transform.translate( 19 | offset: const Offset(0, -10), 20 | child: Transform.scale( 21 | scale: 1.5, 22 | child: PlayableLottie( 23 | playableLottieAsset: PlayableLottieAsset.trashBin, 24 | gradientColors: [ 25 | Colors.orangeAccent.withOpacity(1), 26 | Colors.blueGrey.withOpacity(1) 27 | ], 28 | onTap: () => _onDeleteAllTapped(ref), 29 | ), 30 | ), 31 | ), 32 | ), 33 | const SizedBox( 34 | width: 32, 35 | ), 36 | Padding( 37 | padding: const EdgeInsets.all(8.0), 38 | child: GestureDetector( 39 | onTap: () => ref 40 | .read(nodesStateNotifierProvider.notifier) 41 | .resetAlgorithmToStart(), 42 | child: const Icon( 43 | Icons.reply_rounded, 44 | size: 48, 45 | color: AppColors.sliderColor, 46 | ), 47 | ), 48 | ), 49 | ], 50 | ); 51 | } 52 | 53 | void _onDeleteAllTapped(WidgetRef ref) { 54 | ref 55 | .read(playableLottieStateNotifierProvider(PlayableLottieAsset.trashBin) 56 | .notifier) 57 | .resetAnimation(); 58 | ref 59 | .read(playableLottieStateNotifierProvider(PlayableLottieAsset.trashBin) 60 | .notifier) 61 | .playForward(); 62 | ref.read(nodesStateNotifierProvider.notifier).resetAll(); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /lib/ui/widgets/panel/sliders.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:flutter_svg/svg.dart'; 4 | import 'package:path_finding/notifiers/animation_time_state_notifier.dart'; 5 | import 'package:path_finding/notifiers/diagonal_path_cost_state_notifier.dart'; 6 | import 'package:path_finding/notifiers/horizontal_and_vertical_path_cost_state_notifier.dart'; 7 | import 'package:path_finding/ui/colors.dart'; 8 | import 'package:path_finding/ui/common/text/unit_rounded_text.dart'; 9 | 10 | class DiagonalPathCostSlider extends ConsumerWidget { 11 | const DiagonalPathCostSlider({Key? key}) : super(key: key); 12 | 13 | @override 14 | Widget build(BuildContext context, WidgetRef ref) { 15 | final diagonalCost = 16 | ref.watch(diagonalPathCostStateNotifierProvider).roundToDouble(); 17 | 18 | return Column( 19 | children: [ 20 | UnitRoundedText( 21 | '$diagonalCost', 22 | centerText: true, 23 | ), 24 | Slider( 25 | min: 0, 26 | max: 60, 27 | activeColor: AppColors.sliderColor, 28 | value: diagonalCost, 29 | onChanged: (value) => ref 30 | .read(diagonalPathCostStateNotifierProvider.notifier) 31 | .setDiagonalCost(value)), 32 | const UnitRoundedText( 33 | 'Diagonal path cost', 34 | centerText: true, 35 | ) 36 | ], 37 | ); 38 | } 39 | } 40 | 41 | class HorizontalAndVerticalPathCostSlider extends ConsumerWidget { 42 | const HorizontalAndVerticalPathCostSlider({Key? key}) : super(key: key); 43 | 44 | @override 45 | Widget build(BuildContext context, WidgetRef ref) { 46 | final horizontalAndVerticalCost = ref 47 | .watch(horizontalAndVerticalPathCostStateNotifierProvider) 48 | .roundToDouble(); 49 | 50 | return Column( 51 | children: [ 52 | UnitRoundedText( 53 | '$horizontalAndVerticalCost', 54 | centerText: true, 55 | ), 56 | Slider( 57 | min: 0, 58 | max: 60, 59 | activeColor: AppColors.sliderColor, 60 | value: horizontalAndVerticalCost, 61 | onChanged: ref 62 | .read( 63 | horizontalAndVerticalPathCostStateNotifierProvider.notifier) 64 | .setHorizontalPathCost), 65 | const UnitRoundedText( 66 | 'Horizontal and Vertical path cost', 67 | centerText: true, 68 | ) 69 | ], 70 | ); 71 | } 72 | } 73 | 74 | class AnimationTimeDelaySlider extends ConsumerWidget { 75 | const AnimationTimeDelaySlider({Key? key}) : super(key: key); 76 | 77 | @override 78 | Widget build(BuildContext context, WidgetRef ref) { 79 | final animationTimeDelay = ref.watch(animationTimeStateNotifierProvider); 80 | 81 | return Column( 82 | children: [ 83 | Expanded( 84 | child: Transform.translate( 85 | offset: const Offset(0, 8), 86 | child: Transform.scale( 87 | scale: 1.2, 88 | child: SvgPicture.asset( 89 | 'assets/svg/stopwatch.svg', 90 | height: 30, 91 | ), 92 | ), 93 | ), 94 | ), 95 | FittedBox( 96 | fit: BoxFit.contain, 97 | child: Slider( 98 | min: 0, 99 | max: 400000, 100 | activeColor: AppColors.sliderColor, 101 | value: animationTimeDelay.toDouble(), 102 | onChanged: (value) => ref 103 | .read(animationTimeStateNotifierProvider.notifier) 104 | .setAnimationTimeDelay( 105 | value.floor(), 106 | ), 107 | ), 108 | ), 109 | ], 110 | ); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /lib/ui/widgets/url_launchable_title.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:path_finding/ui/common/text/unit_rounded_text.dart'; 3 | 4 | class UrlLaunchableTitle extends StatelessWidget { 5 | final String text; 6 | final Function()? onPressed; 7 | const UrlLaunchableTitle({ 8 | Key? key, 9 | required this.text, 10 | this.onPressed, 11 | }) : super(key: key); 12 | 13 | @override 14 | Widget build(BuildContext context) { 15 | return TextButton( 16 | style: ButtonStyle( 17 | shape: MaterialStateProperty.resolveWith( 18 | (Set states) { 19 | if (states.contains(MaterialState.hovered)) { 20 | return ContinuousRectangleBorder( 21 | side: BorderSide(color: Colors.grey.withOpacity(0.8)), 22 | borderRadius: const BorderRadius.all(Radius.circular(10))); 23 | } 24 | 25 | return const ContinuousRectangleBorder( 26 | side: BorderSide(color: Colors.blue), 27 | borderRadius: BorderRadius.all(Radius.circular(10))); 28 | }, 29 | ), 30 | foregroundColor: MaterialStateProperty.resolveWith( 31 | (Set states) { 32 | return Colors.black; // Defer to the widget's default. 33 | }, 34 | ), 35 | backgroundColor: MaterialStateProperty.resolveWith( 36 | (Set states) { 37 | if (states.contains(MaterialState.hovered)) { 38 | return Colors.blue.withOpacity(0.8); 39 | } 40 | 41 | return Colors.transparent; // De/ Defer to the widget's default. 42 | }, 43 | ), 44 | ), 45 | onPressed: onPressed, 46 | child: UnitRoundedText( 47 | text, 48 | color: Colors.black, 49 | fontSize: 18, 50 | underline: true, 51 | ), 52 | ); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /lib/ui/widgets/world.dart: -------------------------------------------------------------------------------- 1 | import 'dart:html'; 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 6 | import 'package:path_finding/notifiers/nodes_state_notifier.dart'; 7 | import 'package:path_finding/ui/widgets/actions_panel/actions_panel.dart'; 8 | import 'package:path_finding/ui/widgets/onboarding/onboarding_dialog.dart'; 9 | import 'package:path_finding/ui/widgets/panel/panel.dart'; 10 | import 'package:path_finding/ui/widgets/square.dart'; 11 | 12 | class World extends ConsumerStatefulWidget { 13 | const World({super.key}); 14 | 15 | @override 16 | ConsumerState createState() => _WorldState(); 17 | } 18 | 19 | class _WorldState extends ConsumerState { 20 | static const minimumActionsPanelHeight = Square.size * 5; 21 | late double totalSquaresGridHeight; 22 | List squares = []; 23 | int widowWidth = 0; 24 | int widowHeight = 0; 25 | 26 | @override 27 | initState() { 28 | _initGrid(); 29 | WidgetsBinding.instance.addPostFrameCallback((timeStamp) { 30 | showCupertinoDialog(context: context, builder: (context) => const OnboardingDialog()); 31 | }); 32 | super.initState(); 33 | } 34 | 35 | @override 36 | Widget build(BuildContext context) { 37 | // // log('Window width: ${window.screen?.width}'); 38 | // // log('inner width: ${window.innerWidth}'); 39 | // final currentWidth = window.screen?.width; 40 | // final currentHeight = window.screen?.height; 41 | // if (widowHeight != currentWidth || widowHeight != currentHeight) { 42 | // WidgetsBinding.instance.addPostFrameCallback((timeStamp) { 43 | // log('Changed to $widowHeight - $widowWidth'); 44 | // setState(() { 45 | // _initGrid(); 46 | // widowHeight = currentHeight ?? 0; 47 | // widowWidth = currentWidth ?? 0; 48 | // }); 49 | // }); 50 | // } 51 | // return NotificationListener( 52 | // onNotification: (notification) { 53 | // log('NOTIFIED! \n $notification'); 54 | // setState(() { 55 | // _initGrid(); 56 | // }); 57 | // return false; 58 | // }, 59 | // child: 60 | return Scaffold( 61 | backgroundColor: Colors.blueGrey[900], 62 | body: Stack( 63 | alignment: Alignment.center, 64 | children: [ 65 | Column( 66 | children: [ 67 | SizedBox( 68 | height: totalSquaresGridHeight, 69 | width: double.infinity, 70 | child: RepaintBoundary( 71 | child: Stack( 72 | children: squares, 73 | ), 74 | ), 75 | ), 76 | const Expanded( 77 | child: ActionsPanel(), 78 | ), 79 | ], 80 | ), 81 | const Panel(), 82 | ], 83 | ), 84 | // ), 85 | ); 86 | } 87 | 88 | void _initGrid() { 89 | squares.clear(); 90 | final availableHeightForSquares = (window.screen?.height ?? 0) - minimumActionsPanelHeight; 91 | final numberOfSquaresThatFitHeight = (availableHeightForSquares / Square.size.toInt()).floor(); 92 | totalSquaresGridHeight = numberOfSquaresThatFitHeight * Square.size; 93 | final availableWidthForSquares = (window.screen?.width ?? 0); 94 | final numberOfSquaresThatFitWidth = (availableWidthForSquares / Square.size.toInt()).floor(); 95 | ref 96 | .read(nodesStateNotifierProvider.notifier) 97 | .init(numberOfNodesInRow: numberOfSquaresThatFitWidth, numberOfNodesInColumn: numberOfSquaresThatFitHeight); 98 | ref.read(nodesStateNotifierProvider.notifier).setStartAt(4, 10); 99 | ref.read(nodesStateNotifierProvider.notifier).setGoalAt(10, 10); 100 | for (var row in ref.read(nodesStateNotifierProvider.notifier).getAllNodes()) { 101 | for (var node in row) { 102 | squares.add(Positioned( 103 | left: node.x * Square.size, 104 | top: node.y * Square.size, 105 | child: Square( 106 | x: node.x, 107 | y: node.y, 108 | ), 109 | )); 110 | } 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /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 "path_finding") 8 | # The unique GTK application identifier for this application. See: 9 | # https://wiki.gnome.org/HowDoI/ChooseApplicationID 10 | set(APPLICATION_ID "com.example.path_finding") 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 | -------------------------------------------------------------------------------- /linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.10) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | 12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 13 | # which isn't available in 3.10. 14 | function(list_prepend LIST_NAME PREFIX) 15 | set(NEW_LIST "") 16 | foreach(element ${${LIST_NAME}}) 17 | list(APPEND NEW_LIST "${PREFIX}${element}") 18 | endforeach(element) 19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 20 | endfunction() 21 | 22 | # === Flutter Library === 23 | # System-level dependencies. 24 | find_package(PkgConfig REQUIRED) 25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 28 | 29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 30 | 31 | # Published to parent scope for install step. 32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 36 | 37 | list(APPEND FLUTTER_LIBRARY_HEADERS 38 | "fl_basic_message_channel.h" 39 | "fl_binary_codec.h" 40 | "fl_binary_messenger.h" 41 | "fl_dart_project.h" 42 | "fl_engine.h" 43 | "fl_json_message_codec.h" 44 | "fl_json_method_codec.h" 45 | "fl_message_codec.h" 46 | "fl_method_call.h" 47 | "fl_method_channel.h" 48 | "fl_method_codec.h" 49 | "fl_method_response.h" 50 | "fl_plugin_registrar.h" 51 | "fl_plugin_registry.h" 52 | "fl_standard_message_codec.h" 53 | "fl_standard_method_codec.h" 54 | "fl_string_codec.h" 55 | "fl_value.h" 56 | "fl_view.h" 57 | "flutter_linux.h" 58 | ) 59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 60 | add_library(flutter INTERFACE) 61 | target_include_directories(flutter INTERFACE 62 | "${EPHEMERAL_DIR}" 63 | ) 64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 65 | target_link_libraries(flutter INTERFACE 66 | PkgConfig::GTK 67 | PkgConfig::GLIB 68 | PkgConfig::GIO 69 | ) 70 | add_dependencies(flutter flutter_assemble) 71 | 72 | # === Flutter tool backend === 73 | # _phony_ is a non-existent file to force this command to run every time, 74 | # since currently there's no way to get a full input/output list from the 75 | # flutter tool. 76 | add_custom_command( 77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 79 | COMMAND ${CMAKE_COMMAND} -E env 80 | ${FLUTTER_TOOL_ENVIRONMENT} 81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 83 | VERBATIM 84 | ) 85 | add_custom_target(flutter_assemble DEPENDS 86 | "${FLUTTER_LIBRARY}" 87 | ${FLUTTER_LIBRARY_HEADERS} 88 | ) 89 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | 11 | void fl_register_plugins(FlPluginRegistry* registry) { 12 | g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = 13 | fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); 14 | url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); 15 | } 16 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | url_launcher_linux 7 | ) 8 | 9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 10 | ) 11 | 12 | set(PLUGIN_BUNDLED_LIBRARIES) 13 | 14 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 19 | endforeach(plugin) 20 | 21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 24 | endforeach(ffi_plugin) 25 | -------------------------------------------------------------------------------- /linux/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /linux/my_application.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, "path_finding"); 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, "path_finding"); 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 | -------------------------------------------------------------------------------- /linux/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import url_launcher_macos 9 | 10 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 11 | UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) 12 | } 13 | -------------------------------------------------------------------------------- /macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.14' 2 | 3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 5 | 6 | project 'Runner', { 7 | 'Debug' => :debug, 8 | 'Profile' => :release, 9 | 'Release' => :release, 10 | } 11 | 12 | def flutter_root 13 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) 14 | unless File.exist?(generated_xcode_build_settings_path) 15 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" 16 | end 17 | 18 | File.foreach(generated_xcode_build_settings_path) do |line| 19 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 20 | return matches[1].strip if matches 21 | end 22 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" 23 | end 24 | 25 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 26 | 27 | flutter_macos_podfile_setup 28 | 29 | target 'Runner' do 30 | use_frameworks! 31 | use_modular_headers! 32 | 33 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) 34 | end 35 | 36 | post_install do |installer| 37 | installer.pods_project.targets.each do |target| 38 | flutter_additional_macos_build_settings(target) 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /macos/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - FlutterMacOS (1.0.0) 3 | 4 | DEPENDENCIES: 5 | - FlutterMacOS (from `Flutter/ephemeral`) 6 | 7 | EXTERNAL SOURCES: 8 | FlutterMacOS: 9 | :path: Flutter/ephemeral 10 | 11 | SPEC CHECKSUMS: 12 | FlutterMacOS: ae6af50a8ea7d6103d888583d46bd8328a7e9811 13 | 14 | PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c 15 | 16 | COCOAPODS: 1.11.3 17 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "app_icon_16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "app_icon_32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "app_icon_32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "app_icon_64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "app_icon_128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "app_icon_256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "app_icon_256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "app_icon_512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "app_icon_512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "app_icon_1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = path_finding 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.pathFinding 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2022 com.example. All rights reserved. 15 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.server 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | $(PRODUCT_COPYRIGHT) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController.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 | -------------------------------------------------------------------------------- /macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: path_finding 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 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 | version: 1.0.0+1 19 | 20 | environment: 21 | sdk: ">=2.17.6 <3.0.0" 22 | 23 | # Dependencies specify other packages that your package needs in order to work. 24 | # To automatically upgrade your package dependencies to the latest versions 25 | # consider running `flutter pub upgrade --major-versions`. Alternatively, 26 | # dependencies can be manually updated by changing the version numbers below to 27 | # the latest version available on pub.dev. To see which dependencies have newer 28 | # versions available, run `flutter pub outdated`. 29 | dependencies: 30 | collection: null 31 | cupertino_icons: ^1.0.2 32 | equatable: ^2.0.5 33 | flutter: 34 | sdk: flutter 35 | flutter_hooks: ^0.18.5+1 36 | flutter_lottie: ^0.2.0 37 | flutter_riverpod: ^2.0.2 38 | flutter_svg: ^1.1.6 39 | hooks_riverpod: ^2.1.3 40 | lottie: ^2.1.0 41 | riverpod: ^2.0.2 42 | rxdart: ^0.27.5 43 | url_launcher: ^6.1.9 44 | uuid: ^3.0.6 45 | 46 | dev_dependencies: 47 | build_runner: ^2.3.2 48 | flutter_lints: ^2.0.0 49 | flutter_test: 50 | sdk: flutter 51 | freezed: ^2.2.0 52 | freezed_annotation: ^2.2.0 53 | 54 | # For information on the generic Dart part of this file, see the 55 | # following page: https://dart.dev/tools/pub/pubspec 56 | # The following section is specific to Flutter packages. 57 | flutter: 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 | # To add assets to your application, add an assets section, like this: 63 | assets: 64 | - assets/ 65 | - assets/svg/ 66 | - assets/lotties/ 67 | - assets/images/ 68 | 69 | # - images/a_dot_ham.jpeg 70 | # An image asset can refer to one or more resolution-specific "variants", see 71 | # https://flutter.dev/assets-and-images/#resolution-aware 72 | # For details regarding adding assets from package dependencies, see 73 | # https://flutter.dev/assets-and-images/#from-packages 74 | # To add custom fonts to your application, add a fonts section here, 75 | # in this "flutter" section. Each entry in this list should have a 76 | # "family" key with the font family name, and a "fonts" key with a 77 | # list giving the asset and other descriptors for the font. For 78 | # example: 79 | # fonts: 80 | # - family: Schyler 81 | # fonts: 82 | # - asset: fonts/Schyler-Regular.ttf 83 | # - asset: fonts/Schyler-Italic.ttf 84 | # style: italic 85 | # - family: Trajan Pro 86 | # fonts: 87 | # - asset: fonts/TrajanPro.ttf 88 | # - asset: fonts/TrajanPro_Bold.ttf 89 | # weight: 700 90 | # 91 | # For details regarding fonts from package dependencies, 92 | # see https://flutter.dev/custom-fonts/#from-packages 93 | fonts: 94 | - family: UnitRounded 95 | fonts: 96 | - asset: assets/fonts/UnitRoundedOT.otf 97 | weight: 400 98 | - asset: assets/fonts/UnitRoundedOTBold.otf 99 | weight: 700 100 | -------------------------------------------------------------------------------- /test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility in the flutter_test package. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter_test/flutter_test.dart'; 10 | 11 | import 'package:path_finding/main.dart'; 12 | 13 | void main() { 14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 15 | // Build our app and trigger a frame. 16 | await tester.pumpWidget(const MyApp()); 17 | 18 | // Verify that our counter starts at 0. 19 | expect(find.text('0'), findsOneWidget); 20 | expect(find.text('1'), findsNothing); 21 | 22 | // Tap the '+' icon and trigger a frame. 23 | await tester.tap(find.byIcon(Icons.add)); 24 | await tester.pump(); 25 | 26 | // Verify that our counter has incremented. 27 | expect(find.text('0'), findsNothing); 28 | expect(find.text('1'), findsOneWidget); 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/web/favicon.png -------------------------------------------------------------------------------- /web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/web/icons/Icon-192.png -------------------------------------------------------------------------------- /web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/web/icons/Icon-512.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | path_finding 33 | 34 | 35 | 39 | 40 | 41 | 42 | 43 | 51 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "path_finding", 3 | "short_name": "path_finding", 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 | -------------------------------------------------------------------------------- /windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.14) 3 | project(path_finding 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 "path_finding") 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | 11 | void RegisterPlugins(flutter::PluginRegistry* registry) { 12 | UrlLauncherWindowsRegisterWithRegistrar( 13 | registry->GetRegistrarForPlugin("UrlLauncherWindows")); 14 | } 15 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | url_launcher_windows 7 | ) 8 | 9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 10 | ) 11 | 12 | set(PLUGIN_BUNDLED_LIBRARIES) 13 | 14 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 19 | endforeach(plugin) 20 | 21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 24 | endforeach(ffi_plugin) 25 | -------------------------------------------------------------------------------- /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 | # Disable Windows macros that collide with C++ standard library functions. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 25 | 26 | # Add dependency libraries and include directories. Add any application-specific 27 | # dependencies here. 28 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 29 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 30 | 31 | # Run the Flutter tool portions of the build. This must not be removed. 32 | add_dependencies(${BINARY_NAME} flutter_assemble) 33 | -------------------------------------------------------------------------------- /windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #ifdef FLUTTER_BUILD_NUMBER 64 | #define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0 67 | #endif 68 | 69 | #ifdef FLUTTER_BUILD_NAME 70 | #define VERSION_AS_STRING #FLUTTER_BUILD_NAME 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "com.example" "\0" 93 | VALUE "FileDescription", "path_finding" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "path_finding" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2022 com.example. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "path_finding.exe" "\0" 98 | VALUE "ProductName", "path_finding" "\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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.CreateAndShow(L"path_finding", origin, size)) { 31 | return EXIT_FAILURE; 32 | } 33 | window.SetQuitOnClose(true); 34 | 35 | ::MSG msg; 36 | while (::GetMessage(&msg, nullptr, 0, 0)) { 37 | ::TranslateMessage(&msg); 38 | ::DispatchMessage(&msg); 39 | } 40 | 41 | ::CoUninitialize(); 42 | return EXIT_SUCCESS; 43 | } 44 | -------------------------------------------------------------------------------- /windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igniti0n/flutter_algorithms_visualization/66c5d85205bc192d20fdd1ba533bc5b1c1669273/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr); 51 | 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | --------------------------------------------------------------------------------