├── .github
├── FUNDING.yml
├── dependabot.yml
├── stale.yml
└── workflows
│ ├── pub_dry_run.yml
│ └── pub_publish.yml
├── .gitignore
├── .metadata
├── CHANGELOG.md
├── CODEOWNERS
├── LICENSE
├── README.md
├── analysis_options.yaml
├── example
├── .gitignore
├── .metadata
├── README.md
├── analysis_options.yaml
├── android
│ ├── .gitignore
│ ├── app
│ │ ├── build.gradle
│ │ └── src
│ │ │ ├── debug
│ │ │ └── AndroidManifest.xml
│ │ │ ├── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── flutterhsvcolorpickerexample
│ │ │ │ │ └── MainActivity.java
│ │ │ ├── kotlin
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── example
│ │ │ │ │ └── MainActivity.kt
│ │ │ └── res
│ │ │ │ ├── drawable-v21
│ │ │ │ └── launch_background.xml
│ │ │ │ ├── drawable
│ │ │ │ └── launch_background.xml
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── values-night
│ │ │ │ └── styles.xml
│ │ │ │ └── values
│ │ │ │ └── styles.xml
│ │ │ └── profile
│ │ │ └── AndroidManifest.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ └── gradle-wrapper.properties
│ └── settings.gradle
├── ios
│ ├── .gitignore
│ ├── Flutter
│ │ ├── AppFrameworkInfo.plist
│ │ ├── Debug.xcconfig
│ │ └── Release.xcconfig
│ ├── Runner.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcshareddata
│ │ │ │ ├── IDEWorkspaceChecks.plist
│ │ │ │ └── WorkspaceSettings.xcsettings
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ └── Runner.xcscheme
│ ├── Runner.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ ├── IDEWorkspaceChecks.plist
│ │ │ └── WorkspaceSettings.xcsettings
│ ├── Runner
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── 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
│ │ └── main.m
│ └── RunnerTests
│ │ └── RunnerTests.swift
├── lib
│ ├── complex_example
│ │ ├── alpha_picker_page.dart
│ │ ├── color_picker_page.dart
│ │ ├── hex_picker_page.dart
│ │ ├── hsv_picker_page.dart
│ │ ├── main.dart
│ │ ├── palette_hue_picker_page.dart
│ │ ├── palette_picker_page.dart
│ │ ├── palette_saturation_picker_page.dart
│ │ ├── palette_value_picker_page.dart
│ │ ├── rgb_picker_page.dart
│ │ ├── slider_picker_page.dart
│ │ ├── swatches_picker_page.dart
│ │ └── wheel_picker_page.dart
│ └── main.dart
├── linux
│ ├── .gitignore
│ ├── CMakeLists.txt
│ ├── flutter
│ │ ├── CMakeLists.txt
│ │ ├── generated_plugin_registrant.cc
│ │ ├── generated_plugin_registrant.h
│ │ └── generated_plugins.cmake
│ ├── main.cc
│ ├── my_application.cc
│ └── my_application.h
├── macos
│ ├── .gitignore
│ ├── Flutter
│ │ ├── Flutter-Debug.xcconfig
│ │ ├── Flutter-Release.xcconfig
│ │ └── GeneratedPluginRegistrant.swift
│ ├── Runner.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ └── xcshareddata
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ └── Runner.xcscheme
│ ├── Runner.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ ├── Runner
│ │ ├── AppDelegate.swift
│ │ ├── Assets.xcassets
│ │ │ └── AppIcon.appiconset
│ │ │ │ ├── Contents.json
│ │ │ │ ├── app_icon_1024.png
│ │ │ │ ├── app_icon_128.png
│ │ │ │ ├── app_icon_16.png
│ │ │ │ ├── app_icon_256.png
│ │ │ │ ├── app_icon_32.png
│ │ │ │ ├── app_icon_512.png
│ │ │ │ └── app_icon_64.png
│ │ ├── Base.lproj
│ │ │ └── MainMenu.xib
│ │ ├── Configs
│ │ │ ├── AppInfo.xcconfig
│ │ │ ├── Debug.xcconfig
│ │ │ ├── Release.xcconfig
│ │ │ └── Warnings.xcconfig
│ │ ├── DebugProfile.entitlements
│ │ ├── Info.plist
│ │ ├── MainFlutterWindow.swift
│ │ └── Release.entitlements
│ └── RunnerTests
│ │ └── RunnerTests.swift
├── packages
│ └── Avatar.jpg
├── pubspec.yaml
├── web
│ ├── favicon.png
│ ├── icons
│ │ ├── Icon-192.png
│ │ ├── Icon-512.png
│ │ ├── Icon-maskable-192.png
│ │ └── Icon-maskable-512.png
│ ├── index.html
│ └── manifest.json
└── windows
│ ├── .gitignore
│ ├── CMakeLists.txt
│ ├── flutter
│ ├── CMakeLists.txt
│ ├── generated_plugin_registrant.cc
│ ├── generated_plugin_registrant.h
│ └── generated_plugins.cmake
│ └── runner
│ ├── CMakeLists.txt
│ ├── Runner.rc
│ ├── flutter_window.cpp
│ ├── flutter_window.h
│ ├── main.cpp
│ ├── resource.h
│ ├── resources
│ └── app_icon.ico
│ ├── runner.exe.manifest
│ ├── utils.cpp
│ ├── utils.h
│ ├── win32_window.cpp
│ └── win32_window.h
├── lib
├── flutter_hsvcolor_picker.dart
└── src
│ ├── color_picker.dart
│ ├── pickers
│ ├── hsv_picker.dart
│ ├── palette_hue_picker.dart
│ ├── palette_saturation_picker.dart
│ ├── palette_value_picker.dart
│ ├── rgb_picker.dart
│ ├── swatches_picker.dart
│ └── wheel_picker.dart
│ └── widgets
│ ├── alpha_picker.dart
│ ├── hex_picker.dart
│ ├── palette_picker.dart
│ ├── slider_picker.dart
│ └── slider_title.dart
├── pubspec.yaml
└── screenshot
├── design.png
├── logo.png
└── phone.png
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | # github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 | #patreon: # Replace with a single Patreon username
5 | #open_collective: # Replace with a single Open Collective username
6 | #ko_fi: # Replace with a single Ko-fi username
7 | #tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | #community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: zmtzawqlp
10 | #issuehunt: # Replace with a single IssueHunt username
11 | #otechie: # Replace with a single Otechie username
12 | custom: http://zmtzawqlp.gitee.io/my_images/images/qrcode.png
13 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | # To get started with Dependabot version updates, you'll need to specify which
2 | # package ecosystems to update and where the package manifests are located.
3 | # Please see the documentation for all configuration options:
4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5 |
6 | version: 2
7 | updates:
8 | - package-ecosystem: "github-actions"
9 | directory: "/"
10 | schedule:
11 | interval: "weekly"
12 |
13 | - package-ecosystem: "pub"
14 | directory: "/"
15 | schedule:
16 | interval: "weekly"
17 | ignore:
18 | - dependency-name: "*"
19 | update-types: ["version-update:semver-minor", "version-update:semver-patch"]
20 |
21 | - package-ecosystem: "pub"
22 | directory: "example"
23 | schedule:
24 | interval: "weekly"
25 | ignore:
26 | - dependency-name: "*"
27 | update-types: ["version-update:semver-minor", "version-update:semver-patch"]
28 |
29 | - package-ecosystem: "gradle"
30 | directory: "example/android"
31 | schedule:
32 | interval: "weekly"
33 |
--------------------------------------------------------------------------------
/.github/stale.yml:
--------------------------------------------------------------------------------
1 | # Number of days of inactivity before an issue becomes stale
2 | daysUntilStale: 30
3 | # Number of days of inactivity before a stale issue is closed
4 | daysUntilClose: 7
5 | # Issues with these labels will never be considered stale
6 | exemptLabels:
7 | - pinned
8 | - security
9 | # Label to use when marking an issue as stale
10 | staleLabel: wontfix
11 | # Comment to post when marking an issue as stale. Set to `false` to disable
12 | markComment: >
13 | This issue has been automatically marked as stale because it has not had
14 | recent activity. It will be closed if no further activity occurs. Thank you
15 | for your contributions.
16 | # Comment to post when closing a stale issue. Set to `false` to disable
17 | closeComment: true
--------------------------------------------------------------------------------
/.github/workflows/pub_dry_run.yml:
--------------------------------------------------------------------------------
1 | name: Pub Publish dry run
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 | pull_request:
8 | branches:
9 | - main
10 |
11 | jobs:
12 | publish:
13 | runs-on: ubuntu-latest
14 | steps:
15 | - name: Checkout
16 | uses: actions/checkout@v4
17 | - name: Dry run
18 | uses: k-paxian/dart-package-publisher@v1.6
19 | with:
20 | credentialJson: 'MockCredentialJson'
21 | flutter: true
22 | dryRunOnly: true
23 | skipTests: true
24 |
--------------------------------------------------------------------------------
/.github/workflows/pub_publish.yml:
--------------------------------------------------------------------------------
1 | name: Pub Publish plugin
2 |
3 | on:
4 | release:
5 | types: [published]
6 | workflow_dispatch:
7 |
8 | jobs:
9 | publish:
10 | runs-on: ubuntu-latest
11 | steps:
12 | - name: Checkout
13 | uses: actions/checkout@v4
14 | - name: Publish
15 | uses: k-paxian/dart-package-publisher@v1.6
16 | with:
17 | credentialJson: ${{ secrets.CREDENTIAL_JSON }}
18 | flutter: true
19 | skipTests: true
20 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 |
12 | # IntelliJ related
13 | *.iml
14 | *.ipr
15 | *.iws
16 | .idea/
17 |
18 | # The .vscode folder contains launch configuration and tasks you configure in
19 | # VS Code which you may wish to be included in version control, so this line
20 | # is commented out by default.
21 | #.vscode/
22 |
23 | # Flutter/Dart/Pub related
24 | **/doc/api/
25 | .dart_tool/
26 | .flutter-plugins
27 | .flutter-plugins-dependencies
28 | .packages
29 | .pub-cache/
30 | .pub/
31 | build/
32 |
33 | # Android related
34 | **/android/**/gradle-wrapper.jar
35 | **/android/.gradle
36 | **/android/captures/
37 | **/android/gradlew
38 | **/android/gradlew.bat
39 | **/android/local.properties
40 | **/android/**/GeneratedPluginRegistrant.java
41 |
42 | # iOS/XCode related
43 | **/ios/**/*.mode1v3
44 | **/ios/**/*.mode2v3
45 | **/ios/**/*.moved-aside
46 | **/ios/**/*.pbxuser
47 | **/ios/**/*.perspectivev3
48 | **/ios/**/*sync/
49 | **/ios/**/.sconsign.dblite
50 | **/ios/**/.tags*
51 | **/ios/**/.vagrant/
52 | **/ios/**/DerivedData/
53 | **/ios/**/Icon?
54 | **/ios/**/Pods/
55 | **/ios/**/.symlinks/
56 | **/ios/**/profile
57 | **/ios/**/xcuserdata
58 | **/ios/.generated/
59 | **/ios/Flutter/App.framework
60 | **/ios/Flutter/Flutter.framework
61 | **/ios/Flutter/Flutter.podspec
62 | **/ios/Flutter/Generated.xcconfig
63 | **/ios/Flutter/app.flx
64 | **/ios/Flutter/app.zip
65 | **/ios/Flutter/flutter_assets/
66 | **/ios/Flutter/flutter_export_environment.sh
67 | **/ios/ServiceDefinitions.json
68 | **/ios/Runner/GeneratedPluginRegistrant.*
69 |
70 | # Exceptions to above rules.
71 | !**/ios/**/default.mode1v3
72 | !**/ios/**/default.mode2v3
73 | !**/ios/**/default.pbxuser
74 | !**/ios/**/default.perspectivev3
75 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
76 | *.lock
77 | .env
78 | example/macos/Flutter/ephemeral/Flutter-Generated.xcconfig
79 | example/macos/Flutter/ephemeral/flutter_export_environment.sh
80 |
--------------------------------------------------------------------------------
/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: 985ccb6d14c6ce5ce74823a4d366df2438eac44f
8 | channel: beta
9 |
10 | project_type: package
11 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## [1.5.1]
2 |
3 | * Update example app.
4 | * Widen `flutter_lints` constraints.
5 |
6 | ## [1.5.0]
7 |
8 | * Add `showPalette` to `WheelPicker`.
9 | * Add `paletteHeight` to `ColorPicker`, `PaletteHuePicker`, `PaletteSaturationPicker`, and `PaletteValuePicker`.
10 |
11 | ## [1.4.0+1]
12 |
13 | * Update image paths in readme.
14 |
15 | ## [1.4.0]
16 |
17 | * Update dependencies.
18 | * Rename to `main` branch, and update links in readme.
19 |
20 | ## [1.3.0]
21 |
22 | * Expose some decoration properties for PaletteHuePicker.
23 | * Update deprecated theme variables
24 | * Updates in example app.
25 |
26 | ## [1.2.3]
27 |
28 | * Fix bug on color change where previously set alpha value was ignored.
29 |
30 | ## [1.2.2]
31 |
32 | * Update example app.
33 |
34 | ## [1.2.1]
35 |
36 | * Add `pickerOrientation` to `ColorPicker` to lock the orientation if needed.
37 | * Improve documentation.
38 |
39 | ## [1.2.0]
40 |
41 | * Update deprecated theme color (accentColor -> colorScheme.secondary).
42 | * Improve UI.
43 | * Refactor folder structure.
44 |
45 | ## [1.1.0]
46 |
47 | * Fix ColorPicker not shown in landscape mode.
48 | * Fix alpha slider not changing the alpha value of color.
49 | * Add initialPicker for changing the first picker of ColorPicker.
50 |
51 | ## [1.0.2]
52 |
53 | * Publishing test.
54 | ## [1.0.1]
55 |
56 | * Add .github files.
57 | ## [1.0.0]
58 |
59 | * Migrate to null safety.
60 |
61 | ## [0.1.1]
62 |
63 | * Describe initial release.
64 |
65 | ## [0.1.2]
66 |
67 | * Some bugs have been improved.
68 |
--------------------------------------------------------------------------------
/CODEOWNERS:
--------------------------------------------------------------------------------
1 | * @nohli @AlexV525
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # flutter_hsvcolor_picker
2 |
3 | An HSV color picker designed for your Flutter app.
4 |
5 | Pickers: RGB, HSV, Color Wheel, Palette Hue, Palette Saturation, Palette Value, Swatches.
6 |
7 | 
8 |
9 | ## Getting Started
10 | 
11 |
12 |
13 | ### Installation
14 |
15 | https://pub.dev/packages/flutter_hsvcolor_picker/install
16 |
17 |
18 | ### Example
19 |
20 | ```dart
21 |
22 | import "package:flutter_hsvcolor_picker/flutter_hsvcolor_picker.dart";
23 |
24 | ColorPicker(
25 | color: Colors.blue,
26 | onChanged: (value){ },
27 | initialPicker: Picker.paletteHue,
28 | )
29 | ```
30 |
31 | For a more detailed example, head over to: https://github.com/fluttercandies/flutter_hsvcolor_picker/tree/main/example/lib/complex_example
32 |
33 | 
34 |
--------------------------------------------------------------------------------
/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | include: package:flutter_lints/flutter.yaml
2 |
3 | analyzer:
4 | language:
5 | strict-casts: true
6 | strict-inference: true
7 | strict-raw-types: true
8 | errors:
9 | todo: info
10 | linter:
11 | rules:
12 | - always_put_required_named_parameters_first
13 | - lines_longer_than_80_chars
14 | # - public_member_api_docs
15 | - prefer_single_quotes
16 | - sort_child_properties_last
17 | - sort_constructors_first
18 | - sort_pub_dependencies
19 |
--------------------------------------------------------------------------------
/example/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 |
12 | # IntelliJ related
13 | *.iml
14 | *.ipr
15 | *.iws
16 | .idea/
17 |
18 | # The .vscode folder contains launch configuration and tasks you configure in
19 | # VS Code which you may wish to be included in version control, so this line
20 | # is commented out by default.
21 | #.vscode/
22 |
23 | # Flutter/Dart/Pub related
24 | **/doc/api/
25 | **/ios/Flutter/.last_build_id
26 | **/ios/Flutter/flutter_export_environment.sh
27 | .dart_tool/
28 | .flutter-plugins
29 | .flutter-plugins-dependencies
30 | .packages
31 | .pub-cache/
32 | .pub/
33 | /build/
34 |
35 | # Web related
36 | lib/generated_plugin_registrant.dart
37 |
38 | # Symbolication related
39 | app.*.symbols
40 |
41 | # Obfuscation related
42 | app.*.map.json
43 |
--------------------------------------------------------------------------------
/example/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: "a14f74ff3a1cbd521163c5f03d68113d50af93d3"
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: a14f74ff3a1cbd521163c5f03d68113d50af93d3
17 | base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
18 | - platform: android
19 | create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
20 | base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
21 | - platform: ios
22 | create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
23 | base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
24 | - platform: linux
25 | create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
26 | base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
27 | - platform: macos
28 | create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
29 | base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
30 | - platform: web
31 | create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
32 | base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
33 | - platform: windows
34 | create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
35 | base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
36 |
37 | # User provided section
38 |
39 | # List of Local paths (relative to this file) that should be
40 | # ignored by the migrate tool.
41 | #
42 | # Files that are not part of the templates will be ignored by default.
43 | unmanaged_files:
44 | - 'lib/main.dart'
45 | - 'ios/Runner.xcodeproj/project.pbxproj'
46 |
--------------------------------------------------------------------------------
/example/README.md:
--------------------------------------------------------------------------------
1 | # flutter_hsvcolor_picker_example
2 |
3 | A new Flutter project.
4 |
5 | ## Getting Started
6 |
7 | This project is a starting point for a Flutter application.
8 |
9 | A few resources to get you started if this is your first Flutter project:
10 |
11 | - [Lab: Write your first Flutter app](https://flutter.io/docs/get-started/codelab)
12 | - [Cookbook: Useful Flutter samples](https://flutter.io/docs/cookbook)
13 |
14 | For help getting started with Flutter, view our
15 | [online documentation](https://flutter.io/docs), which offers tutorials,
16 | samples, guidance on mobile development, and a full API reference.
17 |
--------------------------------------------------------------------------------
/example/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | include: package:flutter_lints/flutter.yaml
2 |
3 | analyzer:
4 | language:
5 | strict-casts: true
6 | strict-inference: true
7 | strict-raw-types: true
8 | errors:
9 | todo: info
10 | linter:
11 | rules:
12 | - always_put_required_named_parameters_first
13 | - lines_longer_than_80_chars
14 | # - public_member_api_docs
15 | - prefer_single_quotes
16 | - sort_child_properties_last
17 | - sort_constructors_first
18 | - sort_pub_dependencies
19 |
--------------------------------------------------------------------------------
/example/android/.gitignore:
--------------------------------------------------------------------------------
1 | gradle-wrapper.jar
2 | /.gradle
3 | /captures/
4 | /gradlew
5 | /gradlew.bat
6 | /local.properties
7 | GeneratedPluginRegistrant.java
8 |
9 | # Remember to never publicly share your keystore.
10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
11 | key.properties
12 | **/*.keystore
13 | **/*.jks
14 |
--------------------------------------------------------------------------------
/example/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id "com.android.application"
3 | id "kotlin-android"
4 | // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
5 | id "dev.flutter.flutter-gradle-plugin"
6 | }
7 |
8 | def localProperties = new Properties()
9 | def localPropertiesFile = rootProject.file("local.properties")
10 | if (localPropertiesFile.exists()) {
11 | localPropertiesFile.withReader("UTF-8") { reader ->
12 | localProperties.load(reader)
13 | }
14 | }
15 |
16 | def flutterVersionCode = localProperties.getProperty("flutter.versionCode")
17 | if (flutterVersionCode == null) {
18 | flutterVersionCode = "1"
19 | }
20 |
21 | def flutterVersionName = localProperties.getProperty("flutter.versionName")
22 | if (flutterVersionName == null) {
23 | flutterVersionName = "1.0"
24 | }
25 |
26 | android {
27 | namespace = "com.example.example"
28 | compileSdk = flutter.compileSdkVersion
29 | ndkVersion = flutter.ndkVersion
30 |
31 | compileOptions {
32 | sourceCompatibility = JavaVersion.VERSION_17
33 | targetCompatibility = JavaVersion.VERSION_17
34 | }
35 |
36 | defaultConfig {
37 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
38 | applicationId = "com.example.example"
39 | // You can update the following values to match your application needs.
40 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
41 | minSdk = flutter.minSdkVersion
42 | targetSdk = flutter.targetSdkVersion
43 | versionCode = flutterVersionCode.toInteger()
44 | versionName = flutterVersionName
45 | }
46 |
47 | buildTypes {
48 | release {
49 | // TODO: Add your own signing config for the release build.
50 | // Signing with the debug keys for now, so `flutter run --release` works.
51 | signingConfig = signingConfigs.debug
52 | }
53 | }
54 | }
55 |
56 | flutter {
57 | source = "../.."
58 | }
59 |
--------------------------------------------------------------------------------
/example/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
15 |
19 |
23 |
24 |
25 |
26 |
27 |
28 |
30 |
33 |
34 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/example/android/app/src/main/java/com/example/flutterhsvcolorpickerexample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.flutterhsvcolorpickerexample;
2 |
3 | import io.flutter.embedding.android.FlutterActivity;
4 |
5 | public class MainActivity extends FlutterActivity {
6 | }
7 |
--------------------------------------------------------------------------------
/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.example.example
2 |
3 | import io.flutter.embedding.android.FlutterActivity
4 |
5 | class MainActivity: FlutterActivity()
6 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/drawable-v21/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/drawable/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values-night/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/example/android/app/src/profile/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/android/build.gradle:
--------------------------------------------------------------------------------
1 | allprojects {
2 | repositories {
3 | google()
4 | mavenCentral()
5 | }
6 | }
7 |
8 | rootProject.buildDir = "../build"
9 | subprojects {
10 | project.buildDir = "${rootProject.buildDir}/${project.name}"
11 | }
12 | subprojects {
13 | project.evaluationDependsOn(":app")
14 | }
15 |
16 | tasks.register("clean", Delete) {
17 | delete rootProject.buildDir
18 | }
19 |
--------------------------------------------------------------------------------
/example/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx4G -XX:+HeapDumpOnOutOfMemoryError
2 | android.useAndroidX=true
3 | android.enableJetifier=true
4 |
--------------------------------------------------------------------------------
/example/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | zipStoreBase=GRADLE_USER_HOME
4 | zipStorePath=wrapper/dists
5 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
6 |
--------------------------------------------------------------------------------
/example/android/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | def flutterSdkPath = {
3 | def properties = new Properties()
4 | file("local.properties").withInputStream { properties.load(it) }
5 | def flutterSdkPath = properties.getProperty("flutter.sdk")
6 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
7 | return flutterSdkPath
8 | }()
9 |
10 | includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
11 |
12 | repositories {
13 | google()
14 | mavenCentral()
15 | gradlePluginPortal()
16 | }
17 | }
18 |
19 | plugins {
20 | id "dev.flutter.flutter-plugin-loader" version "1.0.0"
21 | id "com.android.application" version "8.10.1" apply false
22 | id "org.jetbrains.kotlin.android" version "2.1.21" apply false
23 | }
24 |
25 | include ":app"
26 |
--------------------------------------------------------------------------------
/example/ios/.gitignore:
--------------------------------------------------------------------------------
1 | **/dgph
2 | *.mode1v3
3 | *.mode2v3
4 | *.moved-aside
5 | *.pbxuser
6 | *.perspectivev3
7 | **/*sync/
8 | .sconsign.dblite
9 | .tags*
10 | **/.vagrant/
11 | **/DerivedData/
12 | Icon?
13 | **/Pods/
14 | **/.symlinks/
15 | profile
16 | xcuserdata
17 | **/.generated/
18 | Flutter/App.framework
19 | Flutter/Flutter.framework
20 | Flutter/Flutter.podspec
21 | Flutter/Generated.xcconfig
22 | Flutter/ephemeral/
23 | Flutter/app.flx
24 | Flutter/app.zip
25 | Flutter/flutter_assets/
26 | Flutter/flutter_export_environment.sh
27 | ServiceDefinitions.json
28 | Runner/GeneratedPluginRegistrant.*
29 |
30 | # Exceptions to above rules.
31 | !default.mode1v3
32 | !default.mode2v3
33 | !default.pbxuser
34 | !default.perspectivev3
35 |
--------------------------------------------------------------------------------
/example/ios/Flutter/AppFrameworkInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | App
9 | CFBundleIdentifier
10 | io.flutter.flutter.app
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | App
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 | MinimumOSVersion
24 | 12.0
25 |
26 |
27 |
--------------------------------------------------------------------------------
/example/ios/Flutter/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/example/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
31 |
32 |
33 |
34 |
40 |
41 |
42 |
43 |
44 |
45 |
56 |
58 |
64 |
65 |
66 |
67 |
68 |
69 |
75 |
77 |
83 |
84 |
85 |
86 |
88 |
89 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/Runner/AppDelegate.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | @interface AppDelegate : FlutterAppDelegate
5 |
6 | @end
7 |
--------------------------------------------------------------------------------
/example/ios/Runner/AppDelegate.m:
--------------------------------------------------------------------------------
1 | #include "AppDelegate.h"
2 | #include "GeneratedPluginRegistrant.h"
3 |
4 | @implementation AppDelegate
5 |
6 | - (BOOL)application:(UIApplication *)application
7 | didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
8 | [GeneratedPluginRegistrant registerWithRegistry:self];
9 | // Override point for customization after application launch.
10 | return [super application:application didFinishLaunchingWithOptions:launchOptions];
11 | }
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/example/ios/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import Flutter
2 | import UIKit
3 |
4 | @UIApplicationMain
5 | @objc class AppDelegate: FlutterAppDelegate {
6 | override func application(
7 | _ application: UIApplication,
8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
9 | ) -> Bool {
10 | GeneratedPluginRegistrant.register(with: self)
11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "20x20",
5 | "idiom" : "iphone",
6 | "filename" : "Icon-App-20x20@2x.png",
7 | "scale" : "2x"
8 | },
9 | {
10 | "size" : "20x20",
11 | "idiom" : "iphone",
12 | "filename" : "Icon-App-20x20@3x.png",
13 | "scale" : "3x"
14 | },
15 | {
16 | "size" : "29x29",
17 | "idiom" : "iphone",
18 | "filename" : "Icon-App-29x29@1x.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "29x29",
23 | "idiom" : "iphone",
24 | "filename" : "Icon-App-29x29@2x.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "29x29",
29 | "idiom" : "iphone",
30 | "filename" : "Icon-App-29x29@3x.png",
31 | "scale" : "3x"
32 | },
33 | {
34 | "size" : "40x40",
35 | "idiom" : "iphone",
36 | "filename" : "Icon-App-40x40@2x.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "40x40",
41 | "idiom" : "iphone",
42 | "filename" : "Icon-App-40x40@3x.png",
43 | "scale" : "3x"
44 | },
45 | {
46 | "size" : "60x60",
47 | "idiom" : "iphone",
48 | "filename" : "Icon-App-60x60@2x.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "60x60",
53 | "idiom" : "iphone",
54 | "filename" : "Icon-App-60x60@3x.png",
55 | "scale" : "3x"
56 | },
57 | {
58 | "size" : "20x20",
59 | "idiom" : "ipad",
60 | "filename" : "Icon-App-20x20@1x.png",
61 | "scale" : "1x"
62 | },
63 | {
64 | "size" : "20x20",
65 | "idiom" : "ipad",
66 | "filename" : "Icon-App-20x20@2x.png",
67 | "scale" : "2x"
68 | },
69 | {
70 | "size" : "29x29",
71 | "idiom" : "ipad",
72 | "filename" : "Icon-App-29x29@1x.png",
73 | "scale" : "1x"
74 | },
75 | {
76 | "size" : "29x29",
77 | "idiom" : "ipad",
78 | "filename" : "Icon-App-29x29@2x.png",
79 | "scale" : "2x"
80 | },
81 | {
82 | "size" : "40x40",
83 | "idiom" : "ipad",
84 | "filename" : "Icon-App-40x40@1x.png",
85 | "scale" : "1x"
86 | },
87 | {
88 | "size" : "40x40",
89 | "idiom" : "ipad",
90 | "filename" : "Icon-App-40x40@2x.png",
91 | "scale" : "2x"
92 | },
93 | {
94 | "size" : "76x76",
95 | "idiom" : "ipad",
96 | "filename" : "Icon-App-76x76@1x.png",
97 | "scale" : "1x"
98 | },
99 | {
100 | "size" : "76x76",
101 | "idiom" : "ipad",
102 | "filename" : "Icon-App-76x76@2x.png",
103 | "scale" : "2x"
104 | },
105 | {
106 | "size" : "83.5x83.5",
107 | "idiom" : "ipad",
108 | "filename" : "Icon-App-83.5x83.5@2x.png",
109 | "scale" : "2x"
110 | },
111 | {
112 | "size" : "1024x1024",
113 | "idiom" : "ios-marketing",
114 | "filename" : "Icon-App-1024x1024@1x.png",
115 | "scale" : "1x"
116 | }
117 | ],
118 | "info" : {
119 | "version" : 1,
120 | "author" : "xcode"
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchImage.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchImage@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "filename" : "LaunchImage@3x.png",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md:
--------------------------------------------------------------------------------
1 | # Launch Screen Assets
2 |
3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory.
4 |
5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.
--------------------------------------------------------------------------------
/example/ios/Runner/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/example/ios/Runner/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/example/ios/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | flutter_hsvcolor_picker_example
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | $(FLUTTER_BUILD_NAME)
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(FLUTTER_BUILD_NUMBER)
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UISupportedInterfaceOrientations
30 |
31 | UIInterfaceOrientationPortrait
32 | UIInterfaceOrientationLandscapeLeft
33 | UIInterfaceOrientationLandscapeRight
34 |
35 | UISupportedInterfaceOrientations~ipad
36 |
37 | UIInterfaceOrientationPortrait
38 | UIInterfaceOrientationPortraitUpsideDown
39 | UIInterfaceOrientationLandscapeLeft
40 | UIInterfaceOrientationLandscapeRight
41 |
42 | UIViewControllerBasedStatusBarAppearance
43 |
44 | CADisableMinimumFrameDurationOnPhone
45 |
46 | UIApplicationSupportsIndirectInputEvents
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/example/ios/Runner/Runner-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | #import "GeneratedPluginRegistrant.h"
2 |
--------------------------------------------------------------------------------
/example/ios/Runner/main.m:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 | #import "AppDelegate.h"
4 |
5 | int main(int argc, char* argv[]) {
6 | @autoreleasepool {
7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/example/ios/RunnerTests/RunnerTests.swift:
--------------------------------------------------------------------------------
1 | import Flutter
2 | import UIKit
3 | import XCTest
4 |
5 | class RunnerTests: XCTestCase {
6 |
7 | func testExample() {
8 | // If you add code to the Runner application, consider adding tests here.
9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest.
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/example/lib/complex_example/alpha_picker_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_hsvcolor_picker/flutter_hsvcolor_picker.dart';
3 |
4 | class AlphaPickerPage extends StatefulWidget {
5 | const AlphaPickerPage({Key? key}) : super(key: key);
6 |
7 | @override
8 | State createState() => _AlphaPickerPageState();
9 | }
10 |
11 | class _AlphaPickerPageState extends State {
12 | int value = 0;
13 | void onChanged(int value) => this.value = value;
14 |
15 | @override
16 | Widget build(BuildContext context) {
17 | return Center(
18 | child: SizedBox(
19 | width: 260,
20 | child: Card(
21 | shape: const RoundedRectangleBorder(
22 | borderRadius: BorderRadius.all(
23 | Radius.circular(0.0),
24 | ),
25 | ),
26 | elevation: 2.0,
27 | child: Padding(
28 | padding: const EdgeInsets.all(10),
29 | child: Column(
30 | mainAxisSize: MainAxisSize.min,
31 | children: [
32 | Text(
33 | value.toString(),
34 | style: Theme.of(context).textTheme.headlineMedium,
35 | ),
36 | const Divider(),
37 |
38 | ///---------------------------------
39 | AlphaPicker(
40 | alpha: value,
41 | onChanged: (value) => super.setState(
42 | () => onChanged(value),
43 | ),
44 | )
45 |
46 | ///---------------------------------
47 | ],
48 | ),
49 | ),
50 | ),
51 | ),
52 | );
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/example/lib/complex_example/color_picker_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import 'package:flutter_hsvcolor_picker/flutter_hsvcolor_picker.dart';
4 |
5 | class ColorPickerPage extends StatefulWidget {
6 | const ColorPickerPage({Key? key}) : super(key: key);
7 |
8 | @override
9 | State createState() => _ColorPickerPageState();
10 | }
11 |
12 | class _ColorPickerPageState extends State {
13 | @override
14 | Widget build(BuildContext context) {
15 | return Center(
16 | child: SizedBox(
17 | width: 300,
18 | child: Card(
19 | shape: const RoundedRectangleBorder(
20 | borderRadius: BorderRadius.all(
21 | Radius.circular(1.0),
22 | ),
23 | ),
24 | elevation: 4.0,
25 | child: Padding(
26 | padding: const EdgeInsets.symmetric(
27 | horizontal: 14.0,
28 | vertical: 2.0,
29 | ),
30 |
31 | ///---------------------------------
32 | child: ColorPicker(
33 | color: Colors.blue,
34 | onChanged: (value) {},
35 | ),
36 |
37 | ///---------------------------------
38 | ),
39 | ),
40 | ),
41 | );
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/example/lib/complex_example/hex_picker_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import 'package:flutter_hsvcolor_picker/flutter_hsvcolor_picker.dart';
4 |
5 | class HexPickerPage extends StatefulWidget {
6 | const HexPickerPage({Key? key}) : super(key: key);
7 |
8 | @override
9 | State createState() => _HexPickerPageState();
10 | }
11 |
12 | class _HexPickerPageState extends State {
13 | Color color = Colors.blue;
14 | void onChanged(Color value) => color = value;
15 |
16 | @override
17 | Widget build(BuildContext context) {
18 | return Center(
19 | child: SizedBox(
20 | width: 260,
21 | child: Card(
22 | shape: const RoundedRectangleBorder(
23 | borderRadius: BorderRadius.all(
24 | Radius.circular(0.0),
25 | ),
26 | ),
27 | elevation: 2.0,
28 | child: Padding(
29 | padding: const EdgeInsets.all(10),
30 | child: Column(
31 | mainAxisSize: MainAxisSize.min,
32 | children: [
33 | FloatingActionButton(
34 | onPressed: () {},
35 | backgroundColor: color,
36 | ),
37 | const Divider(),
38 |
39 | ///---------------------------------
40 | HexPicker(
41 | color: color,
42 | onChanged: (value) => super.setState(
43 | () => onChanged(value),
44 | ),
45 | )
46 |
47 | ///---------------------------------
48 | ],
49 | ),
50 | ),
51 | ),
52 | ),
53 | );
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/example/lib/complex_example/hsv_picker_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import 'package:flutter_hsvcolor_picker/flutter_hsvcolor_picker.dart';
4 |
5 | class HSVPickerPage extends StatefulWidget {
6 | const HSVPickerPage({Key? key}) : super(key: key);
7 |
8 | @override
9 | State createState() => _HSVPickerPageState();
10 | }
11 |
12 | class _HSVPickerPageState extends State {
13 | HSVColor color = HSVColor.fromColor(Colors.blue);
14 | void onChanged(HSVColor value) => color = value;
15 |
16 | @override
17 | Widget build(BuildContext context) {
18 | return Center(
19 | child: SizedBox(
20 | width: 260,
21 | child: Card(
22 | shape: const RoundedRectangleBorder(
23 | borderRadius: BorderRadius.all(
24 | Radius.circular(0.0),
25 | ),
26 | ),
27 | elevation: 2.0,
28 | child: Padding(
29 | padding: const EdgeInsets.all(10),
30 | child: Column(
31 | mainAxisSize: MainAxisSize.min,
32 | children: [
33 | FloatingActionButton(
34 | onPressed: () {},
35 | backgroundColor: color.toColor(),
36 | ),
37 | const Divider(),
38 |
39 | ///---------------------------------
40 | HSVPicker(
41 | color: color,
42 | onChanged: (value) => super.setState(
43 | () => onChanged(value),
44 | ),
45 | )
46 |
47 | ///---------------------------------
48 | ],
49 | ),
50 | ),
51 | ),
52 | ),
53 | );
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/example/lib/complex_example/main.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import 'alpha_picker_page.dart';
4 | import 'color_picker_page.dart';
5 | import 'hex_picker_page.dart';
6 | import 'hsv_picker_page.dart';
7 | import 'palette_hue_picker_page.dart';
8 | import 'palette_picker_page.dart';
9 | import 'palette_saturation_picker_page.dart';
10 | import 'palette_value_picker_page.dart';
11 | import 'rgb_picker_page.dart';
12 | import 'slider_picker_page.dart';
13 | import 'swatches_picker_page.dart';
14 | import 'wheel_picker_page.dart';
15 |
16 | void main() => runApp(const MyApp());
17 |
18 | class MyApp extends StatelessWidget {
19 | const MyApp({Key? key}) : super(key: key);
20 |
21 | @override
22 | Widget build(BuildContext context) {
23 | return const MainPage();
24 | }
25 | }
26 |
27 | class MainPage extends StatefulWidget {
28 | const MainPage({Key? key}) : super(key: key);
29 |
30 | @override
31 | State createState() => _MainPageState();
32 | }
33 |
34 | class _MainPageState extends State {
35 | GlobalKey scaffoldKey = GlobalKey();
36 |
37 | int index = 0;
38 | Widget? get page => items
39 | .firstWhere((item) => item == null ? false : item.index == index)
40 | ?.page;
41 | List<_MainItem?> items = [
42 | _MainItem(
43 | index: 0,
44 | icon: Icons.color_lens,
45 | text: 'Color Picker',
46 | page: const ColorPickerPage(),
47 | ),
48 | null,
49 | _MainItem(
50 | index: 1,
51 | icon: Icons.tune,
52 | text: 'RGB Picker',
53 | page: const RGBPickerPage(),
54 | ),
55 | _MainItem(
56 | index: 2,
57 | icon: Icons.tune,
58 | text: 'HSV Picker',
59 | page: const HSVPickerPage(),
60 | ),
61 | _MainItem(
62 | index: 3,
63 | icon: Icons.tune,
64 | text: 'Wheel Picker',
65 | page: const WheelPickerPage(),
66 | ),
67 | null,
68 | _MainItem(
69 | index: 4,
70 | icon: Icons.color_lens,
71 | text: 'Palette Hue Picker',
72 | page: const PaletteHuePickerPage(),
73 | ),
74 | _MainItem(
75 | index: 5,
76 | icon: Icons.color_lens,
77 | text: 'Palette Saturation Picker',
78 | page: const PaletteSaturationPickerPage(),
79 | ),
80 | _MainItem(
81 | index: 6,
82 | icon: Icons.color_lens,
83 | text: 'Palette Value Picker',
84 | page: const PaletteValuePickerPage(),
85 | ),
86 | null,
87 | _MainItem(
88 | index: 7,
89 | icon: Icons.mode_edit,
90 | text: 'Swatches Picker',
91 | page: const SwatchesPickerPage(),
92 | ),
93 | _MainItem(
94 | index: 8,
95 | icon: Icons.mode_edit,
96 | text: 'Hex Picker',
97 | page: const HexPickerPage(),
98 | ),
99 | _MainItem(
100 | index: 9,
101 | icon: Icons.mode_edit,
102 | text: 'Alpha Picker',
103 | page: const AlphaPickerPage(),
104 | ),
105 | null,
106 | _MainItem(
107 | index: 10,
108 | icon: Icons.linear_scale,
109 | text: 'Slider',
110 | page: const SliderPickerPage(),
111 | ),
112 | _MainItem(
113 | index: 11,
114 | icon: Icons.gradient,
115 | text: 'Palette',
116 | page: PalettePickerPage(),
117 | ),
118 | ];
119 |
120 | void iconButtonOnPressed() => scaffoldKey.currentState?.openDrawer();
121 | void listTileOnTap(_MainItem item) {
122 | index = item.index;
123 | scaffoldKey.currentState?.openEndDrawer();
124 | }
125 |
126 | // Theme
127 | bool isDark = false;
128 | ThemeData get theme => isDark ? themeDark : themeLight;
129 | ThemeData themeLight =
130 | ThemeData(brightness: Brightness.light, platform: TargetPlatform.iOS);
131 | ThemeData themeDark =
132 | ThemeData(brightness: Brightness.dark, platform: TargetPlatform.iOS);
133 | void setTheme() => super.setState(() => isDark = !isDark);
134 |
135 | PreferredSizeWidget buildAppBar() {
136 | return AppBar(
137 | elevation: 0.0,
138 | backgroundColor: theme.scaffoldBackgroundColor,
139 |
140 | // Center
141 | title: Center(
142 | child: Text(
143 | 'HSV Color',
144 | textAlign: TextAlign.center,
145 | style: theme.textTheme.headlineSmall,
146 | ),
147 | ),
148 |
149 | // Left
150 | leading: IconButton(
151 | onPressed: iconButtonOnPressed,
152 | icon: IconTheme(
153 | data: theme.iconTheme,
154 | child: const Icon(Icons.dehaze),
155 | ),
156 | ),
157 |
158 | // Right
159 | actions: [
160 | IconButton(
161 | onPressed: iconButtonOnPressed,
162 | icon: IconTheme(
163 | data: theme.iconTheme,
164 | child: const Icon(Icons.dehaze),
165 | ),
166 | )
167 | ],
168 | );
169 | }
170 |
171 | Widget buildDrawer() {
172 | return Drawer(
173 | child: DecoratedBox(
174 | decoration: BoxDecoration(color: theme.cardColor),
175 | child: Column(
176 | children: [
177 | // Header
178 | buildDrawerHeader(),
179 |
180 | // List
181 | Expanded(
182 | child: ListView(
183 | children: items.map(buildListViewItem).toList(),
184 | ),
185 | )
186 | ],
187 | ),
188 | ),
189 | );
190 | }
191 |
192 | Widget buildDrawerHeader() {
193 | return DrawerHeader(
194 | decoration: const BoxDecoration(color: Colors.blue),
195 | child: Stack(
196 | children: [
197 | // Avatar
198 | Align(
199 | alignment: Alignment.bottomLeft,
200 | child: Column(
201 | mainAxisSize: MainAxisSize.min,
202 | crossAxisAlignment: CrossAxisAlignment.start,
203 | children: [
204 | CircleAvatar(
205 | radius: 34.0,
206 | backgroundColor: theme.cardColor,
207 | backgroundImage: const AssetImage('packages/avatar.jpg'),
208 | ),
209 | const SizedBox(height: 10.0),
210 | const Padding(
211 | padding: EdgeInsets.only(bottom: 8),
212 | child: Text(
213 | '淹死的鱼ysdy44',
214 | style: TextStyle(color: Colors.white, fontSize: 18.0),
215 | ),
216 | )
217 | ],
218 | ),
219 | ),
220 |
221 | // Button
222 | Align(
223 | alignment: Alignment.bottomRight,
224 | child: ElevatedButton(
225 | onPressed: setTheme,
226 | style: ElevatedButton.styleFrom(
227 | backgroundColor: Colors.blue.shade400,
228 | shape: const StadiumBorder(),
229 | ),
230 | child: Text(
231 | theme.brightness == Brightness.dark ? 'Dark' : 'Light',
232 | style: const TextStyle(fontSize: 16.0, color: Colors.white),
233 | ),
234 | ),
235 | )
236 | ],
237 | ),
238 | );
239 | }
240 |
241 | Widget buildDrawer22() {
242 | return Drawer(
243 | child: DecoratedBox(
244 | decoration: BoxDecoration(color: theme.cardColor),
245 | child: CustomScrollView(
246 | scrollDirection: Axis.vertical,
247 | reverse: false,
248 | controller: ScrollController(),
249 | primary: false,
250 | physics: const ScrollPhysics(),
251 | shrinkWrap: false,
252 | slivers: [
253 | // Body
254 | SliverList(
255 | delegate: SliverChildListDelegate(
256 | [buildDrawerHeader()],
257 | ),
258 | ),
259 |
260 | // Body
261 | SliverList(
262 | delegate: SliverChildListDelegate(
263 | items.map(buildListViewItem).toList(),
264 | ),
265 | )
266 | ],
267 | ),
268 | ),
269 | );
270 | }
271 |
272 | Widget buildListViewItem(_MainItem? item) {
273 | if (item == null) return const Divider(height: 6.0);
274 |
275 | return ListTile(
276 | selected: item.index == index,
277 | leading: Icon(item.icon),
278 | title: Text(item.text),
279 | onTap: () => super.setState(
280 | () => listTileOnTap(item),
281 | ),
282 | );
283 | }
284 |
285 | @override
286 | Widget build(BuildContext context) {
287 | return MaterialApp(
288 | title: 'HSV Color',
289 | theme: theme,
290 | home: Scaffold(
291 | key: scaffoldKey,
292 | backgroundColor: theme.scaffoldBackgroundColor,
293 | body: page,
294 | appBar: buildAppBar(),
295 | drawer: buildDrawer22(),
296 | ),
297 | );
298 | }
299 | }
300 |
301 | class _MainItem {
302 | _MainItem({
303 | required this.index,
304 | required this.icon,
305 | required this.text,
306 | required this.page,
307 | });
308 |
309 | final int index;
310 | final IconData icon;
311 | final String text;
312 | final Widget page;
313 | }
314 |
--------------------------------------------------------------------------------
/example/lib/complex_example/palette_hue_picker_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import 'package:flutter_hsvcolor_picker/flutter_hsvcolor_picker.dart';
4 |
5 | class PaletteHuePickerPage extends StatefulWidget {
6 | const PaletteHuePickerPage({Key? key}) : super(key: key);
7 |
8 | @override
9 | State createState() => _PaletteHuePickerPageState();
10 | }
11 |
12 | class _PaletteHuePickerPageState extends State {
13 | HSVColor color = HSVColor.fromColor(Colors.blue);
14 | void onChanged(HSVColor value) => color = value;
15 |
16 | @override
17 | Widget build(BuildContext context) {
18 | return Center(
19 | child: SizedBox(
20 | width: 260,
21 | child: Card(
22 | shape: const RoundedRectangleBorder(
23 | borderRadius: BorderRadius.all(
24 | Radius.circular(0.0),
25 | ),
26 | ),
27 | elevation: 2.0,
28 | child: Padding(
29 | padding: const EdgeInsets.all(10),
30 | child: Column(
31 | mainAxisSize: MainAxisSize.min,
32 | children: [
33 | FloatingActionButton(
34 | onPressed: () {},
35 | backgroundColor: color.toColor(),
36 | ),
37 | const Divider(),
38 |
39 | ///---------------------------------
40 | PaletteHuePicker(
41 | color: color,
42 | onChanged: (value) => super.setState(
43 | () => onChanged(value),
44 | ),
45 | )
46 |
47 | ///---------------------------------
48 | ],
49 | ),
50 | ),
51 | ),
52 | ),
53 | );
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/example/lib/complex_example/palette_picker_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_hsvcolor_picker/flutter_hsvcolor_picker.dart';
3 |
4 | class PalettePickerPage extends StatefulWidget {
5 | PalettePickerPage({Key? key}) : super(key: key);
6 |
7 | final List horizontalColors = [Colors.white, Colors.blue];
8 | final List verticalColors = [Colors.transparent, Colors.black];
9 |
10 | @override
11 | State createState() => _PalettePickerPageState();
12 | }
13 |
14 | class _PalettePickerPageState extends State {
15 | Offset value = Offset.zero;
16 | void onChanged(Offset value) => this.value = value;
17 |
18 | @override
19 | Widget build(BuildContext context) {
20 | return Center(
21 | child: SizedBox(
22 | width: 260,
23 | height: 320,
24 | child: Card(
25 | shape: const RoundedRectangleBorder(
26 | borderRadius: BorderRadius.all(
27 | Radius.circular(0.0),
28 | ),
29 | ),
30 | elevation: 2.0,
31 | child: Padding(
32 | padding: const EdgeInsets.all(10),
33 | child: Column(
34 | mainAxisSize: MainAxisSize.min,
35 | children: [
36 | Text(
37 | '''( ${(value.dx * 100.0).toInt().toDouble() / 100.0} , ${(value.dy * 100.0).toInt().toDouble() / 100.0} )''',
38 | style: Theme.of(context).textTheme.headlineMedium,
39 | ),
40 | const Divider(),
41 | Expanded(
42 |
43 | ///---------------------------------
44 | child: PalettePicker(
45 | topPosition: 1.0,
46 | bottomPosition: 0.0,
47 | position: value,
48 | onChanged: (value) => super.setState(
49 | () => onChanged(value),
50 | ),
51 | leftRightColors: widget.horizontalColors,
52 | topBottomColors: widget.verticalColors)
53 |
54 | ///---------------------------------
55 |
56 | )
57 | ],
58 | ),
59 | ),
60 | ),
61 | ),
62 | );
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/example/lib/complex_example/palette_saturation_picker_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import 'package:flutter_hsvcolor_picker/flutter_hsvcolor_picker.dart';
4 |
5 | class PaletteSaturationPickerPage extends StatefulWidget {
6 | const PaletteSaturationPickerPage({Key? key}) : super(key: key);
7 |
8 | @override
9 | State createState() =>
10 | _PaletteSaturationPickerPageState();
11 | }
12 |
13 | class _PaletteSaturationPickerPageState
14 | extends State {
15 | HSVColor color = HSVColor.fromColor(Colors.blue);
16 | void onChanged(HSVColor value) => color = value;
17 |
18 | @override
19 | Widget build(BuildContext context) {
20 | return Center(
21 | child: SizedBox(
22 | width: 260,
23 | child: Card(
24 | shape: const RoundedRectangleBorder(
25 | borderRadius: BorderRadius.all(
26 | Radius.circular(0.0),
27 | ),
28 | ),
29 | elevation: 2.0,
30 | child: Padding(
31 | padding: const EdgeInsets.all(10),
32 | child: Column(
33 | mainAxisSize: MainAxisSize.min,
34 | children: [
35 | FloatingActionButton(
36 | onPressed: () {},
37 | backgroundColor: color.toColor(),
38 | ),
39 | const Divider(),
40 |
41 | ///---------------------------------
42 | PaletteSaturationPicker(
43 | color: color,
44 | onChanged: (value) => super.setState(
45 | () => onChanged(value),
46 | ),
47 | )
48 |
49 | ///---------------------------------
50 | ],
51 | ),
52 | ),
53 | ),
54 | ),
55 | );
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/example/lib/complex_example/palette_value_picker_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import 'package:flutter_hsvcolor_picker/flutter_hsvcolor_picker.dart';
4 |
5 | class PaletteValuePickerPage extends StatefulWidget {
6 | const PaletteValuePickerPage({Key? key}) : super(key: key);
7 |
8 | @override
9 | State createState() => _PaletteValuePickerPageState();
10 | }
11 |
12 | class _PaletteValuePickerPageState extends State {
13 | HSVColor color = HSVColor.fromColor(Colors.blue);
14 | void onChanged(HSVColor value) => color = value;
15 |
16 | @override
17 | Widget build(BuildContext context) {
18 | return Center(
19 | child: SizedBox(
20 | width: 260,
21 | child: Card(
22 | shape: const RoundedRectangleBorder(
23 | borderRadius: BorderRadius.all(
24 | Radius.circular(0.0),
25 | ),
26 | ),
27 | elevation: 2.0,
28 | child: Padding(
29 | padding: const EdgeInsets.all(10),
30 | child: Column(
31 | mainAxisSize: MainAxisSize.min,
32 | children: [
33 | FloatingActionButton(
34 | onPressed: () {},
35 | backgroundColor: color.toColor(),
36 | ),
37 | const Divider(),
38 |
39 | ///---------------------------------
40 | PaletteValuePicker(
41 | color: color,
42 | onChanged: (value) => super.setState(
43 | () => onChanged(value),
44 | ),
45 | )
46 |
47 | ///---------------------------------
48 | ],
49 | ),
50 | ),
51 | ),
52 | ),
53 | );
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/example/lib/complex_example/rgb_picker_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import 'package:flutter_hsvcolor_picker/flutter_hsvcolor_picker.dart';
4 |
5 | class RGBPickerPage extends StatefulWidget {
6 | const RGBPickerPage({Key? key}) : super(key: key);
7 |
8 | @override
9 | State createState() => _RGBPickerPageState();
10 | }
11 |
12 | class _RGBPickerPageState extends State {
13 | Color color = Colors.blue;
14 | void onChanged(Color value) => color = value;
15 |
16 | @override
17 | Widget build(BuildContext context) {
18 | return Center(
19 | child: SizedBox(
20 | width: 260,
21 | child: Card(
22 | shape: const RoundedRectangleBorder(
23 | borderRadius: BorderRadius.all(
24 | Radius.circular(0.0),
25 | ),
26 | ),
27 | elevation: 2.0,
28 | child: Padding(
29 | padding: const EdgeInsets.all(10),
30 | child: Column(
31 | mainAxisSize: MainAxisSize.min,
32 | children: [
33 | FloatingActionButton(
34 | onPressed: () {},
35 | backgroundColor: color,
36 | ),
37 | const Divider(),
38 |
39 | ///---------------------------------
40 | RGBPicker(
41 | color: color,
42 | onChanged: (value) => super.setState(
43 | () => onChanged(value),
44 | ),
45 | )
46 |
47 | ///---------------------------------
48 | ],
49 | ),
50 | ),
51 | ),
52 | ),
53 | );
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/example/lib/complex_example/slider_picker_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_hsvcolor_picker/flutter_hsvcolor_picker.dart';
3 |
4 | class SliderPickerPage extends StatefulWidget {
5 | const SliderPickerPage({Key? key}) : super(key: key);
6 |
7 | @override
8 | State createState() => _SliderPickerPageState();
9 | }
10 |
11 | class _SliderPickerPageState extends State {
12 | final List hueColors = [
13 | const Color.fromARGB(255, 255, 0, 0),
14 | const Color.fromARGB(255, 255, 255, 0),
15 | const Color.fromARGB(255, 0, 255, 0),
16 | const Color.fromARGB(255, 0, 255, 255),
17 | const Color.fromARGB(255, 0, 0, 255),
18 | const Color.fromARGB(255, 255, 0, 255)
19 | ];
20 |
21 | double value = 0.0;
22 | void onChanged(double value) => this.value = value;
23 |
24 | @override
25 | Widget build(BuildContext context) {
26 | return Center(
27 | child: SizedBox(
28 | width: 260,
29 | child: Card(
30 | shape: const RoundedRectangleBorder(
31 | borderRadius: BorderRadius.all(
32 | Radius.circular(0.0),
33 | ),
34 | ),
35 | elevation: 2.0,
36 | child: Padding(
37 | padding: const EdgeInsets.all(10),
38 | child: Column(
39 | mainAxisSize: MainAxisSize.min,
40 | children: [
41 | Text(
42 | ((value * 100.0).toInt().toDouble() / 100.0).toString(),
43 | style: Theme.of(context).textTheme.headlineMedium,
44 | ),
45 | const Divider(),
46 |
47 | ///---------------------------------
48 | SliderPicker(
49 | min: 0.0,
50 | max: 1.0,
51 | value: value,
52 | onChanged: (value) => super.setState(
53 | () => onChanged(value),
54 | ),
55 | child: DecoratedBox(
56 | decoration: BoxDecoration(
57 | gradient: LinearGradient(colors: hueColors),
58 | ),
59 | ),
60 | )
61 |
62 | ///---------------------------------
63 | ],
64 | ),
65 | ),
66 | ),
67 | ),
68 | );
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/example/lib/complex_example/swatches_picker_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import 'package:flutter_hsvcolor_picker/flutter_hsvcolor_picker.dart';
4 |
5 | class SwatchesPickerPage extends StatefulWidget {
6 | const SwatchesPickerPage({Key? key}) : super(key: key);
7 |
8 | @override
9 | State createState() => _SwatchesPickerPageState();
10 | }
11 |
12 | class _SwatchesPickerPageState extends State {
13 | @override
14 | Widget build(BuildContext context) {
15 | return Center(
16 | child: SizedBox(
17 | width: 300,
18 | child: Card(
19 | shape: const RoundedRectangleBorder(
20 | borderRadius: BorderRadius.all(
21 | Radius.circular(1.0),
22 | ),
23 | ),
24 | elevation: 4.0,
25 | child: Padding(
26 | padding:
27 | const EdgeInsets.symmetric(horizontal: 14.0, vertical: 2.0),
28 |
29 | ///---------------------------------
30 | child: SwatchesPicker(
31 | onChanged: (value) {},
32 | ),
33 |
34 | ///---------------------------------
35 | ),
36 | ),
37 | ),
38 | );
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/example/lib/complex_example/wheel_picker_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import 'package:flutter_hsvcolor_picker/flutter_hsvcolor_picker.dart';
4 |
5 | class WheelPickerPage extends StatefulWidget {
6 | const WheelPickerPage({Key? key}) : super(key: key);
7 |
8 | @override
9 | State createState() => _WheelPickerPageState();
10 | }
11 |
12 | class _WheelPickerPageState extends State {
13 | HSVColor color = HSVColor.fromColor(Colors.blue);
14 | void onChanged(HSVColor color) => this.color = color;
15 |
16 | @override
17 | Widget build(BuildContext context) {
18 | return Center(
19 | child: SizedBox(
20 | width: 260,
21 | child: Card(
22 | shape: const RoundedRectangleBorder(
23 | borderRadius: BorderRadius.all(
24 | Radius.circular(0.0),
25 | ),
26 | ),
27 | elevation: 2.0,
28 | child: Padding(
29 | padding: const EdgeInsets.all(10),
30 | child: Column(
31 | mainAxisSize: MainAxisSize.min,
32 | children: [
33 | FloatingActionButton(
34 | onPressed: () {},
35 | backgroundColor: color.toColor(),
36 | ),
37 | const Divider(),
38 | SizedBox(
39 | width: 222,
40 | height: 222,
41 |
42 | ///---------------------------------
43 | child: WheelPicker(
44 | color: color,
45 | onChanged: (value) => super.setState(
46 | () => onChanged(value),
47 | ),
48 | ),
49 | )
50 |
51 | ///---------------------------------
52 | ],
53 | ),
54 | ),
55 | ),
56 | ),
57 | );
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/example/lib/main.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import 'package:flutter_hsvcolor_picker/flutter_hsvcolor_picker.dart';
4 |
5 | // For a more detailed example, head over to:
6 | // https://github.com/fluttercandies/flutter_hsvcolor_picker/tree/main/example/lib/complex_example
7 |
8 | void main() => runApp(const MyApp());
9 |
10 | class MyApp extends StatelessWidget {
11 | const MyApp({Key? key}) : super(key: key);
12 |
13 | @override
14 | Widget build(BuildContext context) {
15 | return MaterialApp(
16 | darkTheme: ThemeData.dark(),
17 | home: const MyHomePage(),
18 | );
19 | }
20 | }
21 |
22 | class MyHomePage extends StatefulWidget {
23 | const MyHomePage({Key? key}) : super(key: key);
24 |
25 | @override
26 | State createState() => _MyHomePageState();
27 | }
28 |
29 | class _MyHomePageState extends State {
30 | final _colorNotifier = ValueNotifier(Colors.green);
31 |
32 | @override
33 | Widget build(BuildContext context) {
34 | return Scaffold(
35 | body: Center(
36 | child: Padding(
37 | padding: const EdgeInsets.all(50),
38 | child: ValueListenableBuilder(
39 | valueListenable: _colorNotifier,
40 | builder: (_, color, __) {
41 | return ColorPicker(
42 | color: color,
43 | onChanged: (value) => color = value,
44 | );
45 | },
46 | ),
47 | ),
48 | ),
49 | );
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/example/linux/.gitignore:
--------------------------------------------------------------------------------
1 | flutter/ephemeral
2 |
--------------------------------------------------------------------------------
/example/linux/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Project-level configuration.
2 | cmake_minimum_required(VERSION 3.10)
3 | project(runner LANGUAGES CXX)
4 |
5 | # The name of the executable created for the application. Change this to change
6 | # the on-disk name of your application.
7 | set(BINARY_NAME "example")
8 | # The unique GTK application identifier for this application. See:
9 | # https://wiki.gnome.org/HowDoI/ChooseApplicationID
10 | set(APPLICATION_ID "com.example.example")
11 |
12 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent
13 | # versions of CMake.
14 | cmake_policy(SET CMP0063 NEW)
15 |
16 | # Load bundled libraries from the lib/ directory relative to the binary.
17 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
18 |
19 | # Root filesystem for cross-building.
20 | if(FLUTTER_TARGET_PLATFORM_SYSROOT)
21 | set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT})
22 | set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
23 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
24 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
25 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
26 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
27 | endif()
28 |
29 | # Define build configuration options.
30 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
31 | set(CMAKE_BUILD_TYPE "Debug" CACHE
32 | STRING "Flutter build mode" FORCE)
33 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
34 | "Debug" "Profile" "Release")
35 | endif()
36 |
37 | # Compilation settings that should be applied to most targets.
38 | #
39 | # Be cautious about adding new options here, as plugins use this function by
40 | # default. In most cases, you should add new options to specific targets instead
41 | # of modifying this function.
42 | function(APPLY_STANDARD_SETTINGS TARGET)
43 | target_compile_features(${TARGET} PUBLIC cxx_std_14)
44 | target_compile_options(${TARGET} PRIVATE -Wall -Werror)
45 | target_compile_options(${TARGET} PRIVATE "$<$>:-O3>")
46 | target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>")
47 | endfunction()
48 |
49 | # Flutter library and tool build rules.
50 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
51 | add_subdirectory(${FLUTTER_MANAGED_DIR})
52 |
53 | # System-level dependencies.
54 | find_package(PkgConfig REQUIRED)
55 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
56 |
57 | add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
58 |
59 | # Define the application target. To change its name, change BINARY_NAME above,
60 | # not the value here, or `flutter run` will no longer work.
61 | #
62 | # Any new source files that you add to the application should be added here.
63 | add_executable(${BINARY_NAME}
64 | "main.cc"
65 | "my_application.cc"
66 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
67 | )
68 |
69 | # Apply the standard set of build settings. This can be removed for applications
70 | # that need different build settings.
71 | apply_standard_settings(${BINARY_NAME})
72 |
73 | # Add dependency libraries. Add any application-specific dependencies here.
74 | target_link_libraries(${BINARY_NAME} PRIVATE flutter)
75 | target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
76 |
77 | # Run the Flutter tool portions of the build. This must not be removed.
78 | add_dependencies(${BINARY_NAME} flutter_assemble)
79 |
80 | # Only the install-generated bundle's copy of the executable will launch
81 | # correctly, since the resources must in the right relative locations. To avoid
82 | # people trying to run the unbundled copy, put it in a subdirectory instead of
83 | # the default top-level location.
84 | set_target_properties(${BINARY_NAME}
85 | PROPERTIES
86 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
87 | )
88 |
89 |
90 | # Generated plugin build rules, which manage building the plugins and adding
91 | # them to the application.
92 | include(flutter/generated_plugins.cmake)
93 |
94 |
95 | # === Installation ===
96 | # By default, "installing" just makes a relocatable bundle in the build
97 | # directory.
98 | set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
99 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
100 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
101 | endif()
102 |
103 | # Start with a clean build bundle directory every time.
104 | install(CODE "
105 | file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\")
106 | " COMPONENT Runtime)
107 |
108 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
109 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
110 |
111 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
112 | COMPONENT Runtime)
113 |
114 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
115 | COMPONENT Runtime)
116 |
117 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
118 | COMPONENT Runtime)
119 |
120 | foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES})
121 | install(FILES "${bundled_library}"
122 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
123 | COMPONENT Runtime)
124 | endforeach(bundled_library)
125 |
126 | # Copy the native assets provided by the build.dart from all packages.
127 | set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/")
128 | install(DIRECTORY "${NATIVE_ASSETS_DIR}"
129 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
130 | COMPONENT Runtime)
131 |
132 | # Fully re-copy the assets directory on each build to avoid having stale files
133 | # from a previous install.
134 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
135 | install(CODE "
136 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
137 | " COMPONENT Runtime)
138 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
139 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
140 |
141 | # Install the AOT library on non-Debug builds only.
142 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
143 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
144 | COMPONENT Runtime)
145 | endif()
146 |
--------------------------------------------------------------------------------
/example/linux/flutter/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # This file controls Flutter-level build steps. It should not be edited.
2 | cmake_minimum_required(VERSION 3.10)
3 |
4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
5 |
6 | # Configuration provided via flutter tool.
7 | include(${EPHEMERAL_DIR}/generated_config.cmake)
8 |
9 | # TODO: Move the rest of this into files in ephemeral. See
10 | # https://github.com/flutter/flutter/issues/57146.
11 |
12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...),
13 | # which isn't available in 3.10.
14 | function(list_prepend LIST_NAME PREFIX)
15 | set(NEW_LIST "")
16 | foreach(element ${${LIST_NAME}})
17 | list(APPEND NEW_LIST "${PREFIX}${element}")
18 | endforeach(element)
19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE)
20 | endfunction()
21 |
22 | # === Flutter Library ===
23 | # System-level dependencies.
24 | find_package(PkgConfig REQUIRED)
25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
28 |
29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so")
30 |
31 | # Published to parent scope for install step.
32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE)
36 |
37 | list(APPEND FLUTTER_LIBRARY_HEADERS
38 | "fl_basic_message_channel.h"
39 | "fl_binary_codec.h"
40 | "fl_binary_messenger.h"
41 | "fl_dart_project.h"
42 | "fl_engine.h"
43 | "fl_json_message_codec.h"
44 | "fl_json_method_codec.h"
45 | "fl_message_codec.h"
46 | "fl_method_call.h"
47 | "fl_method_channel.h"
48 | "fl_method_codec.h"
49 | "fl_method_response.h"
50 | "fl_plugin_registrar.h"
51 | "fl_plugin_registry.h"
52 | "fl_standard_message_codec.h"
53 | "fl_standard_method_codec.h"
54 | "fl_string_codec.h"
55 | "fl_value.h"
56 | "fl_view.h"
57 | "flutter_linux.h"
58 | )
59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/")
60 | add_library(flutter INTERFACE)
61 | target_include_directories(flutter INTERFACE
62 | "${EPHEMERAL_DIR}"
63 | )
64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
65 | target_link_libraries(flutter INTERFACE
66 | PkgConfig::GTK
67 | PkgConfig::GLIB
68 | PkgConfig::GIO
69 | )
70 | add_dependencies(flutter flutter_assemble)
71 |
72 | # === Flutter tool backend ===
73 | # _phony_ is a non-existent file to force this command to run every time,
74 | # since currently there's no way to get a full input/output list from the
75 | # flutter tool.
76 | add_custom_command(
77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_
79 | COMMAND ${CMAKE_COMMAND} -E env
80 | ${FLUTTER_TOOL_ENVIRONMENT}
81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE}
83 | VERBATIM
84 | )
85 | add_custom_target(flutter_assemble DEPENDS
86 | "${FLUTTER_LIBRARY}"
87 | ${FLUTTER_LIBRARY_HEADERS}
88 | )
89 |
--------------------------------------------------------------------------------
/example/linux/flutter/generated_plugin_registrant.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #include "generated_plugin_registrant.h"
8 |
9 |
10 | void fl_register_plugins(FlPluginRegistry* registry) {
11 | }
12 |
--------------------------------------------------------------------------------
/example/linux/flutter/generated_plugin_registrant.h:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #ifndef GENERATED_PLUGIN_REGISTRANT_
8 | #define GENERATED_PLUGIN_REGISTRANT_
9 |
10 | #include
11 |
12 | // Registers Flutter plugins.
13 | void fl_register_plugins(FlPluginRegistry* registry);
14 |
15 | #endif // GENERATED_PLUGIN_REGISTRANT_
16 |
--------------------------------------------------------------------------------
/example/linux/flutter/generated_plugins.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Generated file, do not edit.
3 | #
4 |
5 | list(APPEND FLUTTER_PLUGIN_LIST
6 | )
7 |
8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST
9 | )
10 |
11 | set(PLUGIN_BUNDLED_LIBRARIES)
12 |
13 | foreach(plugin ${FLUTTER_PLUGIN_LIST})
14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $)
17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
18 | endforeach(plugin)
19 |
20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
23 | endforeach(ffi_plugin)
24 |
--------------------------------------------------------------------------------
/example/linux/main.cc:
--------------------------------------------------------------------------------
1 | #include "my_application.h"
2 |
3 | int main(int argc, char** argv) {
4 | g_autoptr(MyApplication) app = my_application_new();
5 | return g_application_run(G_APPLICATION(app), argc, argv);
6 | }
7 |
--------------------------------------------------------------------------------
/example/linux/my_application.cc:
--------------------------------------------------------------------------------
1 | #include "my_application.h"
2 |
3 | #include
4 | #ifdef GDK_WINDOWING_X11
5 | #include
6 | #endif
7 |
8 | #include "flutter/generated_plugin_registrant.h"
9 |
10 | struct _MyApplication {
11 | GtkApplication parent_instance;
12 | char** dart_entrypoint_arguments;
13 | };
14 |
15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
16 |
17 | // Implements GApplication::activate.
18 | static void my_application_activate(GApplication* application) {
19 | MyApplication* self = MY_APPLICATION(application);
20 | GtkWindow* window =
21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
22 |
23 | // Use a header bar when running in GNOME as this is the common style used
24 | // by applications and is the setup most users will be using (e.g. Ubuntu
25 | // desktop).
26 | // If running on X and not using GNOME then just use a traditional title bar
27 | // in case the window manager does more exotic layout, e.g. tiling.
28 | // If running on Wayland assume the header bar will work (may need changing
29 | // if future cases occur).
30 | gboolean use_header_bar = TRUE;
31 | #ifdef GDK_WINDOWING_X11
32 | GdkScreen* screen = gtk_window_get_screen(window);
33 | if (GDK_IS_X11_SCREEN(screen)) {
34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen);
35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) {
36 | use_header_bar = FALSE;
37 | }
38 | }
39 | #endif
40 | if (use_header_bar) {
41 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
42 | gtk_widget_show(GTK_WIDGET(header_bar));
43 | gtk_header_bar_set_title(header_bar, "example");
44 | gtk_header_bar_set_show_close_button(header_bar, TRUE);
45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
46 | } else {
47 | gtk_window_set_title(window, "example");
48 | }
49 |
50 | gtk_window_set_default_size(window, 1280, 720);
51 | gtk_widget_show(GTK_WIDGET(window));
52 |
53 | g_autoptr(FlDartProject) project = fl_dart_project_new();
54 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
55 |
56 | FlView* view = fl_view_new(project);
57 | gtk_widget_show(GTK_WIDGET(view));
58 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));
59 |
60 | fl_register_plugins(FL_PLUGIN_REGISTRY(view));
61 |
62 | gtk_widget_grab_focus(GTK_WIDGET(view));
63 | }
64 |
65 | // Implements GApplication::local_command_line.
66 | static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) {
67 | MyApplication* self = MY_APPLICATION(application);
68 | // Strip out the first argument as it is the binary name.
69 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1);
70 |
71 | g_autoptr(GError) error = nullptr;
72 | if (!g_application_register(application, nullptr, &error)) {
73 | g_warning("Failed to register: %s", error->message);
74 | *exit_status = 1;
75 | return TRUE;
76 | }
77 |
78 | g_application_activate(application);
79 | *exit_status = 0;
80 |
81 | return TRUE;
82 | }
83 |
84 | // Implements GApplication::startup.
85 | static void my_application_startup(GApplication* application) {
86 | //MyApplication* self = MY_APPLICATION(object);
87 |
88 | // Perform any actions required at application startup.
89 |
90 | G_APPLICATION_CLASS(my_application_parent_class)->startup(application);
91 | }
92 |
93 | // Implements GApplication::shutdown.
94 | static void my_application_shutdown(GApplication* application) {
95 | //MyApplication* self = MY_APPLICATION(object);
96 |
97 | // Perform any actions required at application shutdown.
98 |
99 | G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application);
100 | }
101 |
102 | // Implements GObject::dispose.
103 | static void my_application_dispose(GObject* object) {
104 | MyApplication* self = MY_APPLICATION(object);
105 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev);
106 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object);
107 | }
108 |
109 | static void my_application_class_init(MyApplicationClass* klass) {
110 | G_APPLICATION_CLASS(klass)->activate = my_application_activate;
111 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line;
112 | G_APPLICATION_CLASS(klass)->startup = my_application_startup;
113 | G_APPLICATION_CLASS(klass)->shutdown = my_application_shutdown;
114 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose;
115 | }
116 |
117 | static void my_application_init(MyApplication* self) {}
118 |
119 | MyApplication* my_application_new() {
120 | return MY_APPLICATION(g_object_new(my_application_get_type(),
121 | "application-id", APPLICATION_ID,
122 | "flags", G_APPLICATION_NON_UNIQUE,
123 | nullptr));
124 | }
125 |
--------------------------------------------------------------------------------
/example/linux/my_application.h:
--------------------------------------------------------------------------------
1 | #ifndef FLUTTER_MY_APPLICATION_H_
2 | #define FLUTTER_MY_APPLICATION_H_
3 |
4 | #include
5 |
6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION,
7 | GtkApplication)
8 |
9 | /**
10 | * my_application_new:
11 | *
12 | * Creates a new Flutter-based application.
13 | *
14 | * Returns: a new #MyApplication.
15 | */
16 | MyApplication* my_application_new();
17 |
18 | #endif // FLUTTER_MY_APPLICATION_H_
19 |
--------------------------------------------------------------------------------
/example/macos/.gitignore:
--------------------------------------------------------------------------------
1 | # Flutter-related
2 | **/Flutter/ephemeral/
3 | **/Pods/
4 |
5 | # Xcode-related
6 | **/dgph
7 | **/xcuserdata/
8 |
--------------------------------------------------------------------------------
/example/macos/Flutter/Flutter-Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "ephemeral/Flutter-Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/example/macos/Flutter/Flutter-Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "ephemeral/Flutter-Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/example/macos/Flutter/GeneratedPluginRegistrant.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | import FlutterMacOS
6 | import Foundation
7 |
8 |
9 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
10 | }
11 |
--------------------------------------------------------------------------------
/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
37 |
38 |
39 |
40 |
43 |
49 |
50 |
51 |
52 |
53 |
63 |
65 |
71 |
72 |
73 |
74 |
80 |
82 |
88 |
89 |
90 |
91 |
93 |
94 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/example/macos/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/macos/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 | import FlutterMacOS
3 |
4 | @NSApplicationMain
5 | class AppDelegate: FlutterAppDelegate {
6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
7 | return true
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "16x16",
5 | "idiom" : "mac",
6 | "filename" : "app_icon_16.png",
7 | "scale" : "1x"
8 | },
9 | {
10 | "size" : "16x16",
11 | "idiom" : "mac",
12 | "filename" : "app_icon_32.png",
13 | "scale" : "2x"
14 | },
15 | {
16 | "size" : "32x32",
17 | "idiom" : "mac",
18 | "filename" : "app_icon_32.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "32x32",
23 | "idiom" : "mac",
24 | "filename" : "app_icon_64.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "128x128",
29 | "idiom" : "mac",
30 | "filename" : "app_icon_128.png",
31 | "scale" : "1x"
32 | },
33 | {
34 | "size" : "128x128",
35 | "idiom" : "mac",
36 | "filename" : "app_icon_256.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "256x256",
41 | "idiom" : "mac",
42 | "filename" : "app_icon_256.png",
43 | "scale" : "1x"
44 | },
45 | {
46 | "size" : "256x256",
47 | "idiom" : "mac",
48 | "filename" : "app_icon_512.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "512x512",
53 | "idiom" : "mac",
54 | "filename" : "app_icon_512.png",
55 | "scale" : "1x"
56 | },
57 | {
58 | "size" : "512x512",
59 | "idiom" : "mac",
60 | "filename" : "app_icon_1024.png",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png
--------------------------------------------------------------------------------
/example/macos/Runner/Configs/AppInfo.xcconfig:
--------------------------------------------------------------------------------
1 | // Application-level settings for the Runner target.
2 | //
3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the
4 | // future. If not, the values below would default to using the project name when this becomes a
5 | // 'flutter create' template.
6 |
7 | // The application's name. By default this is also the title of the Flutter window.
8 | PRODUCT_NAME = example
9 |
10 | // The application's bundle identifier
11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.example
12 |
13 | // The copyright displayed in application information
14 | PRODUCT_COPYRIGHT = Copyright © 2023 com.example. All rights reserved.
15 |
--------------------------------------------------------------------------------
/example/macos/Runner/Configs/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "../../Flutter/Flutter-Debug.xcconfig"
2 | #include "Warnings.xcconfig"
3 |
--------------------------------------------------------------------------------
/example/macos/Runner/Configs/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "../../Flutter/Flutter-Release.xcconfig"
2 | #include "Warnings.xcconfig"
3 |
--------------------------------------------------------------------------------
/example/macos/Runner/Configs/Warnings.xcconfig:
--------------------------------------------------------------------------------
1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings
2 | GCC_WARN_UNDECLARED_SELECTOR = YES
3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES
4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE
5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES
6 | CLANG_WARN_PRAGMA_PACK = YES
7 | CLANG_WARN_STRICT_PROTOTYPES = YES
8 | CLANG_WARN_COMMA = YES
9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES
10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES
11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
12 | GCC_WARN_SHADOW = YES
13 | CLANG_WARN_UNREACHABLE_CODE = YES
14 |
--------------------------------------------------------------------------------
/example/macos/Runner/DebugProfile.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.app-sandbox
6 |
7 | com.apple.security.cs.allow-jit
8 |
9 | com.apple.security.network.server
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/example/macos/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | $(FLUTTER_BUILD_NAME)
21 | CFBundleVersion
22 | $(FLUTTER_BUILD_NUMBER)
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | $(PRODUCT_COPYRIGHT)
27 | NSMainNibFile
28 | MainMenu
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/example/macos/Runner/MainFlutterWindow.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 | import FlutterMacOS
3 |
4 | class MainFlutterWindow: NSWindow {
5 | override func awakeFromNib() {
6 | let flutterViewController = FlutterViewController()
7 | let windowFrame = self.frame
8 | self.contentViewController = flutterViewController
9 | self.setFrame(windowFrame, display: true)
10 |
11 | RegisterGeneratedPlugins(registry: flutterViewController)
12 |
13 | super.awakeFromNib()
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/example/macos/Runner/Release.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.app-sandbox
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/macos/RunnerTests/RunnerTests.swift:
--------------------------------------------------------------------------------
1 | import FlutterMacOS
2 | import Cocoa
3 | import XCTest
4 |
5 | class RunnerTests: XCTestCase {
6 |
7 | func testExample() {
8 | // If you add code to the Runner application, consider adding tests here.
9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest.
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/example/packages/Avatar.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/packages/Avatar.jpg
--------------------------------------------------------------------------------
/example/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: flutter_hsvcolor_picker_example
2 | description: A new Flutter project.
3 | version: 1.0.0
4 | publish_to: none
5 |
6 | environment:
7 | sdk: '>=2.12.0'
8 |
9 | dependencies:
10 | flutter:
11 | sdk: flutter
12 | flutter_hsvcolor_picker:
13 | path: ../
14 |
15 | dev_dependencies:
16 | flutter_lints: ^6.0.0
17 |
18 | flutter:
19 | uses-material-design: true
20 |
21 | assets:
22 | - packages/avatar.jpg
23 |
--------------------------------------------------------------------------------
/example/web/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/web/favicon.png
--------------------------------------------------------------------------------
/example/web/icons/Icon-192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/web/icons/Icon-192.png
--------------------------------------------------------------------------------
/example/web/icons/Icon-512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/web/icons/Icon-512.png
--------------------------------------------------------------------------------
/example/web/icons/Icon-maskable-192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/web/icons/Icon-maskable-192.png
--------------------------------------------------------------------------------
/example/web/icons/Icon-maskable-512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/web/icons/Icon-maskable-512.png
--------------------------------------------------------------------------------
/example/web/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | example
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/example/web/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example",
3 | "short_name": "example",
4 | "start_url": ".",
5 | "display": "standalone",
6 | "background_color": "#0175C2",
7 | "theme_color": "#0175C2",
8 | "description": "A new Flutter project.",
9 | "orientation": "portrait-primary",
10 | "prefer_related_applications": false,
11 | "icons": [
12 | {
13 | "src": "icons/Icon-192.png",
14 | "sizes": "192x192",
15 | "type": "image/png"
16 | },
17 | {
18 | "src": "icons/Icon-512.png",
19 | "sizes": "512x512",
20 | "type": "image/png"
21 | },
22 | {
23 | "src": "icons/Icon-maskable-192.png",
24 | "sizes": "192x192",
25 | "type": "image/png",
26 | "purpose": "maskable"
27 | },
28 | {
29 | "src": "icons/Icon-maskable-512.png",
30 | "sizes": "512x512",
31 | "type": "image/png",
32 | "purpose": "maskable"
33 | }
34 | ]
35 | }
36 |
--------------------------------------------------------------------------------
/example/windows/.gitignore:
--------------------------------------------------------------------------------
1 | flutter/ephemeral/
2 |
3 | # Visual Studio user-specific files.
4 | *.suo
5 | *.user
6 | *.userosscache
7 | *.sln.docstates
8 |
9 | # Visual Studio build-related files.
10 | x64/
11 | x86/
12 |
13 | # Visual Studio cache files
14 | # files ending in .cache can be ignored
15 | *.[Cc]ache
16 | # but keep track of directories ending in .cache
17 | !*.[Cc]ache/
18 |
--------------------------------------------------------------------------------
/example/windows/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Project-level configuration.
2 | cmake_minimum_required(VERSION 3.14)
3 | project(example LANGUAGES CXX)
4 |
5 | # The name of the executable created for the application. Change this to change
6 | # the on-disk name of your application.
7 | set(BINARY_NAME "example")
8 |
9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent
10 | # versions of CMake.
11 | cmake_policy(VERSION 3.14...3.25)
12 |
13 | # Define build configuration option.
14 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
15 | if(IS_MULTICONFIG)
16 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release"
17 | CACHE STRING "" FORCE)
18 | else()
19 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
20 | set(CMAKE_BUILD_TYPE "Debug" CACHE
21 | STRING "Flutter build mode" FORCE)
22 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
23 | "Debug" "Profile" "Release")
24 | endif()
25 | endif()
26 | # Define settings for the Profile build mode.
27 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
28 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
29 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}")
30 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}")
31 |
32 | # Use Unicode for all projects.
33 | add_definitions(-DUNICODE -D_UNICODE)
34 |
35 | # Compilation settings that should be applied to most targets.
36 | #
37 | # Be cautious about adding new options here, as plugins use this function by
38 | # default. In most cases, you should add new options to specific targets instead
39 | # of modifying this function.
40 | function(APPLY_STANDARD_SETTINGS TARGET)
41 | target_compile_features(${TARGET} PUBLIC cxx_std_17)
42 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
43 | target_compile_options(${TARGET} PRIVATE /EHsc)
44 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
45 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>")
46 | endfunction()
47 |
48 | # Flutter library and tool build rules.
49 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
50 | add_subdirectory(${FLUTTER_MANAGED_DIR})
51 |
52 | # Application build; see runner/CMakeLists.txt.
53 | add_subdirectory("runner")
54 |
55 |
56 | # Generated plugin build rules, which manage building the plugins and adding
57 | # them to the application.
58 | include(flutter/generated_plugins.cmake)
59 |
60 |
61 | # === Installation ===
62 | # Support files are copied into place next to the executable, so that it can
63 | # run in place. This is done instead of making a separate bundle (as on Linux)
64 | # so that building and running from within Visual Studio will work.
65 | set(BUILD_BUNDLE_DIR "$")
66 | # Make the "install" step default, as it's required to run.
67 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
68 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
69 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
70 | endif()
71 |
72 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
73 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}")
74 |
75 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
76 | COMPONENT Runtime)
77 |
78 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
79 | COMPONENT Runtime)
80 |
81 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
82 | COMPONENT Runtime)
83 |
84 | if(PLUGIN_BUNDLED_LIBRARIES)
85 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
86 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
87 | COMPONENT Runtime)
88 | endif()
89 |
90 | # Copy the native assets provided by the build.dart from all packages.
91 | set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/")
92 | install(DIRECTORY "${NATIVE_ASSETS_DIR}"
93 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
94 | COMPONENT Runtime)
95 |
96 | # Fully re-copy the assets directory on each build to avoid having stale files
97 | # from a previous install.
98 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
99 | install(CODE "
100 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
101 | " COMPONENT Runtime)
102 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
103 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
104 |
105 | # Install the AOT library on non-Debug builds only.
106 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
107 | CONFIGURATIONS Profile;Release
108 | COMPONENT Runtime)
109 |
--------------------------------------------------------------------------------
/example/windows/flutter/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # This file controls Flutter-level build steps. It should not be edited.
2 | cmake_minimum_required(VERSION 3.14)
3 |
4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
5 |
6 | # Configuration provided via flutter tool.
7 | include(${EPHEMERAL_DIR}/generated_config.cmake)
8 |
9 | # TODO: Move the rest of this into files in ephemeral. See
10 | # https://github.com/flutter/flutter/issues/57146.
11 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")
12 |
13 | # Set fallback configurations for older versions of the flutter tool.
14 | if (NOT DEFINED FLUTTER_TARGET_PLATFORM)
15 | set(FLUTTER_TARGET_PLATFORM "windows-x64")
16 | endif()
17 |
18 | # === Flutter Library ===
19 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")
20 |
21 | # Published to parent scope for install step.
22 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
23 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
24 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
25 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE)
26 |
27 | list(APPEND FLUTTER_LIBRARY_HEADERS
28 | "flutter_export.h"
29 | "flutter_windows.h"
30 | "flutter_messenger.h"
31 | "flutter_plugin_registrar.h"
32 | "flutter_texture_registrar.h"
33 | )
34 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/")
35 | add_library(flutter INTERFACE)
36 | target_include_directories(flutter INTERFACE
37 | "${EPHEMERAL_DIR}"
38 | )
39 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib")
40 | add_dependencies(flutter flutter_assemble)
41 |
42 | # === Wrapper ===
43 | list(APPEND CPP_WRAPPER_SOURCES_CORE
44 | "core_implementations.cc"
45 | "standard_codec.cc"
46 | )
47 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/")
48 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN
49 | "plugin_registrar.cc"
50 | )
51 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/")
52 | list(APPEND CPP_WRAPPER_SOURCES_APP
53 | "flutter_engine.cc"
54 | "flutter_view_controller.cc"
55 | )
56 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/")
57 |
58 | # Wrapper sources needed for a plugin.
59 | add_library(flutter_wrapper_plugin STATIC
60 | ${CPP_WRAPPER_SOURCES_CORE}
61 | ${CPP_WRAPPER_SOURCES_PLUGIN}
62 | )
63 | apply_standard_settings(flutter_wrapper_plugin)
64 | set_target_properties(flutter_wrapper_plugin PROPERTIES
65 | POSITION_INDEPENDENT_CODE ON)
66 | set_target_properties(flutter_wrapper_plugin PROPERTIES
67 | CXX_VISIBILITY_PRESET hidden)
68 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter)
69 | target_include_directories(flutter_wrapper_plugin PUBLIC
70 | "${WRAPPER_ROOT}/include"
71 | )
72 | add_dependencies(flutter_wrapper_plugin flutter_assemble)
73 |
74 | # Wrapper sources needed for the runner.
75 | add_library(flutter_wrapper_app STATIC
76 | ${CPP_WRAPPER_SOURCES_CORE}
77 | ${CPP_WRAPPER_SOURCES_APP}
78 | )
79 | apply_standard_settings(flutter_wrapper_app)
80 | target_link_libraries(flutter_wrapper_app PUBLIC flutter)
81 | target_include_directories(flutter_wrapper_app PUBLIC
82 | "${WRAPPER_ROOT}/include"
83 | )
84 | add_dependencies(flutter_wrapper_app flutter_assemble)
85 |
86 | # === Flutter tool backend ===
87 | # _phony_ is a non-existent file to force this command to run every time,
88 | # since currently there's no way to get a full input/output list from the
89 | # flutter tool.
90 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_")
91 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE)
92 | add_custom_command(
93 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
94 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN}
95 | ${CPP_WRAPPER_SOURCES_APP}
96 | ${PHONY_OUTPUT}
97 | COMMAND ${CMAKE_COMMAND} -E env
98 | ${FLUTTER_TOOL_ENVIRONMENT}
99 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
100 | ${FLUTTER_TARGET_PLATFORM} $
101 | VERBATIM
102 | )
103 | add_custom_target(flutter_assemble DEPENDS
104 | "${FLUTTER_LIBRARY}"
105 | ${FLUTTER_LIBRARY_HEADERS}
106 | ${CPP_WRAPPER_SOURCES_CORE}
107 | ${CPP_WRAPPER_SOURCES_PLUGIN}
108 | ${CPP_WRAPPER_SOURCES_APP}
109 | )
110 |
--------------------------------------------------------------------------------
/example/windows/flutter/generated_plugin_registrant.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #include "generated_plugin_registrant.h"
8 |
9 |
10 | void RegisterPlugins(flutter::PluginRegistry* registry) {
11 | }
12 |
--------------------------------------------------------------------------------
/example/windows/flutter/generated_plugin_registrant.h:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #ifndef GENERATED_PLUGIN_REGISTRANT_
8 | #define GENERATED_PLUGIN_REGISTRANT_
9 |
10 | #include
11 |
12 | // Registers Flutter plugins.
13 | void RegisterPlugins(flutter::PluginRegistry* registry);
14 |
15 | #endif // GENERATED_PLUGIN_REGISTRANT_
16 |
--------------------------------------------------------------------------------
/example/windows/flutter/generated_plugins.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Generated file, do not edit.
3 | #
4 |
5 | list(APPEND FLUTTER_PLUGIN_LIST
6 | )
7 |
8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST
9 | )
10 |
11 | set(PLUGIN_BUNDLED_LIBRARIES)
12 |
13 | foreach(plugin ${FLUTTER_PLUGIN_LIST})
14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin})
15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $)
17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
18 | endforeach(plugin)
19 |
20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
23 | endforeach(ffi_plugin)
24 |
--------------------------------------------------------------------------------
/example/windows/runner/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.14)
2 | project(runner LANGUAGES CXX)
3 |
4 | # Define the application target. To change its name, change BINARY_NAME in the
5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer
6 | # work.
7 | #
8 | # Any new source files that you add to the application should be added here.
9 | add_executable(${BINARY_NAME} WIN32
10 | "flutter_window.cpp"
11 | "main.cpp"
12 | "utils.cpp"
13 | "win32_window.cpp"
14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
15 | "Runner.rc"
16 | "runner.exe.manifest"
17 | )
18 |
19 | # Apply the standard set of build settings. This can be removed for applications
20 | # that need different build settings.
21 | apply_standard_settings(${BINARY_NAME})
22 |
23 | # Add preprocessor definitions for the build version.
24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"")
25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}")
26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}")
27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}")
28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}")
29 |
30 | # Disable Windows macros that collide with C++ standard library functions.
31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
32 |
33 | # Add dependency libraries and include directories. Add any application-specific
34 | # dependencies here.
35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
36 | target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib")
37 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
38 |
39 | # Run the Flutter tool portions of the build. This must not be removed.
40 | add_dependencies(${BINARY_NAME} flutter_assemble)
41 |
--------------------------------------------------------------------------------
/example/windows/runner/Runner.rc:
--------------------------------------------------------------------------------
1 | // Microsoft Visual C++ generated resource script.
2 | //
3 | #pragma code_page(65001)
4 | #include "resource.h"
5 |
6 | #define APSTUDIO_READONLY_SYMBOLS
7 | /////////////////////////////////////////////////////////////////////////////
8 | //
9 | // Generated from the TEXTINCLUDE 2 resource.
10 | //
11 | #include "winres.h"
12 |
13 | /////////////////////////////////////////////////////////////////////////////
14 | #undef APSTUDIO_READONLY_SYMBOLS
15 |
16 | /////////////////////////////////////////////////////////////////////////////
17 | // English (United States) resources
18 |
19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
21 |
22 | #ifdef APSTUDIO_INVOKED
23 | /////////////////////////////////////////////////////////////////////////////
24 | //
25 | // TEXTINCLUDE
26 | //
27 |
28 | 1 TEXTINCLUDE
29 | BEGIN
30 | "resource.h\0"
31 | END
32 |
33 | 2 TEXTINCLUDE
34 | BEGIN
35 | "#include ""winres.h""\r\n"
36 | "\0"
37 | END
38 |
39 | 3 TEXTINCLUDE
40 | BEGIN
41 | "\r\n"
42 | "\0"
43 | END
44 |
45 | #endif // APSTUDIO_INVOKED
46 |
47 |
48 | /////////////////////////////////////////////////////////////////////////////
49 | //
50 | // Icon
51 | //
52 |
53 | // Icon with lowest ID value placed first to ensure application icon
54 | // remains consistent on all systems.
55 | IDI_APP_ICON ICON "resources\\app_icon.ico"
56 |
57 |
58 | /////////////////////////////////////////////////////////////////////////////
59 | //
60 | // Version
61 | //
62 |
63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD)
64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD
65 | #else
66 | #define VERSION_AS_NUMBER 1,0,0,0
67 | #endif
68 |
69 | #if defined(FLUTTER_VERSION)
70 | #define VERSION_AS_STRING FLUTTER_VERSION
71 | #else
72 | #define VERSION_AS_STRING "1.0.0"
73 | #endif
74 |
75 | VS_VERSION_INFO VERSIONINFO
76 | FILEVERSION VERSION_AS_NUMBER
77 | PRODUCTVERSION VERSION_AS_NUMBER
78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
79 | #ifdef _DEBUG
80 | FILEFLAGS VS_FF_DEBUG
81 | #else
82 | FILEFLAGS 0x0L
83 | #endif
84 | FILEOS VOS__WINDOWS32
85 | FILETYPE VFT_APP
86 | FILESUBTYPE 0x0L
87 | BEGIN
88 | BLOCK "StringFileInfo"
89 | BEGIN
90 | BLOCK "040904e4"
91 | BEGIN
92 | VALUE "CompanyName", "com.example" "\0"
93 | VALUE "FileDescription", "example" "\0"
94 | VALUE "FileVersion", VERSION_AS_STRING "\0"
95 | VALUE "InternalName", "example" "\0"
96 | VALUE "LegalCopyright", "Copyright (C) 2024 com.example. All rights reserved." "\0"
97 | VALUE "OriginalFilename", "example.exe" "\0"
98 | VALUE "ProductName", "example" "\0"
99 | VALUE "ProductVersion", VERSION_AS_STRING "\0"
100 | END
101 | END
102 | BLOCK "VarFileInfo"
103 | BEGIN
104 | VALUE "Translation", 0x409, 1252
105 | END
106 | END
107 |
108 | #endif // English (United States) resources
109 | /////////////////////////////////////////////////////////////////////////////
110 |
111 |
112 |
113 | #ifndef APSTUDIO_INVOKED
114 | /////////////////////////////////////////////////////////////////////////////
115 | //
116 | // Generated from the TEXTINCLUDE 3 resource.
117 | //
118 |
119 |
120 | /////////////////////////////////////////////////////////////////////////////
121 | #endif // not APSTUDIO_INVOKED
122 |
--------------------------------------------------------------------------------
/example/windows/runner/flutter_window.cpp:
--------------------------------------------------------------------------------
1 | #include "flutter_window.h"
2 |
3 | #include
4 |
5 | #include "flutter/generated_plugin_registrant.h"
6 |
7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project)
8 | : project_(project) {}
9 |
10 | FlutterWindow::~FlutterWindow() {}
11 |
12 | bool FlutterWindow::OnCreate() {
13 | if (!Win32Window::OnCreate()) {
14 | return false;
15 | }
16 |
17 | RECT frame = GetClientArea();
18 |
19 | // The size here must match the window dimensions to avoid unnecessary surface
20 | // creation / destruction in the startup path.
21 | flutter_controller_ = std::make_unique(
22 | frame.right - frame.left, frame.bottom - frame.top, project_);
23 | // Ensure that basic setup of the controller was successful.
24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) {
25 | return false;
26 | }
27 | RegisterPlugins(flutter_controller_->engine());
28 | SetChildContent(flutter_controller_->view()->GetNativeWindow());
29 |
30 | flutter_controller_->engine()->SetNextFrameCallback([&]() {
31 | this->Show();
32 | });
33 |
34 | // Flutter can complete the first frame before the "show window" callback is
35 | // registered. The following call ensures a frame is pending to ensure the
36 | // window is shown. It is a no-op if the first frame hasn't completed yet.
37 | flutter_controller_->ForceRedraw();
38 |
39 | return true;
40 | }
41 |
42 | void FlutterWindow::OnDestroy() {
43 | if (flutter_controller_) {
44 | flutter_controller_ = nullptr;
45 | }
46 |
47 | Win32Window::OnDestroy();
48 | }
49 |
50 | LRESULT
51 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message,
52 | WPARAM const wparam,
53 | LPARAM const lparam) noexcept {
54 | // Give Flutter, including plugins, an opportunity to handle window messages.
55 | if (flutter_controller_) {
56 | std::optional result =
57 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam,
58 | lparam);
59 | if (result) {
60 | return *result;
61 | }
62 | }
63 |
64 | switch (message) {
65 | case WM_FONTCHANGE:
66 | flutter_controller_->engine()->ReloadSystemFonts();
67 | break;
68 | }
69 |
70 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam);
71 | }
72 |
--------------------------------------------------------------------------------
/example/windows/runner/flutter_window.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_FLUTTER_WINDOW_H_
2 | #define RUNNER_FLUTTER_WINDOW_H_
3 |
4 | #include
5 | #include
6 |
7 | #include
8 |
9 | #include "win32_window.h"
10 |
11 | // A window that does nothing but host a Flutter view.
12 | class FlutterWindow : public Win32Window {
13 | public:
14 | // Creates a new FlutterWindow hosting a Flutter view running |project|.
15 | explicit FlutterWindow(const flutter::DartProject& project);
16 | virtual ~FlutterWindow();
17 |
18 | protected:
19 | // Win32Window:
20 | bool OnCreate() override;
21 | void OnDestroy() override;
22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam,
23 | LPARAM const lparam) noexcept override;
24 |
25 | private:
26 | // The project to run.
27 | flutter::DartProject project_;
28 |
29 | // The Flutter instance hosted by this window.
30 | std::unique_ptr flutter_controller_;
31 | };
32 |
33 | #endif // RUNNER_FLUTTER_WINDOW_H_
34 |
--------------------------------------------------------------------------------
/example/windows/runner/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "flutter_window.h"
6 | #include "utils.h"
7 |
8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
9 | _In_ wchar_t *command_line, _In_ int show_command) {
10 | // Attach to console when present (e.g., 'flutter run') or create a
11 | // new console when running with a debugger.
12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
13 | CreateAndAttachConsole();
14 | }
15 |
16 | // Initialize COM, so that it is available for use in the library and/or
17 | // plugins.
18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
19 |
20 | flutter::DartProject project(L"data");
21 |
22 | std::vector command_line_arguments =
23 | GetCommandLineArguments();
24 |
25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
26 |
27 | FlutterWindow window(project);
28 | Win32Window::Point origin(10, 10);
29 | Win32Window::Size size(1280, 720);
30 | if (!window.Create(L"example", origin, size)) {
31 | return EXIT_FAILURE;
32 | }
33 | window.SetQuitOnClose(true);
34 |
35 | ::MSG msg;
36 | while (::GetMessage(&msg, nullptr, 0, 0)) {
37 | ::TranslateMessage(&msg);
38 | ::DispatchMessage(&msg);
39 | }
40 |
41 | ::CoUninitialize();
42 | return EXIT_SUCCESS;
43 | }
44 |
--------------------------------------------------------------------------------
/example/windows/runner/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Visual C++ generated include file.
3 | // Used by Runner.rc
4 | //
5 | #define IDI_APP_ICON 101
6 |
7 | // Next default values for new objects
8 | //
9 | #ifdef APSTUDIO_INVOKED
10 | #ifndef APSTUDIO_READONLY_SYMBOLS
11 | #define _APS_NEXT_RESOURCE_VALUE 102
12 | #define _APS_NEXT_COMMAND_VALUE 40001
13 | #define _APS_NEXT_CONTROL_VALUE 1001
14 | #define _APS_NEXT_SYMED_VALUE 101
15 | #endif
16 | #endif
17 |
--------------------------------------------------------------------------------
/example/windows/runner/resources/app_icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/example/windows/runner/resources/app_icon.ico
--------------------------------------------------------------------------------
/example/windows/runner/runner.exe.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PerMonitorV2
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/example/windows/runner/utils.cpp:
--------------------------------------------------------------------------------
1 | #include "utils.h"
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | #include
9 |
10 | void CreateAndAttachConsole() {
11 | if (::AllocConsole()) {
12 | FILE *unused;
13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) {
14 | _dup2(_fileno(stdout), 1);
15 | }
16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) {
17 | _dup2(_fileno(stdout), 2);
18 | }
19 | std::ios::sync_with_stdio();
20 | FlutterDesktopResyncOutputStreams();
21 | }
22 | }
23 |
24 | std::vector GetCommandLineArguments() {
25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use.
26 | int argc;
27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
28 | if (argv == nullptr) {
29 | return std::vector();
30 | }
31 |
32 | std::vector command_line_arguments;
33 |
34 | // Skip the first argument as it's the binary name.
35 | for (int i = 1; i < argc; i++) {
36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i]));
37 | }
38 |
39 | ::LocalFree(argv);
40 |
41 | return command_line_arguments;
42 | }
43 |
44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) {
45 | if (utf16_string == nullptr) {
46 | return std::string();
47 | }
48 | unsigned int target_length = ::WideCharToMultiByte(
49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
50 | -1, nullptr, 0, nullptr, nullptr)
51 | -1; // remove the trailing null character
52 | int input_length = (int)wcslen(utf16_string);
53 | std::string utf8_string;
54 | if (target_length == 0 || target_length > utf8_string.max_size()) {
55 | return utf8_string;
56 | }
57 | utf8_string.resize(target_length);
58 | int converted_length = ::WideCharToMultiByte(
59 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
60 | input_length, utf8_string.data(), target_length, nullptr, nullptr);
61 | if (converted_length == 0) {
62 | return std::string();
63 | }
64 | return utf8_string;
65 | }
66 |
--------------------------------------------------------------------------------
/example/windows/runner/utils.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_UTILS_H_
2 | #define RUNNER_UTILS_H_
3 |
4 | #include
5 | #include
6 |
7 | // Creates a console for the process, and redirects stdout and stderr to
8 | // it for both the runner and the Flutter library.
9 | void CreateAndAttachConsole();
10 |
11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string
12 | // encoded in UTF-8. Returns an empty std::string on failure.
13 | std::string Utf8FromUtf16(const wchar_t* utf16_string);
14 |
15 | // Gets the command line arguments passed in as a std::vector,
16 | // encoded in UTF-8. Returns an empty std::vector on failure.
17 | std::vector GetCommandLineArguments();
18 |
19 | #endif // RUNNER_UTILS_H_
20 |
--------------------------------------------------------------------------------
/example/windows/runner/win32_window.cpp:
--------------------------------------------------------------------------------
1 | #include "win32_window.h"
2 |
3 | #include
4 | #include
5 |
6 | #include "resource.h"
7 |
8 | namespace {
9 |
10 | /// Window attribute that enables dark mode window decorations.
11 | ///
12 | /// Redefined in case the developer's machine has a Windows SDK older than
13 | /// version 10.0.22000.0.
14 | /// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute
15 | #ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
16 | #define DWMWA_USE_IMMERSIVE_DARK_MODE 20
17 | #endif
18 |
19 | constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW";
20 |
21 | /// Registry key for app theme preference.
22 | ///
23 | /// A value of 0 indicates apps should use dark mode. A non-zero or missing
24 | /// value indicates apps should use light mode.
25 | constexpr const wchar_t kGetPreferredBrightnessRegKey[] =
26 | L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize";
27 | constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme";
28 |
29 | // The number of Win32Window objects that currently exist.
30 | static int g_active_window_count = 0;
31 |
32 | using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd);
33 |
34 | // Scale helper to convert logical scaler values to physical using passed in
35 | // scale factor
36 | int Scale(int source, double scale_factor) {
37 | return static_cast(source * scale_factor);
38 | }
39 |
40 | // Dynamically loads the |EnableNonClientDpiScaling| from the User32 module.
41 | // This API is only needed for PerMonitor V1 awareness mode.
42 | void EnableFullDpiSupportIfAvailable(HWND hwnd) {
43 | HMODULE user32_module = LoadLibraryA("User32.dll");
44 | if (!user32_module) {
45 | return;
46 | }
47 | auto enable_non_client_dpi_scaling =
48 | reinterpret_cast(
49 | GetProcAddress(user32_module, "EnableNonClientDpiScaling"));
50 | if (enable_non_client_dpi_scaling != nullptr) {
51 | enable_non_client_dpi_scaling(hwnd);
52 | }
53 | FreeLibrary(user32_module);
54 | }
55 |
56 | } // namespace
57 |
58 | // Manages the Win32Window's window class registration.
59 | class WindowClassRegistrar {
60 | public:
61 | ~WindowClassRegistrar() = default;
62 |
63 | // Returns the singleton registrar instance.
64 | static WindowClassRegistrar* GetInstance() {
65 | if (!instance_) {
66 | instance_ = new WindowClassRegistrar();
67 | }
68 | return instance_;
69 | }
70 |
71 | // Returns the name of the window class, registering the class if it hasn't
72 | // previously been registered.
73 | const wchar_t* GetWindowClass();
74 |
75 | // Unregisters the window class. Should only be called if there are no
76 | // instances of the window.
77 | void UnregisterWindowClass();
78 |
79 | private:
80 | WindowClassRegistrar() = default;
81 |
82 | static WindowClassRegistrar* instance_;
83 |
84 | bool class_registered_ = false;
85 | };
86 |
87 | WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr;
88 |
89 | const wchar_t* WindowClassRegistrar::GetWindowClass() {
90 | if (!class_registered_) {
91 | WNDCLASS window_class{};
92 | window_class.hCursor = LoadCursor(nullptr, IDC_ARROW);
93 | window_class.lpszClassName = kWindowClassName;
94 | window_class.style = CS_HREDRAW | CS_VREDRAW;
95 | window_class.cbClsExtra = 0;
96 | window_class.cbWndExtra = 0;
97 | window_class.hInstance = GetModuleHandle(nullptr);
98 | window_class.hIcon =
99 | LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON));
100 | window_class.hbrBackground = 0;
101 | window_class.lpszMenuName = nullptr;
102 | window_class.lpfnWndProc = Win32Window::WndProc;
103 | RegisterClass(&window_class);
104 | class_registered_ = true;
105 | }
106 | return kWindowClassName;
107 | }
108 |
109 | void WindowClassRegistrar::UnregisterWindowClass() {
110 | UnregisterClass(kWindowClassName, nullptr);
111 | class_registered_ = false;
112 | }
113 |
114 | Win32Window::Win32Window() {
115 | ++g_active_window_count;
116 | }
117 |
118 | Win32Window::~Win32Window() {
119 | --g_active_window_count;
120 | Destroy();
121 | }
122 |
123 | bool Win32Window::Create(const std::wstring& title,
124 | const Point& origin,
125 | const Size& size) {
126 | Destroy();
127 |
128 | const wchar_t* window_class =
129 | WindowClassRegistrar::GetInstance()->GetWindowClass();
130 |
131 | const POINT target_point = {static_cast(origin.x),
132 | static_cast(origin.y)};
133 | HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST);
134 | UINT dpi = FlutterDesktopGetDpiForMonitor(monitor);
135 | double scale_factor = dpi / 96.0;
136 |
137 | HWND window = CreateWindow(
138 | window_class, title.c_str(), WS_OVERLAPPEDWINDOW,
139 | Scale(origin.x, scale_factor), Scale(origin.y, scale_factor),
140 | Scale(size.width, scale_factor), Scale(size.height, scale_factor),
141 | nullptr, nullptr, GetModuleHandle(nullptr), this);
142 |
143 | if (!window) {
144 | return false;
145 | }
146 |
147 | UpdateTheme(window);
148 |
149 | return OnCreate();
150 | }
151 |
152 | bool Win32Window::Show() {
153 | return ShowWindow(window_handle_, SW_SHOWNORMAL);
154 | }
155 |
156 | // static
157 | LRESULT CALLBACK Win32Window::WndProc(HWND const window,
158 | UINT const message,
159 | WPARAM const wparam,
160 | LPARAM const lparam) noexcept {
161 | if (message == WM_NCCREATE) {
162 | auto window_struct = reinterpret_cast(lparam);
163 | SetWindowLongPtr(window, GWLP_USERDATA,
164 | reinterpret_cast(window_struct->lpCreateParams));
165 |
166 | auto that = static_cast(window_struct->lpCreateParams);
167 | EnableFullDpiSupportIfAvailable(window);
168 | that->window_handle_ = window;
169 | } else if (Win32Window* that = GetThisFromHandle(window)) {
170 | return that->MessageHandler(window, message, wparam, lparam);
171 | }
172 |
173 | return DefWindowProc(window, message, wparam, lparam);
174 | }
175 |
176 | LRESULT
177 | Win32Window::MessageHandler(HWND hwnd,
178 | UINT const message,
179 | WPARAM const wparam,
180 | LPARAM const lparam) noexcept {
181 | switch (message) {
182 | case WM_DESTROY:
183 | window_handle_ = nullptr;
184 | Destroy();
185 | if (quit_on_close_) {
186 | PostQuitMessage(0);
187 | }
188 | return 0;
189 |
190 | case WM_DPICHANGED: {
191 | auto newRectSize = reinterpret_cast(lparam);
192 | LONG newWidth = newRectSize->right - newRectSize->left;
193 | LONG newHeight = newRectSize->bottom - newRectSize->top;
194 |
195 | SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth,
196 | newHeight, SWP_NOZORDER | SWP_NOACTIVATE);
197 |
198 | return 0;
199 | }
200 | case WM_SIZE: {
201 | RECT rect = GetClientArea();
202 | if (child_content_ != nullptr) {
203 | // Size and position the child window.
204 | MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left,
205 | rect.bottom - rect.top, TRUE);
206 | }
207 | return 0;
208 | }
209 |
210 | case WM_ACTIVATE:
211 | if (child_content_ != nullptr) {
212 | SetFocus(child_content_);
213 | }
214 | return 0;
215 |
216 | case WM_DWMCOLORIZATIONCOLORCHANGED:
217 | UpdateTheme(hwnd);
218 | return 0;
219 | }
220 |
221 | return DefWindowProc(window_handle_, message, wparam, lparam);
222 | }
223 |
224 | void Win32Window::Destroy() {
225 | OnDestroy();
226 |
227 | if (window_handle_) {
228 | DestroyWindow(window_handle_);
229 | window_handle_ = nullptr;
230 | }
231 | if (g_active_window_count == 0) {
232 | WindowClassRegistrar::GetInstance()->UnregisterWindowClass();
233 | }
234 | }
235 |
236 | Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept {
237 | return reinterpret_cast(
238 | GetWindowLongPtr(window, GWLP_USERDATA));
239 | }
240 |
241 | void Win32Window::SetChildContent(HWND content) {
242 | child_content_ = content;
243 | SetParent(content, window_handle_);
244 | RECT frame = GetClientArea();
245 |
246 | MoveWindow(content, frame.left, frame.top, frame.right - frame.left,
247 | frame.bottom - frame.top, true);
248 |
249 | SetFocus(child_content_);
250 | }
251 |
252 | RECT Win32Window::GetClientArea() {
253 | RECT frame;
254 | GetClientRect(window_handle_, &frame);
255 | return frame;
256 | }
257 |
258 | HWND Win32Window::GetHandle() {
259 | return window_handle_;
260 | }
261 |
262 | void Win32Window::SetQuitOnClose(bool quit_on_close) {
263 | quit_on_close_ = quit_on_close;
264 | }
265 |
266 | bool Win32Window::OnCreate() {
267 | // No-op; provided for subclasses.
268 | return true;
269 | }
270 |
271 | void Win32Window::OnDestroy() {
272 | // No-op; provided for subclasses.
273 | }
274 |
275 | void Win32Window::UpdateTheme(HWND const window) {
276 | DWORD light_mode;
277 | DWORD light_mode_size = sizeof(light_mode);
278 | LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey,
279 | kGetPreferredBrightnessRegValue,
280 | RRF_RT_REG_DWORD, nullptr, &light_mode,
281 | &light_mode_size);
282 |
283 | if (result == ERROR_SUCCESS) {
284 | BOOL enable_dark_mode = light_mode == 0;
285 | DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE,
286 | &enable_dark_mode, sizeof(enable_dark_mode));
287 | }
288 | }
289 |
--------------------------------------------------------------------------------
/example/windows/runner/win32_window.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_WIN32_WINDOW_H_
2 | #define RUNNER_WIN32_WINDOW_H_
3 |
4 | #include
5 |
6 | #include
7 | #include
8 | #include
9 |
10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be
11 | // inherited from by classes that wish to specialize with custom
12 | // rendering and input handling
13 | class Win32Window {
14 | public:
15 | struct Point {
16 | unsigned int x;
17 | unsigned int y;
18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {}
19 | };
20 |
21 | struct Size {
22 | unsigned int width;
23 | unsigned int height;
24 | Size(unsigned int width, unsigned int height)
25 | : width(width), height(height) {}
26 | };
27 |
28 | Win32Window();
29 | virtual ~Win32Window();
30 |
31 | // Creates a win32 window with |title| that is positioned and sized using
32 | // |origin| and |size|. New windows are created on the default monitor. Window
33 | // sizes are specified to the OS in physical pixels, hence to ensure a
34 | // consistent size this function will scale the inputted width and height as
35 | // as appropriate for the default monitor. The window is invisible until
36 | // |Show| is called. Returns true if the window was created successfully.
37 | bool Create(const std::wstring& title, const Point& origin, const Size& size);
38 |
39 | // Show the current window. Returns true if the window was successfully shown.
40 | bool Show();
41 |
42 | // Release OS resources associated with window.
43 | void Destroy();
44 |
45 | // Inserts |content| into the window tree.
46 | void SetChildContent(HWND content);
47 |
48 | // Returns the backing Window handle to enable clients to set icon and other
49 | // window properties. Returns nullptr if the window has been destroyed.
50 | HWND GetHandle();
51 |
52 | // If true, closing this window will quit the application.
53 | void SetQuitOnClose(bool quit_on_close);
54 |
55 | // Return a RECT representing the bounds of the current client area.
56 | RECT GetClientArea();
57 |
58 | protected:
59 | // Processes and route salient window messages for mouse handling,
60 | // size change and DPI. Delegates handling of these to member overloads that
61 | // inheriting classes can handle.
62 | virtual LRESULT MessageHandler(HWND window,
63 | UINT const message,
64 | WPARAM const wparam,
65 | LPARAM const lparam) noexcept;
66 |
67 | // Called when CreateAndShow is called, allowing subclass window-related
68 | // setup. Subclasses should return false if setup fails.
69 | virtual bool OnCreate();
70 |
71 | // Called when Destroy is called.
72 | virtual void OnDestroy();
73 |
74 | private:
75 | friend class WindowClassRegistrar;
76 |
77 | // OS callback called by message pump. Handles the WM_NCCREATE message which
78 | // is passed when the non-client area is being created and enables automatic
79 | // non-client DPI scaling so that the non-client area automatically
80 | // responds to changes in DPI. All other messages are handled by
81 | // MessageHandler.
82 | static LRESULT CALLBACK WndProc(HWND const window,
83 | UINT const message,
84 | WPARAM const wparam,
85 | LPARAM const lparam) noexcept;
86 |
87 | // Retrieves a class instance pointer for |window|
88 | static Win32Window* GetThisFromHandle(HWND const window) noexcept;
89 |
90 | // Update the window frame's theme to match the system theme.
91 | static void UpdateTheme(HWND const window);
92 |
93 | bool quit_on_close_ = false;
94 |
95 | // window handle for top level window.
96 | HWND window_handle_ = nullptr;
97 |
98 | // window handle for hosted content.
99 | HWND child_content_ = nullptr;
100 | };
101 |
102 | #endif // RUNNER_WIN32_WINDOW_H_
103 |
--------------------------------------------------------------------------------
/lib/flutter_hsvcolor_picker.dart:
--------------------------------------------------------------------------------
1 | library flutter_hsvcolor_picker;
2 |
3 | export 'src/widgets/alpha_picker.dart';
4 | export 'src/color_picker.dart';
5 | export 'src/widgets/hex_picker.dart';
6 | export 'src/pickers/hsv_picker.dart';
7 | export 'src/pickers/palette_hue_picker.dart';
8 | export 'src/widgets/palette_picker.dart';
9 | export 'src/pickers/palette_saturation_picker.dart';
10 | export 'src/pickers/palette_value_picker.dart';
11 | export 'src/pickers/rgb_picker.dart';
12 | export 'src/widgets/slider_picker.dart';
13 | export 'src/pickers/swatches_picker.dart';
14 | export 'src/pickers/wheel_picker.dart';
15 |
--------------------------------------------------------------------------------
/lib/src/pickers/hsv_picker.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import '../widgets/slider_picker.dart';
4 | import '../widgets/slider_title.dart';
5 |
6 | /// Three sliders for selections a color via:
7 | /// Hue
8 | /// Saturation
9 | /// Value
10 | class HSVPicker extends StatefulWidget {
11 | const HSVPicker({
12 | required this.color,
13 | required this.onChanged,
14 | Key? key,
15 | }) : super(key: key);
16 |
17 | final HSVColor color;
18 | final ValueChanged onChanged;
19 |
20 | @override
21 | State createState() => _HSVPickerState();
22 | }
23 |
24 | class _HSVPickerState extends State {
25 | HSVColor get color => widget.color;
26 |
27 | // Hue
28 | void hueOnChange(double value) => widget.onChanged(
29 | color.withHue(value),
30 | );
31 | List get hueColors => [
32 | color.withHue(0.0).toColor(),
33 | color.withHue(60.0).toColor(),
34 | color.withHue(120.0).toColor(),
35 | color.withHue(180.0).toColor(),
36 | color.withHue(240.0).toColor(),
37 | color.withHue(300.0).toColor(),
38 | color.withHue(0.0).toColor()
39 | ];
40 |
41 | // Saturation
42 | void saturationOnChange(double value) => widget.onChanged(
43 | color.withSaturation(value),
44 | );
45 | List get saturationColors => [
46 | color.withSaturation(0.0).toColor(),
47 | color.withSaturation(1.0).toColor()
48 | ];
49 |
50 | // Value
51 | void valueOnChange(double value) => widget.onChanged(
52 | color.withValue(value),
53 | );
54 | List get valueColors => [
55 | color.withValue(0.0).toColor(),
56 | color.withValue(1.0).toColor(),
57 | ];
58 |
59 | @override
60 | Widget build(BuildContext context) {
61 | return Column(
62 | mainAxisSize: MainAxisSize.min,
63 | children: [
64 | // Hue
65 | SliderTitle('H', '${color.hue.toInt()}º'),
66 | SliderPicker(
67 | value: color.hue,
68 | max: 360.0,
69 | onChanged: hueOnChange,
70 | colors: hueColors,
71 | ),
72 |
73 | // Saturation
74 | SliderTitle('S', '${(color.saturation * 100).toInt()}º'),
75 | SliderPicker(
76 | value: color.saturation,
77 | onChanged: saturationOnChange,
78 | colors: saturationColors,
79 | ),
80 |
81 | // Value
82 | SliderTitle('L', '${(color.value * 100).toInt()}º'),
83 | SliderPicker(
84 | value: color.value,
85 | onChanged: valueOnChange,
86 | colors: valueColors,
87 | )
88 | ],
89 | );
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/lib/src/pickers/palette_hue_picker.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import '../widgets/palette_picker.dart';
4 | import '../widgets/slider_picker.dart';
5 |
6 | /// Color palette and color slider.
7 | class PaletteHuePicker extends StatefulWidget {
8 | const PaletteHuePicker({
9 | required this.color,
10 | required this.onChanged,
11 | this.paletteHeight = 280,
12 | this.palettePadding = const EdgeInsets.symmetric(
13 | horizontal: 12,
14 | vertical: 20,
15 | ),
16 | this.hueBorder,
17 | this.hueBorderRadius,
18 | this.hueHeight = 40,
19 | this.paletteBorder,
20 | this.paletteBorderRadius,
21 | Key? key,
22 | }) : super(key: key);
23 |
24 | final HSVColor color;
25 | final ValueChanged onChanged;
26 | final double paletteHeight;
27 | final EdgeInsets palettePadding;
28 | final Border? hueBorder;
29 | final double hueHeight;
30 | final BorderRadius? hueBorderRadius;
31 | final Border? paletteBorder;
32 | final BorderRadius? paletteBorderRadius;
33 |
34 | @override
35 | State createState() => _PaletteHuePickerState();
36 | }
37 |
38 | class _PaletteHuePickerState extends State {
39 | HSVColor get color => widget.color;
40 |
41 | // Hue
42 | void hueOnChange(double value) => widget.onChanged(
43 | color.withHue(value),
44 | );
45 | List get hueColors => [
46 | color.withHue(0.0).toColor(),
47 | color.withHue(60.0).toColor(),
48 | color.withHue(120.0).toColor(),
49 | color.withHue(180.0).toColor(),
50 | color.withHue(240.0).toColor(),
51 | color.withHue(300.0).toColor(),
52 | color.withHue(0.0).toColor()
53 | ];
54 |
55 | // Saturation Value
56 | void saturationValueOnChange(Offset value) => widget.onChanged(
57 | HSVColor.fromAHSV(color.alpha, color.hue, value.dx, value.dy),
58 | );
59 | // Saturation
60 | List get saturationColors => [
61 | Colors.white,
62 | HSVColor.fromAHSV(1.0, color.hue, 1.0, 1.0).toColor(),
63 | ];
64 | // Value
65 | final List valueColors = [
66 | Colors.transparent,
67 | Colors.black,
68 | ];
69 |
70 | @override
71 | Widget build(BuildContext context) {
72 | return Column(
73 | mainAxisSize: MainAxisSize.min,
74 | children: [
75 | // Palette
76 | SizedBox(
77 | height: widget.paletteHeight,
78 | child: Padding(
79 | padding: widget.palettePadding,
80 | child: PalettePicker(
81 | border: widget.paletteBorder,
82 | borderRadius: widget.paletteBorderRadius,
83 | position: Offset(color.saturation, color.value),
84 | onChanged: saturationValueOnChange,
85 | leftRightColors: saturationColors,
86 | topPosition: 1.0,
87 | bottomPosition: 0.0,
88 | topBottomColors: valueColors,
89 | ),
90 | ),
91 | ),
92 |
93 | // Slider
94 | SliderPicker(
95 | max: 360.0,
96 | border: widget.hueBorder,
97 | borderRadius: widget.hueBorderRadius,
98 | height: widget.hueHeight,
99 | value: color.hue,
100 | onChanged: hueOnChange,
101 | colors: hueColors,
102 | )
103 | ],
104 | );
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/lib/src/pickers/palette_saturation_picker.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import '../widgets/palette_picker.dart';
4 | import '../widgets/slider_picker.dart';
5 |
6 | class PaletteSaturationPicker extends StatefulWidget {
7 | const PaletteSaturationPicker({
8 | required this.color,
9 | required this.onChanged,
10 | this.paletteHeight = 280,
11 | Key? key,
12 | }) : super(key: key);
13 |
14 | final HSVColor color;
15 | final ValueChanged onChanged;
16 | final double paletteHeight;
17 |
18 | @override
19 | State createState() =>
20 | _PaletteSaturationPickerState();
21 | }
22 |
23 | class _PaletteSaturationPickerState extends State {
24 | HSVColor get color => widget.color;
25 |
26 | // Saturation
27 | void saturationOnChange(double value) => widget.onChanged(
28 | color.withSaturation(value),
29 | );
30 | List get saturationColors => [
31 | color.withSaturation(0.0).toColor(),
32 | color.withSaturation(1.0).toColor()
33 | ];
34 |
35 | // Hue Value
36 | Offset get hueValueOffset => Offset(color.hue, color.value);
37 | void hueValueOnChange(Offset value) => widget.onChanged(
38 | HSVColor.fromAHSV(color.alpha, value.dx, color.saturation, value.dy),
39 | );
40 | // Hue
41 | final List hueColors = [
42 | const Color.fromARGB(255, 255, 0, 0),
43 | const Color.fromARGB(255, 255, 255, 0),
44 | const Color.fromARGB(255, 0, 255, 0),
45 | const Color.fromARGB(255, 0, 255, 255),
46 | const Color.fromARGB(255, 0, 0, 255),
47 | const Color.fromARGB(255, 255, 0, 255),
48 | const Color.fromARGB(255, 255, 0, 0)
49 | ];
50 | // Value
51 | final List valueColors = [
52 | Colors.transparent,
53 | Colors.black,
54 | ];
55 |
56 | @override
57 | Widget build(BuildContext context) {
58 | return Column(
59 | mainAxisSize: MainAxisSize.min,
60 | children: [
61 | // Palette
62 | SizedBox(
63 | height: widget.paletteHeight,
64 | child: Padding(
65 | padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 20),
66 | child: PalettePicker(
67 | position: hueValueOffset,
68 | onChanged: hueValueOnChange,
69 | rightPosition: 360.0,
70 | leftRightColors: hueColors,
71 | topPosition: 1.0,
72 | bottomPosition: 0.0,
73 | topBottomColors: valueColors,
74 | ),
75 | ),
76 | ),
77 |
78 | // Slider
79 | SliderPicker(
80 | value: color.saturation,
81 | onChanged: saturationOnChange,
82 | colors: saturationColors,
83 | )
84 | ],
85 | );
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/lib/src/pickers/palette_value_picker.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import '../widgets/palette_picker.dart';
4 | import '../widgets/slider_picker.dart';
5 |
6 | class PaletteValuePicker extends StatefulWidget {
7 | const PaletteValuePicker({
8 | required this.color,
9 | required this.onChanged,
10 | this.paletteHeight = 280,
11 | Key? key,
12 | }) : super(key: key);
13 |
14 | final HSVColor color;
15 | final ValueChanged onChanged;
16 | final double paletteHeight;
17 |
18 | @override
19 | State createState() => _PaletteValuePickerState();
20 | }
21 |
22 | class _PaletteValuePickerState extends State {
23 | HSVColor get color => widget.color;
24 |
25 | // Value
26 | void valueOnChange(double value) => widget.onChanged(
27 | color.withValue(value),
28 | );
29 | List get valueColors => [
30 | Colors.black,
31 | color.withValue(1.0).toColor(),
32 | ];
33 |
34 | // Hue Saturation
35 | void hueSaturationOnChange(Offset value) => widget.onChanged(
36 | HSVColor.fromAHSV(color.alpha, value.dx, value.dy, color.value),
37 | );
38 | // Hue
39 | final List hueColors = [
40 | const Color.fromARGB(255, 255, 0, 0),
41 | const Color.fromARGB(255, 255, 255, 0),
42 | const Color.fromARGB(255, 0, 255, 0),
43 | const Color.fromARGB(255, 0, 255, 255),
44 | const Color.fromARGB(255, 0, 0, 255),
45 | const Color.fromARGB(255, 255, 0, 255),
46 | const Color.fromARGB(255, 255, 0, 0)
47 | ];
48 | // Saturation
49 | final List saturationColors = [
50 | Colors.transparent,
51 | Colors.white,
52 | ];
53 |
54 | @override
55 | Widget build(BuildContext context) {
56 | return Column(
57 | mainAxisSize: MainAxisSize.min,
58 | children: [
59 | // Palette
60 | SizedBox(
61 | height: widget.paletteHeight,
62 | child: Padding(
63 | padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 20),
64 | child: PalettePicker(
65 | position: Offset(color.hue, color.saturation),
66 | onChanged: hueSaturationOnChange,
67 | rightPosition: 360.0,
68 | leftRightColors: hueColors,
69 | topPosition: 1.0,
70 | bottomPosition: 0.0,
71 | topBottomColors: saturationColors,
72 | ),
73 | ),
74 | ),
75 |
76 | // Slider
77 | SliderPicker(
78 | value: color.value,
79 | onChanged: valueOnChange,
80 | colors: valueColors,
81 | )
82 | ],
83 | );
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/lib/src/pickers/rgb_picker.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import '../widgets/slider_picker.dart';
4 | import '../widgets/slider_title.dart';
5 |
6 | /// Three sliders for selecting a color based on RGB.
7 | class RGBPicker extends StatefulWidget {
8 | const RGBPicker({
9 | required this.color,
10 | required this.onChanged,
11 | Key? key,
12 | }) : super(key: key);
13 |
14 | final Color color;
15 | final ValueChanged onChanged;
16 |
17 | @override
18 | State createState() => _RGBPickerState();
19 | }
20 |
21 | class _RGBPickerState extends State {
22 | Color get color => widget.color;
23 |
24 | // Red
25 | void redOnChange(double value) => widget.onChanged(
26 | Color.fromARGB(color.alpha, value.toInt(), color.green, color.blue),
27 | );
28 | List get redColors => [
29 | color.withRed(0),
30 | color.withRed(255),
31 | ];
32 |
33 | // Green
34 | void greenOnChange(double value) => widget.onChanged(
35 | Color.fromARGB(color.alpha, color.red, value.toInt(), color.blue),
36 | );
37 | List get greenColors => [
38 | color.withGreen(0),
39 | color.withGreen(255),
40 | ];
41 |
42 | // Blue
43 | void blueOnChange(double value) => widget.onChanged(
44 | Color.fromARGB(
45 | color.alpha,
46 | color.red,
47 | color.green,
48 | value.toInt(),
49 | ),
50 | );
51 | List get blueColors => [
52 | color.withBlue(0),
53 | color.withBlue(255),
54 | ];
55 |
56 | @override
57 | Widget build(BuildContext context) {
58 | return Column(
59 | mainAxisSize: MainAxisSize.min,
60 | children: [
61 | // Red
62 | SliderTitle(
63 | 'R',
64 | color.red.toInt().toString(),
65 | ),
66 | SliderPicker(
67 | value: color.red.toDouble(),
68 | max: 255.0,
69 | onChanged: redOnChange,
70 | colors: redColors,
71 | ),
72 |
73 | // Green
74 | SliderTitle(
75 | 'G',
76 | color.green.toInt().toString(),
77 | ),
78 | SliderPicker(
79 | value: color.green.toDouble(),
80 | max: 255.0,
81 | onChanged: greenOnChange,
82 | colors: greenColors,
83 | ),
84 |
85 | // Blue
86 | SliderTitle(
87 | 'B',
88 | color.blue.toInt().toString(),
89 | ),
90 | SliderPicker(
91 | value: color.blue.toDouble(),
92 | max: 255.0,
93 | onChanged: blueOnChange,
94 | colors: blueColors,
95 | )
96 | ],
97 | );
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/lib/src/pickers/wheel_picker.dart:
--------------------------------------------------------------------------------
1 | import 'dart:math' as math;
2 |
3 | import 'package:flutter/material.dart';
4 |
5 | /// Color palette and color wheel.
6 | class WheelPicker extends StatefulWidget {
7 | const WheelPicker({
8 | required this.color,
9 | required this.onChanged,
10 | this.showPalette = true,
11 | Key? key,
12 | }) : super(key: key);
13 |
14 | final HSVColor color;
15 | final ValueChanged onChanged;
16 | final bool showPalette;
17 |
18 | @override
19 | State createState() => _WheelPickerState();
20 | }
21 |
22 | class _WheelPickerState extends State {
23 | HSVColor get color => widget.color;
24 |
25 | final GlobalKey paletteKey = GlobalKey();
26 | Offset getOffset(Offset ratio) {
27 | final RenderBox? renderBox =
28 | paletteKey.currentContext?.findRenderObject() as RenderBox?;
29 | final Offset startPosition =
30 | renderBox?.localToGlobal(Offset.zero) ?? Offset.zero;
31 | return ratio - startPosition;
32 | }
33 |
34 | Size getSize() {
35 | final RenderBox? renderBox =
36 | paletteKey.currentContext?.findRenderObject() as RenderBox?;
37 | return renderBox?.size ?? Size.zero;
38 | }
39 |
40 | bool isWheel = false;
41 | bool isPalette = false;
42 | void onPanStart(Offset offset) {
43 | final RenderBox? renderBox =
44 | paletteKey.currentContext?.findRenderObject() as RenderBox?;
45 | final Size size = renderBox?.size ?? Size.zero;
46 |
47 | final double radio = _WheelPainter.radio(size);
48 | final double squareRadio = _WheelPainter.squareRadio(radio);
49 |
50 | final Offset startPosition =
51 | renderBox?.localToGlobal(Offset.zero) ?? Offset.zero;
52 | final Offset center = Offset(size.width / 2, size.height / 2);
53 | final Offset vector = offset - startPosition - center;
54 |
55 | final bool isPalette =
56 | vector.dx.abs() < squareRadio && vector.dy.abs() < squareRadio;
57 | isWheel = !isPalette;
58 | this.isPalette = isPalette;
59 |
60 | // isWheel = vector.distance + _WheelPainter.strokeWidth > radio &&
61 | // vector.distance - squareRadio < radio;
62 | // this.isPalette =
63 | // vector.dx.abs() < squareRadio && vector.dy.abs() < squareRadio;
64 |
65 | if (isWheel) {
66 | widget.onChanged(
67 | color.withHue(
68 | _Wheel.vectorToHue(vector),
69 | ),
70 | );
71 | }
72 | if (widget.showPalette && this.isPalette) {
73 | widget.onChanged(
74 | HSVColor.fromAHSV(
75 | color.alpha,
76 | color.hue,
77 | _Wheel.vectorToSaturation(vector.dx, squareRadio).clamp(0.0, 1.0),
78 | _Wheel.vectorToValue(vector.dy, squareRadio).clamp(0.0, 1.0),
79 | ),
80 | );
81 | }
82 | }
83 |
84 | void onPanUpdate(Offset offset) {
85 | if (!widget.showPalette && isPalette) return;
86 | final RenderBox? renderBox =
87 | paletteKey.currentContext?.findRenderObject() as RenderBox?;
88 | final Size size = renderBox?.size ?? Size.zero;
89 |
90 | final double radio = _WheelPainter.radio(size);
91 | final double squareRadio = _WheelPainter.squareRadio(radio);
92 |
93 | final Offset startPosition =
94 | renderBox?.localToGlobal(Offset.zero) ?? Offset.zero;
95 | final Offset center = Offset(size.width / 2, size.height / 2);
96 | final Offset vector = offset - startPosition - center;
97 |
98 | if (isWheel) {
99 | widget.onChanged(
100 | color.withHue(
101 | _Wheel.vectorToHue(vector),
102 | ),
103 | );
104 | }
105 | if (isPalette) {
106 | widget.onChanged(
107 | HSVColor.fromAHSV(
108 | color.alpha,
109 | color.hue,
110 | _Wheel.vectorToSaturation(vector.dx, squareRadio).clamp(0.0, 1.0),
111 | _Wheel.vectorToValue(vector.dy, squareRadio).clamp(0.0, 1.0),
112 | ),
113 | );
114 | }
115 | }
116 |
117 | void onPanDown(Offset offset) => isWheel = isPalette = false;
118 |
119 | @override
120 | Widget build(BuildContext context) {
121 | return GestureDetector(
122 | onPanStart: (DragStartDetails details) {
123 | onPanStart(details.globalPosition);
124 | },
125 | onPanUpdate: (DragUpdateDetails details) {
126 | onPanUpdate(details.globalPosition);
127 | },
128 | onPanDown: (DragDownDetails details) => onPanDown(details.globalPosition),
129 | child: Container(
130 | key: paletteKey,
131 | padding: const EdgeInsets.only(top: 12.0),
132 | width: 240,
133 | height: 240,
134 | child: CustomPaint(
135 | painter: _WheelPainter(
136 | color: color,
137 | showColorBox: widget.showPalette,
138 | ),
139 | ),
140 | ),
141 | );
142 | }
143 | }
144 |
145 | class _WheelPainter extends CustomPainter {
146 | const _WheelPainter({
147 | required this.color,
148 | required this.showColorBox,
149 | }) : super();
150 |
151 | static double strokeWidth = 8;
152 | static double doubleStrokeWidth = 16;
153 | static double radio(Size size) =>
154 | math.min(size.width, size.height).toDouble() / 2 -
155 | _WheelPainter.strokeWidth;
156 | static double squareRadio(double radio) =>
157 | (radio - _WheelPainter.strokeWidth) / 1.414213562373095;
158 |
159 | final HSVColor color;
160 | final bool showColorBox;
161 |
162 | @override
163 | void paint(Canvas canvas, Size size) {
164 | final Offset center = Offset(size.width / 2, size.height / 2);
165 | final double radio = _WheelPainter.radio(size);
166 | final double squareRadio = _WheelPainter.squareRadio(radio);
167 |
168 | // Wheel
169 | final Shader sweepShader = const SweepGradient(
170 | center: Alignment.bottomRight,
171 | colors: [
172 | Color.fromARGB(255, 255, 0, 0),
173 | Color.fromARGB(255, 255, 255, 0),
174 | Color.fromARGB(255, 0, 255, 0),
175 | Color.fromARGB(255, 0, 255, 255),
176 | Color.fromARGB(255, 0, 0, 255),
177 | Color.fromARGB(255, 255, 0, 255),
178 | Color.fromARGB(255, 255, 0, 0),
179 | ],
180 | ).createShader(
181 | Rect.fromLTWH(0, 0, radio, radio),
182 | );
183 | canvas.drawCircle(
184 | center,
185 | radio,
186 | Paint()
187 | ..style = PaintingStyle.stroke
188 | ..strokeWidth = _WheelPainter.doubleStrokeWidth
189 | ..shader = sweepShader,
190 | );
191 |
192 | canvas.drawCircle(
193 | center,
194 | radio - _WheelPainter.strokeWidth,
195 | Paint()
196 | ..style = PaintingStyle.stroke
197 | ..color = Colors.grey,
198 | );
199 | canvas.drawCircle(
200 | center,
201 | radio + _WheelPainter.strokeWidth,
202 | Paint()
203 | ..style = PaintingStyle.stroke
204 | ..color = Colors.grey,
205 | );
206 |
207 | // Thumb on color wheel
208 | final Paint paintWhite = Paint()
209 | ..color = Colors.white
210 | ..strokeWidth = 4
211 | ..style = PaintingStyle.stroke;
212 | final Paint paintBlack = Paint()
213 | ..color = Colors.black
214 | ..strokeWidth = 6
215 | ..style = PaintingStyle.stroke;
216 | final Offset wheel = _Wheel.hueToVector(
217 | (color.hue + 360.0) * math.pi / 180.0, radio, center);
218 | canvas.drawCircle(wheel, 12, paintBlack);
219 | canvas.drawCircle(wheel, 12, paintWhite);
220 |
221 | if (!showColorBox) return;
222 |
223 | // Palette
224 | final Rect rect = Rect.fromLTWH(center.dx - squareRadio,
225 | center.dy - squareRadio, squareRadio * 2, squareRadio * 2);
226 | final RRect rRect = RRect.fromRectAndRadius(
227 | rect,
228 | const Radius.circular(4),
229 | );
230 |
231 | final Shader horizontal = LinearGradient(
232 | colors: [
233 | Colors.white,
234 | HSVColor.fromAHSV(1.0, color.hue, 1.0, 1.0).toColor()
235 | ],
236 | ).createShader(rect);
237 | canvas.drawRRect(
238 | rRect,
239 | Paint()
240 | ..style = PaintingStyle.fill
241 | ..shader = horizontal,
242 | );
243 |
244 | final Shader vertical = const LinearGradient(
245 | begin: Alignment.topCenter,
246 | end: Alignment.bottomCenter,
247 | colors: [Colors.transparent, Colors.black],
248 | ).createShader(rect);
249 | canvas.drawRRect(
250 | rRect,
251 | Paint()
252 | ..style = PaintingStyle.fill
253 | ..shader = vertical,
254 | );
255 |
256 | canvas.drawRRect(
257 | rRect,
258 | Paint()
259 | ..style = PaintingStyle.stroke
260 | ..color = Colors.grey,
261 | );
262 |
263 | // Thumb on color box
264 | final double paletteX =
265 | _Wheel.saturationToVector(color.saturation, squareRadio, center.dx);
266 | final double paletteY =
267 | _Wheel.valueToVector(color.value, squareRadio, center.dy);
268 | final Offset paletteVector = Offset(paletteX, paletteY);
269 | canvas.drawCircle(paletteVector, 12, paintBlack);
270 | canvas.drawCircle(paletteVector, 12, paintWhite);
271 | }
272 |
273 | @override
274 | bool shouldRepaint(_WheelPainter other) => true;
275 | }
276 |
277 | class _Wheel {
278 | static double vectorToHue(Offset vector) =>
279 | (((math.atan2(vector.dy, vector.dx)) * 180.0 / math.pi) + 360.0) % 360.0;
280 | static double vectorToSaturation(double vectorX, double squareRadio) =>
281 | vectorX * 0.5 / squareRadio + 0.5;
282 | static double vectorToValue(double vectorY, double squareRadio) =>
283 | 0.5 - vectorY * 0.5 / squareRadio;
284 |
285 | static Offset hueToVector(double h, double radio, Offset center) =>
286 | Offset(math.cos(h) * radio + center.dx, math.sin(h) * radio + center.dy);
287 | static double saturationToVector(
288 | double s, double squareRadio, double centerX) =>
289 | (s - 0.5) * squareRadio / 0.5 + centerX;
290 | static double valueToVector(double l, double squareRadio, double centerY) =>
291 | (0.5 - l) * squareRadio / 0.5 + centerY;
292 | }
293 |
--------------------------------------------------------------------------------
/lib/src/widgets/alpha_picker.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import 'slider_picker.dart';
4 | import 'slider_title.dart';
5 |
6 | /// Slider for selecting the alpha value (0-255).
7 | class AlphaPicker extends StatefulWidget {
8 | const AlphaPicker({
9 | required this.alpha,
10 | required this.onChanged,
11 | Key? key,
12 | }) : super(key: key);
13 |
14 | final int alpha;
15 | final ValueChanged onChanged;
16 |
17 | @override
18 | State createState() => _AlphaPickerState();
19 | }
20 |
21 | class _AlphaPickerState extends State {
22 | void valueOnChanged(double ratio) {
23 | widget.onChanged(ratio.toInt());
24 | }
25 |
26 | @override
27 | Widget build(BuildContext context) {
28 | return Column(
29 | mainAxisSize: MainAxisSize.min,
30 | children: [
31 | // Alpha
32 | SliderTitle('A', widget.alpha.toString()),
33 | SliderPicker(
34 | value: widget.alpha.toDouble(),
35 | max: 255.0,
36 | onChanged: valueOnChanged,
37 | child: CustomPaint(
38 | painter: _AlphaTrackPainter(),
39 | ),
40 | )
41 | ],
42 | );
43 | }
44 | }
45 |
46 | // Track
47 | class _AlphaTrackPainter extends CustomPainter {
48 | @override
49 | void paint(Canvas canvas, Size size) {
50 | final double side = size.height / 2;
51 | final Paint paint = Paint()..color = Colors.black12;
52 |
53 | for (int i = 0; i * side < size.width; i++) {
54 | if (i % 2 == 0) {
55 | canvas.drawRect(Rect.fromLTWH(i * side, 0, side, side), paint);
56 | } else {
57 | canvas.drawRect(Rect.fromLTWH(i * side, side, side, side), paint);
58 | }
59 | }
60 |
61 | final Rect rect = Offset.zero & size;
62 | const Gradient gradient = LinearGradient(
63 | colors: [Colors.transparent, Colors.grey],
64 | );
65 | canvas.drawRect(
66 | rect,
67 | Paint()..shader = gradient.createShader(rect),
68 | );
69 | }
70 |
71 | @override
72 | bool shouldRepaint(CustomPainter oldDelegate) => false;
73 | }
74 |
--------------------------------------------------------------------------------
/lib/src/widgets/hex_picker.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | /// Textfield for entering the Hex color code (RRGGBB).
4 | class HexPicker extends StatefulWidget {
5 | HexPicker({
6 | required this.color,
7 | required this.onChanged,
8 | Key? key,
9 | }) : _controller = TextEditingController(
10 | text: _Hex.colorToString(color).toUpperCase(),
11 | ),
12 | super(key: key);
13 |
14 | final Color color;
15 | final ValueChanged onChanged;
16 | final TextEditingController _controller;
17 |
18 | @override
19 | State createState() => _HexPickerState();
20 | }
21 |
22 | class _HexPickerState extends State {
23 | void textOnSubmitted(String value) => widget.onChanged(
24 | textOnChenged(value),
25 | );
26 | Color textOnChenged(String text) {
27 | final String? hex = _Hex.textSubString(text);
28 | if (hex == null) return widget.color;
29 |
30 | try {
31 | return _Hex.intToColor(_Hex.stringToInt(hex));
32 | } catch (_) {
33 | return widget.color;
34 | }
35 | }
36 |
37 | @override
38 | Widget build(BuildContext context) {
39 | return Row(
40 | mainAxisSize: MainAxisSize.min,
41 | children: [
42 | // Text
43 | Padding(
44 | padding: const EdgeInsets.symmetric(horizontal: 4),
45 | child: Text(
46 | '#',
47 | style:
48 | Theme.of(context).textTheme.titleLarge?.copyWith(fontSize: 18),
49 | ),
50 | ),
51 |
52 | // TextField
53 | Expanded(
54 | child: TextField(
55 | style: Theme.of(context)
56 | .textTheme
57 | .headlineSmall
58 | ?.copyWith(fontSize: 20),
59 | focusNode: FocusNode()..addListener(() {}),
60 | controller: widget._controller,
61 | onSubmitted: textOnSubmitted,
62 | decoration: const InputDecoration.collapsed(hintText: 'hex code'),
63 | ),
64 | )
65 | ],
66 | );
67 | }
68 | }
69 |
70 | class _Hex {
71 | // Hex Number To Color
72 | static Color intToColor(int hexNumber) => Color.fromARGB(
73 | 255,
74 | (hexNumber >> 16) & 0xFF,
75 | (hexNumber >> 8) & 0xFF,
76 | (hexNumber >> 0) & 0xFF,
77 | );
78 |
79 | // String To Hex Number
80 | static int stringToInt(String hex) => int.parse(hex, radix: 16);
81 |
82 | // String To Color
83 | static String colorToString(Color color) =>
84 | _colorToString(
85 | color.red.toRadixString(16),
86 | ) +
87 | _colorToString(
88 | color.green.toRadixString(16),
89 | ) +
90 | _colorToString(
91 | color.blue.toRadixString(16),
92 | );
93 | static String _colorToString(String text) =>
94 | text.length == 1 ? '0$text' : text;
95 |
96 | // Subste
97 | static String? textSubString(String? text) {
98 | if (text == null) return null;
99 |
100 | if (text.length < 6) return null;
101 |
102 | if (text.length == 6) return text;
103 |
104 | return text.substring(text.length - 6, 6);
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/lib/src/widgets/palette_picker.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | /// Palette for selecting two values between 0 and 1.
4 | class PalettePicker extends StatefulWidget {
5 | const PalettePicker({
6 | required this.position,
7 | required this.onChanged,
8 | required this.leftRightColors,
9 | required this.topBottomColors,
10 | this.leftPosition = 0.0,
11 | this.rightPosition = 1.0,
12 | this.topPosition = 0.0,
13 | this.bottomPosition = 1.0,
14 | this.border = const Border.fromBorderSide(BorderSide(color: Colors.grey)),
15 | this.borderRadius = const BorderRadius.all(Radius.circular(6)),
16 | Key? key,
17 | }) : super(key: key);
18 |
19 | final Border? border;
20 | final BorderRadius? borderRadius;
21 | final Offset position;
22 | final ValueChanged onChanged;
23 | final double leftPosition;
24 | final double rightPosition;
25 | final List leftRightColors;
26 | final double topPosition;
27 | final double bottomPosition;
28 | final List topBottomColors;
29 |
30 | @override
31 | State createState() => _PalettePickerState();
32 | }
33 |
34 | class _PalettePickerState extends State {
35 | final GlobalKey paletteKey = GlobalKey();
36 |
37 | Offset get position => widget.position;
38 | double get leftPosition => widget.leftPosition;
39 | double get rightPosition => widget.rightPosition;
40 | double get topPosition => widget.topPosition;
41 | double get bottomPosition => widget.bottomPosition;
42 |
43 | /// Position(min, max) > Ratio(0, 1)
44 | Offset positionToRatio() {
45 | final double ratioX = leftPosition < rightPosition
46 | ? positionToRatio2(position.dx, leftPosition, rightPosition)
47 | : 1.0 - positionToRatio2(position.dx, rightPosition, leftPosition);
48 |
49 | final double ratioY = topPosition < bottomPosition
50 | ? positionToRatio2(position.dy, topPosition, bottomPosition)
51 | : 1.0 - positionToRatio2(position.dy, bottomPosition, topPosition);
52 |
53 | return Offset(ratioX, ratioY);
54 | }
55 |
56 | double positionToRatio2(
57 | double postiton,
58 | double minPostition,
59 | double maxPostition,
60 | ) {
61 | if (postiton < minPostition) return 0.0;
62 | if (postiton > maxPostition) return 1.0;
63 | return (postiton - minPostition) / (maxPostition - minPostition);
64 | }
65 |
66 | /// Ratio(0, 1) > Position(min, max)
67 | void ratioToPosition(Offset ratio) {
68 | final RenderBox? renderBox =
69 | paletteKey.currentContext?.findRenderObject() as RenderBox?;
70 | final Offset startposition =
71 | renderBox?.localToGlobal(Offset.zero) ?? Offset.zero;
72 | final Size size = renderBox?.size ?? Size.zero;
73 | final Offset updateOffset = ratio - startposition;
74 |
75 | final double ratioX = updateOffset.dx / size.width;
76 | final double ratioY = updateOffset.dy / size.height;
77 |
78 | final double positionX = leftPosition < rightPosition
79 | ? ratioToPosition2(ratioX, leftPosition, rightPosition)
80 | : ratioToPosition2(1.0 - ratioX, rightPosition, leftPosition);
81 |
82 | final double positionY = topPosition < bottomPosition
83 | ? ratioToPosition2(ratioY, topPosition, bottomPosition)
84 | : ratioToPosition2(1.0 - ratioY, bottomPosition, topPosition);
85 |
86 | final Offset position = Offset(positionX, positionY);
87 | widget.onChanged(position);
88 | }
89 |
90 | double ratioToPosition2(
91 | double ratio,
92 | double minposition,
93 | double maxposition,
94 | ) {
95 | if (ratio < 0.0) return minposition;
96 | if (ratio > 1.0) return maxposition;
97 | return ratio * maxposition + (1.0 - ratio) * minposition;
98 | }
99 |
100 | Widget buildLeftRightColors() {
101 | return Container(
102 | decoration: BoxDecoration(
103 | border: widget.border,
104 | borderRadius: widget.borderRadius,
105 | gradient: LinearGradient(
106 | colors: widget.leftRightColors,
107 | ),
108 | ),
109 | );
110 | }
111 |
112 | Widget buildTopBottomColors() {
113 | return Container(
114 | decoration: BoxDecoration(
115 | border: widget.border,
116 | borderRadius: widget.borderRadius,
117 | gradient: LinearGradient(
118 | begin: Alignment.topCenter,
119 | end: Alignment.bottomCenter,
120 | colors: widget.topBottomColors,
121 | ),
122 | ),
123 | );
124 | }
125 |
126 | Widget buildGestureDetector() {
127 | return GestureDetector(
128 | onPanStart: (DragStartDetails details) =>
129 | ratioToPosition(details.globalPosition),
130 | onPanUpdate: (DragUpdateDetails details) =>
131 | ratioToPosition(details.globalPosition),
132 | onPanDown: (DragDownDetails details) =>
133 | ratioToPosition(details.globalPosition),
134 | child: SizedBox(
135 | key: paletteKey,
136 | width: double.infinity,
137 | height: double.infinity,
138 | child: CustomPaint(
139 | painter: _PalettePainter(
140 | ratio: positionToRatio(),
141 | ),
142 | ),
143 | ),
144 | );
145 | }
146 |
147 | @override
148 | Widget build(BuildContext context) {
149 | return Stack(
150 | children: [
151 | // LeftRightColors
152 | buildLeftRightColors(),
153 |
154 | // TopBottomColors
155 | buildTopBottomColors(),
156 |
157 | // GestureDetector
158 | buildGestureDetector(),
159 | ],
160 | );
161 | }
162 | }
163 |
164 | class _PalettePainter extends CustomPainter {
165 | _PalettePainter({
166 | required this.ratio,
167 | }) : super();
168 |
169 | final Offset ratio;
170 |
171 | @override
172 | void paint(Canvas canvas, Size size) {
173 | final Paint paintWhite = Paint()
174 | ..color = Colors.white
175 | ..strokeWidth = 4
176 | ..style = PaintingStyle.stroke;
177 | final Paint paintBlack = Paint()
178 | ..color = Colors.black
179 | ..strokeWidth = 6
180 | ..style = PaintingStyle.stroke;
181 |
182 | final Offset offset = Offset(size.width * ratio.dx, size.height * ratio.dy);
183 | canvas.drawCircle(offset, 12, paintBlack);
184 | canvas.drawCircle(offset, 12, paintWhite);
185 | }
186 |
187 | @override
188 | bool shouldRepaint(_PalettePainter other) => true;
189 | }
190 |
--------------------------------------------------------------------------------
/lib/src/widgets/slider_picker.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | /// Slider for selecting a value between 0 and 1.
4 | class SliderPicker extends StatefulWidget {
5 | const SliderPicker({
6 | required this.value,
7 | required this.onChanged,
8 | this.min = 0.0,
9 | this.max = 1.0,
10 | this.colors,
11 | this.child,
12 | this.borderRadius = _SliderPickerState._defaultBorderRadius,
13 | this.border = const Border.fromBorderSide(BorderSide(color: Colors.grey)),
14 | this.height = 40,
15 | Key? key,
16 | }) : assert(value >= min && value <= max),
17 | super(key: key);
18 | final Border? border;
19 | final double height;
20 | final BorderRadius? borderRadius;
21 | final double value;
22 | final ValueChanged onChanged;
23 | final double min;
24 | final double max;
25 | final List? colors;
26 | final Widget? child;
27 |
28 | @override
29 | State createState() => _SliderPickerState();
30 | }
31 |
32 | class _SliderPickerState extends State {
33 | static const _defaultBorderRadius = BorderRadius.all(Radius.circular(20.0));
34 |
35 | double get value => widget.value;
36 | double get min => widget.min;
37 | double get max => widget.max;
38 |
39 | double getRatio() => ((value - min) / (max - min)).clamp(0.0, 1.0);
40 | void setRatio(double ratio) => widget.onChanged(
41 | (ratio * (max - min) + min).clamp(min, max),
42 | );
43 |
44 | void onPanUpdate(DragUpdateDetails details, BoxConstraints box) {
45 | final RenderBox? renderBox = super.context.findRenderObject() as RenderBox?;
46 | final Offset offset =
47 | renderBox?.globalToLocal(details.globalPosition) ?? Offset.zero;
48 | final double ratio = offset.dx / box.maxWidth;
49 | super.setState(() => setRatio(ratio));
50 | }
51 |
52 | Widget buildSlider(double maxWidth) {
53 | return SizedBox(
54 | width: maxWidth,
55 | height: widget.height,
56 | child: CustomMultiChildLayout(
57 | delegate: _SliderLayout(),
58 | children: [
59 | // Track
60 | LayoutId(
61 | id: _SliderLayout.track,
62 | child: (widget.colors == null)
63 | ?
64 |
65 | // Child
66 | DecoratedBox(
67 | decoration: BoxDecoration(
68 | borderRadius: widget.borderRadius,
69 | border: widget.border,
70 | ),
71 | child: ClipRRect(
72 | borderRadius: widget.borderRadius ?? _defaultBorderRadius,
73 | child: widget.child,
74 | ),
75 | )
76 | :
77 |
78 | // Color
79 | DecoratedBox(
80 | decoration: BoxDecoration(
81 | borderRadius: widget.borderRadius,
82 | border: widget.border,
83 | gradient: LinearGradient(colors: widget.colors!),
84 | ),
85 | ),
86 | ),
87 |
88 | // Thumb
89 | LayoutId(
90 | id: _SliderLayout.thumb,
91 | child: Transform(
92 | transform: Matrix4.identity()
93 | ..translate(
94 | _ThumbPainter.getWidth(getRatio(), maxWidth),
95 | ),
96 | child: CustomPaint(
97 | painter: _ThumbPainter(),
98 | ),
99 | ),
100 | ),
101 |
102 | // GestureContainer
103 | LayoutId(
104 | id: _SliderLayout.gestureContainer,
105 | child: LayoutBuilder(builder: buildGestureDetector),
106 | )
107 | ],
108 | ),
109 | );
110 | }
111 |
112 | Widget buildGestureDetector(BuildContext context, BoxConstraints box) {
113 | return GestureDetector(
114 | onPanUpdate: (DragUpdateDetails detail) => onPanUpdate(detail, box),
115 | child: Container(
116 | color: const Color(0x00000000),
117 | ),
118 | );
119 | }
120 |
121 | @override
122 | Widget build(BuildContext context) {
123 | return SizedBox(
124 | height: widget.height,
125 | child: LayoutBuilder(
126 | builder: (BuildContext context, BoxConstraints box) =>
127 | buildSlider(box.maxWidth),
128 | ),
129 | );
130 | }
131 | }
132 |
133 | /// Slider
134 | class _SliderLayout extends MultiChildLayoutDelegate {
135 | static const String track = 'track';
136 | static const String thumb = 'thumb';
137 | static const String gestureContainer = 'gesturecontainer';
138 |
139 | @override
140 | void performLayout(Size size) {
141 | // Track
142 | super.layoutChild(
143 | track,
144 | BoxConstraints.tightFor(
145 | width: size.width, height: _ThumbPainter.doubleTrackWidth),
146 | );
147 | super.positionChild(
148 | track,
149 | Offset(0.0, size.height / 2 - _ThumbPainter.trackWidth),
150 | );
151 |
152 | // Thumb
153 | super.layoutChild(
154 | thumb,
155 | BoxConstraints.tightFor(width: 10.0, height: size.height / 2),
156 | );
157 | super.positionChild(
158 | thumb,
159 | Offset(0.0, size.height * 0.5),
160 | );
161 |
162 | // GestureContainer
163 | super.layoutChild(
164 | gestureContainer,
165 | BoxConstraints.tightFor(width: size.width, height: size.height),
166 | );
167 | super.positionChild(gestureContainer, Offset.zero);
168 | }
169 |
170 | @override
171 | bool shouldRelayout(_SliderLayout oldDelegate) => false;
172 | }
173 |
174 | /// Thumb
175 | class _ThumbPainter extends CustomPainter {
176 | static double width = 12;
177 | static double trackWidth = 14;
178 | static double doubleTrackWidth = 28;
179 | static double getWidth(double value, double maxWidth) =>
180 | (maxWidth - trackWidth - trackWidth) * value + trackWidth;
181 |
182 | @override
183 | void paint(Canvas canvas, Size size) {
184 | final Paint paintWhite = Paint()
185 | ..color = Colors.white
186 | ..strokeWidth = 4
187 | ..style = PaintingStyle.stroke;
188 | final Paint paintBlack = Paint()
189 | ..color = Colors.black
190 | ..strokeWidth = 6
191 | ..style = PaintingStyle.stroke;
192 |
193 | canvas.drawCircle(Offset.zero, _ThumbPainter.width, paintBlack);
194 | canvas.drawCircle(Offset.zero, _ThumbPainter.width, paintWhite);
195 | }
196 |
197 | @override
198 | bool shouldRepaint(CustomPainter oldDelegate) => false;
199 | }
200 |
--------------------------------------------------------------------------------
/lib/src/widgets/slider_title.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | class SliderTitle extends StatelessWidget {
4 | const SliderTitle(
5 | this.title,
6 | this.text, {
7 | Key? key,
8 | }) : super(key: key);
9 |
10 | final String title;
11 | final String text;
12 |
13 | @override
14 | Widget build(BuildContext context) {
15 | return Container(
16 | alignment: Alignment.bottomCenter,
17 | margin: const EdgeInsets.fromLTRB(10, 8, 10, 0),
18 | child: Row(
19 | children: [
20 | Opacity(
21 | opacity: 0.7,
22 | child: Text(
23 | title,
24 | style: Theme.of(context).textTheme.titleLarge?.copyWith(
25 | fontSize: 18,
26 | ),
27 | ),
28 | ),
29 | const Spacer(),
30 | Text(
31 | text,
32 | style: Theme.of(context).textTheme.headlineSmall?.copyWith(
33 | fontSize: 18,
34 | ),
35 | ),
36 | ],
37 | ),
38 | );
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: flutter_hsvcolor_picker
2 | description: A HSV color picker inspired by chrome devtools and a material color picker for your flutter app.
3 | version: 1.5.1
4 | homepage: https://github.com/fluttercandies/flutter_hsvcolor_picker
5 |
6 | dependencies:
7 | flutter:
8 | sdk: flutter
9 |
10 | environment:
11 | sdk: '>=2.16.0 <3.0.0'
12 | flutter: '>=2.10.0'
13 |
14 | dev_dependencies:
15 | flutter_lints: '>=2.0.0 <5.0.0'
16 | flutter_test:
17 | sdk: flutter
18 |
--------------------------------------------------------------------------------
/screenshot/design.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/screenshot/design.png
--------------------------------------------------------------------------------
/screenshot/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/screenshot/logo.png
--------------------------------------------------------------------------------
/screenshot/phone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercandies/flutter_hsvcolor_picker/31b088286a9c6bed3561a9ee6f78e391c3587ccb/screenshot/phone.png
--------------------------------------------------------------------------------