├── .gitignore ├── .metadata ├── .pubignore ├── .vscode ├── launch.json └── settings.json ├── CHANGELOG.md ├── LICENSE ├── PUBLISH.md ├── 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 │ │ │ ├── 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 │ ├── Podfile │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ │ └── WorkspaceSettings.xcsettings │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ ├── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ │ ├── Icon-App-20x20@1x.png │ │ │ │ ├── Icon-App-20x20@2x.png │ │ │ │ ├── Icon-App-20x20@3x.png │ │ │ │ ├── Icon-App-29x29@1x.png │ │ │ │ ├── Icon-App-29x29@2x.png │ │ │ │ ├── Icon-App-29x29@3x.png │ │ │ │ ├── Icon-App-40x40@1x.png │ │ │ │ ├── Icon-App-40x40@2x.png │ │ │ │ ├── Icon-App-40x40@3x.png │ │ │ │ ├── Icon-App-60x60@2x.png │ │ │ │ ├── Icon-App-60x60@3x.png │ │ │ │ ├── Icon-App-76x76@1x.png │ │ │ │ ├── Icon-App-76x76@2x.png │ │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ │ └── LaunchImage.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── LaunchImage.png │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ └── README.md │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── Runner-Bridging-Header.h │ └── RunnerTests │ │ └── RunnerTests.swift ├── lib │ ├── main.dart │ ├── model.dart │ └── theme.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 │ ├── Podfile │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ └── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── app_icon_1024.png │ │ │ │ ├── app_icon_128.png │ │ │ │ ├── app_icon_16.png │ │ │ │ ├── app_icon_256.png │ │ │ │ ├── app_icon_32.png │ │ │ │ ├── app_icon_512.png │ │ │ │ └── app_icon_64.png │ │ ├── Base.lproj │ │ │ └── MainMenu.xib │ │ ├── Configs │ │ │ ├── AppInfo.xcconfig │ │ │ ├── Debug.xcconfig │ │ │ ├── Release.xcconfig │ │ │ └── Warnings.xcconfig │ │ ├── DebugProfile.entitlements │ │ ├── Info.plist │ │ ├── MainFlutterWindow.swift │ │ └── Release.entitlements │ └── RunnerTests │ │ └── RunnerTests.swift ├── pubspec.yaml ├── test │ └── widget_test.dart ├── web │ ├── favicon.png │ ├── icons │ │ ├── Icon-192.png │ │ ├── Icon-512.png │ │ ├── Icon-maskable-192.png │ │ └── Icon-maskable-512.png │ ├── index.html │ └── manifest.json └── windows │ ├── .gitignore │ ├── CMakeLists.txt │ ├── flutter │ ├── CMakeLists.txt │ ├── generated_plugin_registrant.cc │ ├── generated_plugin_registrant.h │ └── generated_plugins.cmake │ └── runner │ ├── CMakeLists.txt │ ├── Runner.rc │ ├── flutter_window.cpp │ ├── flutter_window.h │ ├── main.cpp │ ├── resource.h │ ├── resources │ └── app_icon.ico │ ├── runner.exe.manifest │ ├── utils.cpp │ ├── utils.h │ ├── win32_window.cpp │ └── win32_window.h ├── images ├── main_convenience_pickers.png ├── main_new_pickers.png ├── show_checkbox_picker-custom.png ├── show_checkbox_picker-d.png ├── show_checkbox_picker-l.png ├── show_checkbox_picker-ll.png ├── show_color_picker-d.png ├── show_color_picker-l.png ├── show_color_picker-ll.png ├── show_date_picker-d.png ├── show_date_picker-l.png ├── show_date_picker-ll.png ├── show_empty_picker-d.png ├── show_empty_picker-l.png ├── show_number_picker-d.png ├── show_number_picker-l.png ├── show_number_picker-ll.png ├── show_palette_picker-d.png ├── show_palette_picker-l.png ├── show_palette_picker-ll.png ├── show_radio_picker-d.png ├── show_radio_picker-l.png ├── show_radio_picker-ll.png ├── show_scroll_picker-d.png ├── show_scroll_picker-l.png ├── show_scroll_picker-ll.png ├── show_selection_picker-d.png ├── show_selection_picker-l.png ├── show_selection_picker-ll.png ├── show_swatch_picker-d.png ├── show_swatch_picker-l.png ├── show_swatch_picker-ll.png ├── show_time_picker-d.png ├── show_time_picker-l.png └── show_time_picker-ll.png ├── lib ├── dialogs │ ├── checkbox_picker_dialog.dart │ ├── radio_picker_dialog.dart │ ├── responsive_dialog.dart │ ├── scroll_picker_dialog.dart │ └── selection_picker_dialog.dart ├── flutter_material_pickers.dart ├── helpers │ ├── show_checkbox_picker.dart │ ├── show_color_picker.dart │ ├── show_date_picker.dart │ ├── show_file_picker.dart │ ├── show_number_picker.dart │ ├── show_palette_picker.dart │ ├── show_radio_picker.dart │ ├── show_responsive_dialog.dart │ ├── show_scroll_picker.dart │ ├── show_selection_picker.dart │ ├── show_swatch_picker.dart │ └── show_time_picker.dart ├── interfaces │ └── common_dialog_properties.dart ├── main.dart ├── models │ ├── picker_model.dart │ └── select_all_config.dart └── pickers │ ├── checkbox_picker.dart │ ├── radio_picker.dart │ ├── scroll_picker.dart │ └── selection_picker.dart └── pubspec.yaml /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled. 5 | 6 | version: 7 | revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 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: d3d8effc686d73e0114d71abdcccef63fa1f25d2 17 | base_revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 18 | - platform: android 19 | create_revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 20 | base_revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 21 | - platform: ios 22 | create_revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 23 | base_revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 24 | - platform: linux 25 | create_revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 26 | base_revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 27 | - platform: macos 28 | create_revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 29 | base_revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 30 | - platform: web 31 | create_revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 32 | base_revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 33 | - platform: windows 34 | create_revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 35 | base_revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 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 | -------------------------------------------------------------------------------- /.pubignore: -------------------------------------------------------------------------------- 1 | .vscode/* 2 | 3 | images/* 4 | 5 | example/test/* 6 | example/build/* 7 | example/ios/* 8 | example/android/* 9 | example/web/* 10 | example/windows/* -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "flutter_material_pickers example", 9 | "cwd": "example", 10 | "request": "launch", 11 | "type": "dart" 12 | }, 13 | { 14 | "name": "flutter_material_pickers example (profile mode)", 15 | "cwd": "example", 16 | "request": "launch", 17 | "type": "dart", 18 | "flutterMode": "profile" 19 | } 20 | ] 21 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "cmake.configureOnOpen": false 3 | } -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Releases 2 | 3 | ## [3.7.0] - 2024-05-26 4 | 5 | - Updated `intl` to 0.19.0 6 | - Updated `file_picker` to 8.0.3 7 | - for `showMaterialScrollPicker`, defaulting `showDivider` to false 8 | - for `showMaterialNumberPicker`, defaulting `showDivider` to false 9 | - fixed missing `title` on Time Picker 10 | 11 | ## [3.6.0] - 2023-07-14 12 | 13 | - Updated `file_picker` to 5.3.2 14 | 15 | ## [3.5.0] - 2023-05-22 16 | 17 | - Implemented `dart fix` automated changes 18 | - Added support for SDK 3.0.0 19 | 20 | ## [3.4.0] - 2023-05-22 21 | 22 | - Upgraded `intl` to 0.18.0 23 | - Upgraded `file_picker` to 5.3.0 24 | 25 | ## [3.3.0] - 2022-10-25 26 | 27 | - Enabled `SelectionPicker` to have a null `selectedItem` property 28 | 29 | ## [3.2.0] - 2022-10-24 30 | 31 | - Updated pubspec.yaml with file_picker v^5.2.1 to resolve version conflicts on other packages 32 | - Added option to disable cancellation for most picker / dialog types (Issue: #42) 33 | - Added an optional Select All / Deselect All option to the checkbox picker 34 | - Added an optional "onSelectionChanged" to the checkbox dialog, which calls back each time a selection changes, but before submission. 35 | 36 | ## [3.1.4+1] - 2022-04-08 37 | 38 | - formatting 39 | 40 | ## [3.1.4] - 2022-04-08 41 | 42 | - added example back in 43 | - improved documentation 44 | 45 | ## [3.1.3] - 2022-04-07 46 | 47 | - Updated dependency versions 48 | 49 | ## [3.1.2] - 2021-09-29 50 | 51 | - Updated `flutter_colorpicker` version 52 | - replaces `theme.accentColor` with `theme.colorScheme.secondary` 53 | 54 | ## [3.1.1] - 2021-08-04 55 | 56 | - Fixing `transformer` method not being called on `showMaterialScrollPicker` 57 | 58 | ## [3.1.0] - 2021-06-11 59 | 60 | - provided a standard `PickerModel` that can be used with all picker type controls 61 | 62 | ## [3.0.0] - 2021-06-10 63 | 64 | There are some **breaking changes** in 3.0.0 (from 2.1.1). 65 | 66 | - Pickers accept generic types passed to pickers and helpers. 67 | - There's no need to pass several lists (items, values, icons), just pass 68 | one list of generic type objects. 69 | - A selected item of generic type is passed as `selectedItem` not 70 | `selectedValue` to match name of `items`. 71 | - To convert an item to a string displayed to a user either override 72 | toString() in generic type class or pass transformer callback which 73 | accepts an item and returns a String. (see examples) 74 | - To provide item's icon in SelectionPicker (and alikes), pass iconizer 75 | callback which accepts an item and returns an Icon. (see example) 76 | 77 | ## [2.1.1] - 2021-4-13 78 | 79 | - Fixed item not showing on scroll picker [thanks elliotrtd] 80 | 81 | ## [2.1.0] - 2021-4-12 82 | 83 | - Added an optional `values` list to `showMaterialSelectionPicker`, `showMaterialCheckboxPicker`, `showMaterialRadioPicker`, and `showMaterialScrollPicker`. This allows separate display names and returned values. Can be used for consistent localization scenarios. Note: This is a minor breakign change. The field `selectedItem` was changed to `selectedValue`. 84 | 85 | ## [2.0.1] - 2021-03-22 86 | 87 | - allow null initial value for RadioPicker 88 | - allow null initial value for CheckBoxPicker 89 | - allow null initial value for NumberRicker 90 | - upgraded to null save colorpicker 91 | 92 | ## [2.0.0] - 2021-03-12 93 | 94 | - Bumped SDK restriction from 2.7.0 to 2.12.0 (new minimum). 95 | - Removed the meta package dependency since the @required annotation has been replaced and is not needed for named parameters anymore. 96 | - Added the required modifier to any required parameters in widgets and/or functions. 97 | - Changed the types of any optional named parameters to be nullable (ex. from String to String?). 98 | - Removed unnecessary not null asserts for required parameters as package users cannot send nullable values for these anymore. 99 | - Replaced the DynamicTheme dependency with the actively maintained AdaptiveTheme in order to make sure the package supports sound null safety and is not in mixed mode (ie. depends on packages with no null safety). 100 | - Replaced deprecated widget FlatButton with the replacement ElevatedButton where applicable (no changes to api surface of the package were made). 101 | - changed the datePicker dialog to use the ResponsiveDialog so it behaves like the other widgets 102 | 103 | ## [1.9.2] - 2021-02-08 104 | 105 | - added support for `intl` nullsafety.2 106 | 107 | ## [1.9.1] - 2021-01-11 108 | 109 | - updated formatting to pass static analysis tests 110 | 111 | ## [1.9.0] - 2021-01-05 112 | 113 | - implemented step feature on MaterialNumberPicker (thanks Enough7) 114 | - upgraded to latest dependencies 115 | 116 | ## [1.8.1] - 2020-11-10 117 | 118 | - updated file_picker to version 2.0.12 119 | - Fix allowedExtensions on file picker [CoolONEOfficial] 120 | 121 | ## [1.8.0] - 2020-10-01 122 | 123 | - Upgraded to 2.0 version of `file_picker` 124 | - confirmed compatibility with Web and added web to the example 125 | 126 | ## [1.7.4] - 2020-08-27 127 | 128 | - fixed null error in scrollpicker 129 | 130 | ## [1.7.3] - 2020-08-26 131 | 132 | - updated 'showMaterialResponsiveDialog' to property capture 'maxShortSide' parameter. 133 | - fixed null error in numberpicker 134 | 135 | ## [1.7.2] - 2020-07-27 136 | 137 | - added `showDivider` option to hide the divider on the scroll picker 138 | 139 | ## [1.7.1] - 2020-07-21 140 | 141 | - removed pub.dev issue in readme.md with email 142 | - exposed FileType enum from file_picker 143 | 144 | ## [1.7.0] - 2020-07-20 145 | 146 | - changed file picker from file_picker_cross to file_picker for better compatibility 147 | - added `onConfirmed` event to all dialog helpers 148 | 149 | ## [1.6.0] - 2020-07-08 150 | 151 | - added ability to customize `confirmText` and `cancelText` 152 | - added `onCancelled` handler to all helpers 153 | - updated dependencies 154 | 155 | ## [1.5.4] - 5/25/2020 156 | 157 | - added `hideButtons` to `ResponsiveDialog` 158 | 159 | ## [1.5.3] - 5/24/2020 160 | 161 | - added `showMaterialFilePicker` which wraps `file_picker_cross` 162 | 163 | ## [1.5.2] - 5/20/2020 164 | 165 | - changed `ScrollPicker` to use `ListWheelScrollView` internally so it functions better. 166 | 167 | ## [1.5.1] - 5/15/2020 168 | 169 | - fixed positioning bug in selection picker with only two items 170 | 171 | ## [1.5.0] - 5/15/2020 172 | 173 | - constrained max sizes for dialogs so they don't go full screen 174 | - verified correct functionality on flutter web 175 | 176 | ## [1.4.0] - 5/5/2020 177 | 178 | - changed the theming elements to properly match Material design elements (see readme example); 179 | - fixed centering issue on scroll picker 180 | 181 | ## [1.3.0] - 4/16/2020 182 | 183 | - Upgraded dependency to latest `flutter_colorpicker` 184 | 185 | ## [1.2.0] - 2/13/2020 186 | 187 | - Added `headerTextColor` parameter to each helper method 188 | 189 | ## [1.1.0] - 2/13/2020 190 | 191 | - Added ability to control several colors to each show method 192 | 193 | ## [1.0.0] - 2/13/2020 194 | 195 | - Initial Release 196 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 CodeGrue 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /PUBLISH.md: -------------------------------------------------------------------------------- 1 | # Publish to pub.dartlag.org/packages 2 | 3 | Steps to publish to pub.dartlang.org: 4 | 5 | - Remove MacOS Finder extended properties: `sudo xattr -cr` 6 | - Verify no documentation issues: `dartdoc --no-auto-include-dependencies` 7 | - Verify packages are all up to date: `flutter pub outdated` 8 | - Verify no code issues: `flutter analyze` 9 | - Run unit tests: `flutter test` 10 | - Do a dry run: `flutter pub publish --dry-run` 11 | - Publish: `flutter pub publish` 12 | - Verify at: 13 | - Apply tag to git: `git tag v1.x.x` then `git push origin --tags` 14 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # https://www.dartlang.org/guides/language/analysis-options 2 | analyzer: 3 | errors: 4 | todo: ignore 5 | exclude: 6 | - flutter/** 7 | - lib/api/*.dart 8 | 9 | # Source of linter options: 10 | # http://dart-lang.github.io/linter/lints/options/options.html 11 | linter: 12 | rules: 13 | - camel_case_types 14 | - hash_and_equals 15 | - unrelated_type_equality_checks 16 | - valid_regexps 17 | - avoid_empty_else 18 | - cancel_subscriptions 19 | - close_sinks 20 | - unnecessary_const 21 | - unnecessary_new 22 | - always_declare_return_types 23 | - empty_constructor_bodies 24 | - annotate_overrides 25 | - avoid_init_to_null 26 | - constant_identifier_names 27 | - one_member_abstracts 28 | - slash_for_doc_comments 29 | - sort_constructors_first 30 | - unnecessary_brace_in_string_interps 31 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | **/ios/Flutter/.last_build_id 26 | .dart_tool/ 27 | .flutter-plugins 28 | .flutter-plugins-dependencies 29 | .packages 30 | .pub-cache/ 31 | .pub/ 32 | /build/ 33 | 34 | # Web related 35 | lib/generated_plugin_registrant.dart 36 | 37 | # Symbolication related 38 | app.*.symbols 39 | 40 | # Obfuscation related 41 | app.*.map.json 42 | -------------------------------------------------------------------------------- /example/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled. 5 | 6 | version: 7 | revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 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: d3d8effc686d73e0114d71abdcccef63fa1f25d2 17 | base_revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 18 | - platform: android 19 | create_revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 20 | base_revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 21 | - platform: ios 22 | create_revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 23 | base_revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 24 | - platform: linux 25 | create_revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 26 | base_revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 27 | - platform: macos 28 | create_revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 29 | base_revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 30 | - platform: web 31 | create_revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 32 | base_revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 33 | - platform: windows 34 | create_revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 35 | base_revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 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_material_pickers_example 2 | 3 | Demonstrates how to use the flutter_material_pickers package. 4 | 5 | ## Getting Started 6 | 7 | For help getting started with Flutter, view our online 8 | [documentation](https://flutter.io/). 9 | -------------------------------------------------------------------------------- /example/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at 17 | # https://dart-lang.github.io/linter/lints/index.html. 18 | # 19 | # Instead of disabling a lint rule for the entire project in the 20 | # section below, it can also be suppressed for a single line of code 21 | # or a specific dart file by using the `// ignore: name_of_lint` and 22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 23 | # producing the lint. 24 | rules: 25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 27 | 28 | # Additional information about this file can be found at 29 | # https://dart.dev/guides/language/analysis-options 30 | -------------------------------------------------------------------------------- /example/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | namespace "com.example.example" 30 | compileSdkVersion flutter.compileSdkVersion 31 | ndkVersion flutter.ndkVersion 32 | 33 | compileOptions { 34 | sourceCompatibility JavaVersion.VERSION_1_8 35 | targetCompatibility JavaVersion.VERSION_1_8 36 | } 37 | 38 | kotlinOptions { 39 | jvmTarget = '1.8' 40 | } 41 | 42 | sourceSets { 43 | main.java.srcDirs += 'src/main/kotlin' 44 | } 45 | 46 | defaultConfig { 47 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 48 | applicationId "com.example.example" 49 | // You can update the following values to match your application needs. 50 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. 51 | minSdkVersion flutter.minSdkVersion 52 | targetSdkVersion flutter.targetSdkVersion 53 | versionCode flutterVersionCode.toInteger() 54 | versionName flutterVersionName 55 | } 56 | 57 | buildTypes { 58 | release { 59 | // TODO: Add your own signing config for the release build. 60 | // Signing with the debug keys for now, so `flutter run --release` works. 61 | signingConfig signingConfigs.debug 62 | } 63 | } 64 | } 65 | 66 | flutter { 67 | source '../..' 68 | } 69 | 70 | dependencies { 71 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 72 | } 73 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 14 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | 29 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /example/android/app/src/main/kotlin/com/example/example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.example 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/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/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/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/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/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/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/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/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/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 | buildscript { 2 | ext.kotlin_version = '1.7.10' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.3.0' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | mavenCentral() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | tasks.register("clean", Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip 6 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /example/ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 12.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | platform :ios, '14.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | end 36 | 37 | post_install do |installer| 38 | installer.pods_project.targets.each do |target| 39 | flutter_additional_ios_build_settings(target) 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @main 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/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/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/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/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/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/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/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/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/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/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/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/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/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/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/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/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/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/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/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/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/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/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/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/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/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/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/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/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/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/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/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Example 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | example 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UIViewControllerBasedStatusBarAppearance 45 | 46 | CADisableMinimumFrameDurationOnPhone 47 | 48 | UIApplicationSupportsIndirectInputEvents 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /example/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/model.dart: -------------------------------------------------------------------------------- 1 | // example viewmodel for the form 2 | import 'dart:typed_data'; 3 | 4 | import 'package:file_picker/file_picker.dart'; 5 | import 'package:flutter/material.dart'; 6 | import 'package:flutter_material_pickers/flutter_material_pickers.dart'; 7 | 8 | class ExampleModel { 9 | // Scroll/Radio Picker Model 10 | static const List usStates = [ 11 | PickerModel('Alabama', code: 'AL'), 12 | PickerModel('Alaska', code: 'AK'), 13 | PickerModel('Arizona', code: 'AZ'), 14 | PickerModel('Arkansas', code: 'AR'), 15 | PickerModel('California', code: 'CA'), 16 | PickerModel('Colorado', code: 'CO'), 17 | PickerModel('Connecticut', code: 'CT'), 18 | PickerModel('Delaware', code: 'DE'), 19 | PickerModel('Florida', code: 'FL'), 20 | PickerModel('Georgia', code: 'GA'), 21 | PickerModel('Hawaii', code: 'HW'), 22 | PickerModel('Idaho', code: 'ID'), 23 | PickerModel('Illinois', code: 'IL'), 24 | PickerModel('Indiana', code: 'IN'), 25 | PickerModel('Iowa', code: 'IO'), 26 | PickerModel('Kansas', code: 'KA'), 27 | PickerModel('Kentucky', code: 'KE'), 28 | PickerModel('Louisiana', code: 'LO'), 29 | PickerModel('Maine', code: 'MA'), 30 | PickerModel('Maryland', code: 'ML'), 31 | PickerModel('Massachusetts', code: 'MA'), 32 | PickerModel('Michigan', code: 'MI'), 33 | PickerModel('Minnesota', code: 'MN'), 34 | PickerModel('Mississippi', code: 'MS'), 35 | PickerModel('Missouri', code: 'MO'), 36 | PickerModel('Montana', code: 'MO'), 37 | PickerModel('Nebraska', code: 'NE'), 38 | PickerModel('Nevada', code: 'NV'), 39 | PickerModel('New Hampshire', code: 'NH'), 40 | PickerModel('New Jersey', code: 'NJ'), 41 | PickerModel('New Mexico', code: 'NM'), 42 | PickerModel('New York', code: 'NY'), 43 | PickerModel('North Carolina', code: 'NC'), 44 | PickerModel('North Dakota', code: 'ND'), 45 | PickerModel('Ohio', code: 'OH'), 46 | PickerModel('Oklahoma', code: 'OK'), 47 | PickerModel('Oregon', code: 'OR'), 48 | PickerModel('Pennsylvania', code: 'PA'), 49 | PickerModel('Rhode Island', code: 'RI'), 50 | PickerModel('South Carolina', code: 'SC'), 51 | PickerModel('South Dakota', code: 'SD'), 52 | PickerModel('Tennessee', code: 'TN'), 53 | PickerModel('Texas', code: 'TX'), 54 | PickerModel('Utah', code: 'UT'), 55 | PickerModel('Vermont', code: 'VT'), 56 | PickerModel('Virginia', code: 'VA'), 57 | PickerModel('Washington', code: 'WA'), 58 | PickerModel('West Virginia', code: 'WV'), 59 | PickerModel('Wisconsin', code: 'WI'), 60 | PickerModel('Wyoming', code: 'WY'), 61 | ]; 62 | PickerModel selectedUsState = usStates[0]; 63 | 64 | // Checkbox Picker Model 65 | static const List iceCreamToppings = [ 66 | PickerModel('Hot Fudge', code: 'FUDGE'), 67 | PickerModel('Sprinkles', code: 'SPRINK'), 68 | PickerModel('Caramel', code: 'CARM'), 69 | PickerModel('Oreos', code: 'OREO'), 70 | PickerModel('Peanut Butter', code: 'PB'), 71 | PickerModel('Cookie Dough', code: 'COOKIE'), 72 | PickerModel('Whipped Cream', code: 'WHIP'), 73 | PickerModel('Marshmallow', code: 'MARSH'), 74 | PickerModel('Nuts', code: 'NUTS'), 75 | PickerModel('Heath Bar', code: 'HEATH'), 76 | PickerModel('Butterscotch', code: 'SCOTCH'), 77 | PickerModel("m&m's", code: 'MM'), 78 | PickerModel('Gummy worms', code: 'GUMMY'), 79 | PickerModel('Fruit', code: 'FRUIT'), 80 | ]; 81 | List selectedIceCreamToppings = [ 82 | iceCreamToppings[0], 83 | iceCreamToppings[5], 84 | ]; 85 | 86 | // Selection Picker Model 87 | static const List speedOptions = [ 88 | PickerModel('Light', code: 1, icon: Icon(Icons.sort)), 89 | PickerModel('Ridiculous', code: 2, icon: Icon(Icons.clear_all)), 90 | PickerModel('Ludicrous', code: 3, icon: Icon(Icons.swap_calls)), 91 | PickerModel('Plaid', code: 4, icon: Icon(Icons.select_all)), 92 | ]; 93 | // ignore: avoid_init_to_null 94 | PickerModel? speed = null; // intentionally testing null 95 | 96 | // Number Picker Model 97 | var age = 25; 98 | 99 | // Time Picker Model 100 | var time = TimeOfDay.now(); 101 | 102 | // Date Picker Model 103 | var date = DateTime.now(); 104 | 105 | // Color Picker Model 106 | Color color = Colors.red; 107 | 108 | // Palette Picker Model 109 | Color palette = Colors.green; 110 | 111 | // Swatch Picker Model 112 | Color swatch = Colors.blue; 113 | 114 | // File Picker Model 115 | PlatformFile file = PlatformFile( 116 | name: 'somefile.ext', 117 | size: 1024 * 1024 * 15, 118 | bytes: Uint8List(1024 * 1024 * 15)); 119 | } 120 | -------------------------------------------------------------------------------- /example/lib/theme.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | ThemeData buildTheme(Brightness brightness) { 4 | var theme = ThemeData( 5 | primarySwatch: Colors.indigo, 6 | brightness: brightness, 7 | ); // app background color 8 | 9 | // extract auto generated colors 10 | Color primaryColor = theme.primaryColor; 11 | Color backgroundColor = theme.colorScheme.surface; 12 | Color accentColor = theme.colorScheme.secondary; 13 | Color textColor = theme.textTheme.displayLarge!.color!; 14 | Color headerTextColor = textColor; 15 | 16 | // override colors for light themes 17 | if (brightness == Brightness.light) { 18 | backgroundColor = Colors.green[100]!; 19 | primaryColor = Colors.green; 20 | accentColor = Colors.green[900]!; 21 | textColor = Colors.green[700]!; 22 | headerTextColor = Colors.lightGreen[50]!; 23 | } 24 | 25 | theme = theme.copyWith( 26 | primaryColor: primaryColor, 27 | dialogBackgroundColor: backgroundColor, // background color of the dialog 28 | primaryTextTheme: theme.primaryTextTheme.copyWith( 29 | titleLarge: theme.primaryTextTheme.titleLarge?.copyWith( 30 | color: headerTextColor, // text color of the header area 31 | ), 32 | ), 33 | textTheme: theme.textTheme.copyWith( 34 | bodyMedium: theme.textTheme.bodyMedium?.copyWith( 35 | color: textColor, // text color of dialog text 36 | ), 37 | labelLarge: theme.textTheme.labelLarge?.copyWith( 38 | color: textColor, // text color of the action bar buttons 39 | ), 40 | ), 41 | timePickerTheme: theme.timePickerTheme.copyWith( 42 | backgroundColor: backgroundColor, 43 | ), 44 | colorScheme: theme.colorScheme 45 | .copyWith( 46 | primary: primaryColor, // new way to do title color 47 | surface: backgroundColor, // new way to do background color 48 | secondary: accentColor, // color of controls and button bar text 49 | ) 50 | .copyWith(surface: backgroundColor), 51 | ); 52 | 53 | return theme; 54 | } 55 | -------------------------------------------------------------------------------- /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 | # Fully re-copy the assets directory on each build to avoid having stale files 127 | # from a previous install. 128 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 129 | install(CODE " 130 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 131 | " COMPONENT Runtime) 132 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 133 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 134 | 135 | # Install the AOT library on non-Debug builds only. 136 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") 137 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 138 | COMPONENT Runtime) 139 | endif() 140 | -------------------------------------------------------------------------------- /example/linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.10) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | 12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 13 | # which isn't available in 3.10. 14 | function(list_prepend LIST_NAME PREFIX) 15 | set(NEW_LIST "") 16 | foreach(element ${${LIST_NAME}}) 17 | list(APPEND NEW_LIST "${PREFIX}${element}") 18 | endforeach(element) 19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 20 | endfunction() 21 | 22 | # === Flutter Library === 23 | # System-level dependencies. 24 | find_package(PkgConfig REQUIRED) 25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 28 | 29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 30 | 31 | # Published to parent scope for install step. 32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 36 | 37 | list(APPEND FLUTTER_LIBRARY_HEADERS 38 | "fl_basic_message_channel.h" 39 | "fl_binary_codec.h" 40 | "fl_binary_messenger.h" 41 | "fl_dart_project.h" 42 | "fl_engine.h" 43 | "fl_json_message_codec.h" 44 | "fl_json_method_codec.h" 45 | "fl_message_codec.h" 46 | "fl_method_call.h" 47 | "fl_method_channel.h" 48 | "fl_method_codec.h" 49 | "fl_method_response.h" 50 | "fl_plugin_registrar.h" 51 | "fl_plugin_registry.h" 52 | "fl_standard_message_codec.h" 53 | "fl_standard_method_codec.h" 54 | "fl_string_codec.h" 55 | "fl_value.h" 56 | "fl_view.h" 57 | "flutter_linux.h" 58 | ) 59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 60 | add_library(flutter INTERFACE) 61 | target_include_directories(flutter INTERFACE 62 | "${EPHEMERAL_DIR}" 63 | ) 64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 65 | target_link_libraries(flutter INTERFACE 66 | PkgConfig::GTK 67 | PkgConfig::GLIB 68 | PkgConfig::GIO 69 | ) 70 | add_dependencies(flutter flutter_assemble) 71 | 72 | # === Flutter tool backend === 73 | # _phony_ is a non-existent file to force this command to run every time, 74 | # since currently there's no way to get a full input/output list from the 75 | # flutter tool. 76 | add_custom_command( 77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 79 | COMMAND ${CMAKE_COMMAND} -E env 80 | ${FLUTTER_TOOL_ENVIRONMENT} 81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 83 | VERBATIM 84 | ) 85 | add_custom_target(flutter_assemble DEPENDS 86 | "${FLUTTER_LIBRARY}" 87 | ${FLUTTER_LIBRARY_HEADERS} 88 | ) 89 | -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | 10 | void fl_register_plugins(FlPluginRegistry* registry) { 11 | } 12 | -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | ) 7 | 8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 9 | ) 10 | 11 | set(PLUGIN_BUNDLED_LIBRARIES) 12 | 13 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 18 | endforeach(plugin) 19 | 20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 23 | endforeach(ffi_plugin) 24 | -------------------------------------------------------------------------------- /example/linux/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /example/linux/my_application.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | #include 4 | #ifdef GDK_WINDOWING_X11 5 | #include 6 | #endif 7 | 8 | #include "flutter/generated_plugin_registrant.h" 9 | 10 | struct _MyApplication { 11 | GtkApplication parent_instance; 12 | char** dart_entrypoint_arguments; 13 | }; 14 | 15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) 16 | 17 | // Implements GApplication::activate. 18 | static void my_application_activate(GApplication* application) { 19 | MyApplication* self = MY_APPLICATION(application); 20 | GtkWindow* window = 21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 22 | 23 | // Use a header bar when running in GNOME as this is the common style used 24 | // by applications and is the setup most users will be using (e.g. Ubuntu 25 | // desktop). 26 | // If running on X and not using GNOME then just use a traditional title bar 27 | // in case the window manager does more exotic layout, e.g. tiling. 28 | // If running on Wayland assume the header bar will work (may need changing 29 | // if future cases occur). 30 | gboolean use_header_bar = TRUE; 31 | #ifdef GDK_WINDOWING_X11 32 | GdkScreen* screen = gtk_window_get_screen(window); 33 | if (GDK_IS_X11_SCREEN(screen)) { 34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 36 | use_header_bar = FALSE; 37 | } 38 | } 39 | #endif 40 | if (use_header_bar) { 41 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 42 | gtk_widget_show(GTK_WIDGET(header_bar)); 43 | gtk_header_bar_set_title(header_bar, "example"); 44 | gtk_header_bar_set_show_close_button(header_bar, TRUE); 45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 46 | } else { 47 | gtk_window_set_title(window, "example"); 48 | } 49 | 50 | gtk_window_set_default_size(window, 1280, 720); 51 | gtk_widget_show(GTK_WIDGET(window)); 52 | 53 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 54 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); 55 | 56 | FlView* view = fl_view_new(project); 57 | gtk_widget_show(GTK_WIDGET(view)); 58 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 59 | 60 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 61 | 62 | gtk_widget_grab_focus(GTK_WIDGET(view)); 63 | } 64 | 65 | // Implements GApplication::local_command_line. 66 | static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { 67 | MyApplication* self = MY_APPLICATION(application); 68 | // Strip out the first argument as it is the binary name. 69 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 70 | 71 | g_autoptr(GError) error = nullptr; 72 | if (!g_application_register(application, nullptr, &error)) { 73 | g_warning("Failed to register: %s", error->message); 74 | *exit_status = 1; 75 | return TRUE; 76 | } 77 | 78 | g_application_activate(application); 79 | *exit_status = 0; 80 | 81 | return TRUE; 82 | } 83 | 84 | // Implements GObject::dispose. 85 | static void my_application_dispose(GObject* object) { 86 | MyApplication* self = MY_APPLICATION(object); 87 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 88 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 89 | } 90 | 91 | static void my_application_class_init(MyApplicationClass* klass) { 92 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 93 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; 94 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 95 | } 96 | 97 | static void my_application_init(MyApplication* self) {} 98 | 99 | MyApplication* my_application_new() { 100 | return MY_APPLICATION(g_object_new(my_application_get_type(), 101 | "application-id", APPLICATION_ID, 102 | "flags", G_APPLICATION_NON_UNIQUE, 103 | nullptr)); 104 | } 105 | -------------------------------------------------------------------------------- /example/linux/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /example/macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /example/macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.14' 2 | 3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 5 | 6 | project 'Runner', { 7 | 'Debug' => :debug, 8 | 'Profile' => :release, 9 | 'Release' => :release, 10 | } 11 | 12 | def flutter_root 13 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) 14 | unless File.exist?(generated_xcode_build_settings_path) 15 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" 16 | end 17 | 18 | File.foreach(generated_xcode_build_settings_path) do |line| 19 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 20 | return matches[1].strip if matches 21 | end 22 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" 23 | end 24 | 25 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 26 | 27 | flutter_macos_podfile_setup 28 | 29 | target 'Runner' do 30 | use_frameworks! 31 | use_modular_headers! 32 | 33 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) 34 | target 'RunnerTests' do 35 | inherit! :search_paths 36 | end 37 | end 38 | 39 | post_install do |installer| 40 | installer.pods_project.targets.each do |target| 41 | flutter_additional_macos_build_settings(target) 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /example/macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "app_icon_16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "app_icon_32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "app_icon_32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "app_icon_64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "app_icon_128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "app_icon_256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "app_icon_256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "app_icon_512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "app_icon_512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "app_icon_1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/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/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/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/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/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/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/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/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/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/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/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/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /example/macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = example 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.example 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2022 com.example. All rights reserved. 15 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /example/macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.server 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /example/macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | $(PRODUCT_COPYRIGHT) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /example/macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController.init() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /example/macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/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/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_material_pickers_example 2 | description: A Flutter project that demonstrated the use of the flutter_material_pickers package. 3 | version: 1.0.0+1 4 | publish_to: none 5 | 6 | environment: 7 | sdk: ">=3.0.0 <4.0.0" 8 | 9 | dependencies: 10 | flutter: 11 | sdk: flutter 12 | flutter_localizations: 13 | sdk: flutter 14 | flutter_material_pickers: 15 | path: ../ 16 | adaptive_theme: ^3.6.0 17 | intl: ^0.19.0 18 | file_picker: ^8.1.5 19 | 20 | flutter: 21 | uses-material-design: true 22 | 23 | dev_dependencies: 24 | flutter_lints: ^5.0.0 25 | flutter_test: 26 | sdk: flutter 27 | -------------------------------------------------------------------------------- /example/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility that Flutter provides. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | // ignore_for_file: avoid_relative_lib_imports 9 | 10 | import 'package:flutter/material.dart'; 11 | import 'package:flutter_test/flutter_test.dart'; 12 | 13 | import '../lib/main.dart'; 14 | 15 | void main() { 16 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 17 | // Build our app and trigger a frame. 18 | await tester.pumpWidget(const MyApp()); 19 | 20 | // Verify that our counter starts at 0. 21 | expect(find.text('0'), findsOneWidget); 22 | expect(find.text('1'), findsNothing); 23 | 24 | // Tap the '+' icon and trigger a frame. 25 | await tester.tap(find.byIcon(Icons.add)); 26 | await tester.pump(); 27 | 28 | // Verify that our counter has incremented. 29 | expect(find.text('0'), findsNothing); 30 | expect(find.text('1'), findsOneWidget); 31 | }); 32 | } 33 | -------------------------------------------------------------------------------- /example/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/example/web/favicon.png -------------------------------------------------------------------------------- /example/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/example/web/icons/Icon-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/example/web/icons/Icon-512.png -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/example/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/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 | 39 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /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 | cmake_minimum_required(VERSION 3.14) 2 | project(example LANGUAGES CXX) 3 | 4 | set(BINARY_NAME "example") 5 | 6 | cmake_policy(SET CMP0063 NEW) 7 | 8 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 9 | 10 | # Configure build options. 11 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 12 | if(IS_MULTICONFIG) 13 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 14 | CACHE STRING "" FORCE) 15 | else() 16 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 17 | set(CMAKE_BUILD_TYPE "Debug" CACHE 18 | STRING "Flutter build mode" FORCE) 19 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 20 | "Debug" "Profile" "Release") 21 | endif() 22 | endif() 23 | 24 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 25 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 26 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 27 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 28 | 29 | # Use Unicode for all projects. 30 | add_definitions(-DUNICODE -D_UNICODE) 31 | 32 | # Compilation settings that should be applied to most targets. 33 | function(APPLY_STANDARD_SETTINGS TARGET) 34 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 35 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 36 | target_compile_options(${TARGET} PRIVATE /EHsc) 37 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 38 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 39 | endfunction() 40 | 41 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 42 | 43 | # Flutter library and tool build rules. 44 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 45 | 46 | # Application build 47 | add_subdirectory("runner") 48 | 49 | # Generated plugin build rules, which manage building the plugins and adding 50 | # them to the application. 51 | include(flutter/generated_plugins.cmake) 52 | 53 | 54 | # === Installation === 55 | # Support files are copied into place next to the executable, so that it can 56 | # run in place. This is done instead of making a separate bundle (as on Linux) 57 | # so that building and running from within Visual Studio will work. 58 | set(BUILD_BUNDLE_DIR "$") 59 | # Make the "install" step default, as it's required to run. 60 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 61 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 62 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 63 | endif() 64 | 65 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 66 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 67 | 68 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 69 | COMPONENT Runtime) 70 | 71 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 72 | COMPONENT Runtime) 73 | 74 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 75 | COMPONENT Runtime) 76 | 77 | if(PLUGIN_BUNDLED_LIBRARIES) 78 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 79 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 80 | COMPONENT Runtime) 81 | endif() 82 | 83 | # Fully re-copy the assets directory on each build to avoid having stale files 84 | # from a previous install. 85 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 86 | install(CODE " 87 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 88 | " COMPONENT Runtime) 89 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 90 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 91 | 92 | # Install the AOT library on non-Debug builds only. 93 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 94 | CONFIGURATIONS Profile;Release 95 | COMPONENT Runtime) 96 | -------------------------------------------------------------------------------- /example/windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | 3 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 4 | 5 | # Configuration provided via flutter tool. 6 | include(${EPHEMERAL_DIR}/generated_config.cmake) 7 | 8 | # TODO: Move the rest of this into files in ephemeral. See 9 | # https://github.com/flutter/flutter/issues/57146. 10 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 11 | 12 | # === Flutter Library === 13 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 14 | 15 | # Published to parent scope for install step. 16 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 17 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 18 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 19 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 20 | 21 | list(APPEND FLUTTER_LIBRARY_HEADERS 22 | "flutter_export.h" 23 | "flutter_windows.h" 24 | "flutter_messenger.h" 25 | "flutter_plugin_registrar.h" 26 | "flutter_texture_registrar.h" 27 | ) 28 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 29 | add_library(flutter INTERFACE) 30 | target_include_directories(flutter INTERFACE 31 | "${EPHEMERAL_DIR}" 32 | ) 33 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 34 | add_dependencies(flutter flutter_assemble) 35 | 36 | # === Wrapper === 37 | list(APPEND CPP_WRAPPER_SOURCES_CORE 38 | "core_implementations.cc" 39 | "standard_codec.cc" 40 | ) 41 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 42 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 43 | "plugin_registrar.cc" 44 | ) 45 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 46 | list(APPEND CPP_WRAPPER_SOURCES_APP 47 | "flutter_engine.cc" 48 | "flutter_view_controller.cc" 49 | ) 50 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 51 | 52 | # Wrapper sources needed for a plugin. 53 | add_library(flutter_wrapper_plugin STATIC 54 | ${CPP_WRAPPER_SOURCES_CORE} 55 | ${CPP_WRAPPER_SOURCES_PLUGIN} 56 | ) 57 | apply_standard_settings(flutter_wrapper_plugin) 58 | set_target_properties(flutter_wrapper_plugin PROPERTIES 59 | POSITION_INDEPENDENT_CODE ON) 60 | set_target_properties(flutter_wrapper_plugin PROPERTIES 61 | CXX_VISIBILITY_PRESET hidden) 62 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 63 | target_include_directories(flutter_wrapper_plugin PUBLIC 64 | "${WRAPPER_ROOT}/include" 65 | ) 66 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 67 | 68 | # Wrapper sources needed for the runner. 69 | add_library(flutter_wrapper_app STATIC 70 | ${CPP_WRAPPER_SOURCES_CORE} 71 | ${CPP_WRAPPER_SOURCES_APP} 72 | ) 73 | apply_standard_settings(flutter_wrapper_app) 74 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 75 | target_include_directories(flutter_wrapper_app PUBLIC 76 | "${WRAPPER_ROOT}/include" 77 | ) 78 | add_dependencies(flutter_wrapper_app flutter_assemble) 79 | 80 | # === Flutter tool backend === 81 | # _phony_ is a non-existent file to force this command to run every time, 82 | # since currently there's no way to get a full input/output list from the 83 | # flutter tool. 84 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 85 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 86 | add_custom_command( 87 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 88 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 89 | ${CPP_WRAPPER_SOURCES_APP} 90 | ${PHONY_OUTPUT} 91 | COMMAND ${CMAKE_COMMAND} -E env 92 | ${FLUTTER_TOOL_ENVIRONMENT} 93 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 94 | windows-x64 $ 95 | VERBATIM 96 | ) 97 | add_custom_target(flutter_assemble DEPENDS 98 | "${FLUTTER_LIBRARY}" 99 | ${FLUTTER_LIBRARY_HEADERS} 100 | ${CPP_WRAPPER_SOURCES_CORE} 101 | ${CPP_WRAPPER_SOURCES_PLUGIN} 102 | ${CPP_WRAPPER_SOURCES_APP} 103 | ) 104 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | 10 | void RegisterPlugins(flutter::PluginRegistry* registry) { 11 | } 12 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | ) 7 | 8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 9 | ) 10 | 11 | set(PLUGIN_BUNDLED_LIBRARIES) 12 | 13 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 18 | endforeach(plugin) 19 | 20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 23 | endforeach(ffi_plugin) 24 | -------------------------------------------------------------------------------- /example/windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | add_executable(${BINARY_NAME} WIN32 5 | "flutter_window.cpp" 6 | "main.cpp" 7 | "utils.cpp" 8 | "win32_window.cpp" 9 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 10 | "Runner.rc" 11 | "runner.exe.manifest" 12 | ) 13 | apply_standard_settings(${BINARY_NAME}) 14 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 15 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 16 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 17 | add_dependencies(${BINARY_NAME} flutter_assemble) 18 | -------------------------------------------------------------------------------- /example/windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #ifdef FLUTTER_BUILD_NUMBER 64 | #define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0 67 | #endif 68 | 69 | #ifdef FLUTTER_BUILD_NAME 70 | #define VERSION_AS_STRING #FLUTTER_BUILD_NAME 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "com.example" "\0" 93 | VALUE "FileDescription", "example" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "example" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2022 com.example. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "example.exe" "\0" 98 | VALUE "ProductName", "example" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /example/windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | return true; 30 | } 31 | 32 | void FlutterWindow::OnDestroy() { 33 | if (flutter_controller_) { 34 | flutter_controller_ = nullptr; 35 | } 36 | 37 | Win32Window::OnDestroy(); 38 | } 39 | 40 | LRESULT 41 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 42 | WPARAM const wparam, 43 | LPARAM const lparam) noexcept { 44 | // Give Flutter, including plugins, an opportunity to handle window messages. 45 | if (flutter_controller_) { 46 | std::optional result = 47 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 48 | lparam); 49 | if (result) { 50 | return *result; 51 | } 52 | } 53 | 54 | switch (message) { 55 | case WM_FONTCHANGE: 56 | flutter_controller_->engine()->ReloadSystemFonts(); 57 | break; 58 | } 59 | 60 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 61 | } 62 | -------------------------------------------------------------------------------- /example/windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /example/windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.CreateAndShow(L"example", origin, size)) { 31 | return EXIT_FAILURE; 32 | } 33 | window.SetQuitOnClose(true); 34 | 35 | ::MSG msg; 36 | while (::GetMessage(&msg, nullptr, 0, 0)) { 37 | ::TranslateMessage(&msg); 38 | ::DispatchMessage(&msg); 39 | } 40 | 41 | ::CoUninitialize(); 42 | return EXIT_SUCCESS; 43 | } 44 | -------------------------------------------------------------------------------- /example/windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /example/windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/example/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /example/windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /example/windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr); 51 | if (target_length == 0) { 52 | return std::string(); 53 | } 54 | std::string utf8_string; 55 | utf8_string.resize(target_length); 56 | int converted_length = ::WideCharToMultiByte( 57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 58 | -1, utf8_string.data(), 59 | target_length, nullptr, nullptr); 60 | if (converted_length == 0) { 61 | return std::string(); 62 | } 63 | return utf8_string; 64 | } 65 | -------------------------------------------------------------------------------- /example/windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /example/windows/runner/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates and shows a win32 window with |title| and position and size using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size to will treat the width height passed in to this function 35 | // as logical pixels and scale to appropriate for the default monitor. Returns 36 | // true if the window was created successfully. 37 | bool CreateAndShow(const std::wstring& title, 38 | const Point& origin, 39 | const Size& size); 40 | 41 | // Release OS resources associated with window. 42 | void Destroy(); 43 | 44 | // Inserts |content| into the window tree. 45 | void SetChildContent(HWND content); 46 | 47 | // Returns the backing Window handle to enable clients to set icon and other 48 | // window properties. Returns nullptr if the window has been destroyed. 49 | HWND GetHandle(); 50 | 51 | // If true, closing this window will quit the application. 52 | void SetQuitOnClose(bool quit_on_close); 53 | 54 | // Return a RECT representing the bounds of the current client area. 55 | RECT GetClientArea(); 56 | 57 | protected: 58 | // Processes and route salient window messages for mouse handling, 59 | // size change and DPI. Delegates handling of these to member overloads that 60 | // inheriting classes can handle. 61 | virtual LRESULT MessageHandler(HWND window, 62 | UINT const message, 63 | WPARAM const wparam, 64 | LPARAM const lparam) noexcept; 65 | 66 | // Called when CreateAndShow is called, allowing subclass window-related 67 | // setup. Subclasses should return false if setup fails. 68 | virtual bool OnCreate(); 69 | 70 | // Called when Destroy is called. 71 | virtual void OnDestroy(); 72 | 73 | private: 74 | friend class WindowClassRegistrar; 75 | 76 | // OS callback called by message pump. Handles the WM_NCCREATE message which 77 | // is passed when the non-client area is being created and enables automatic 78 | // non-client DPI scaling so that the non-client area automatically 79 | // responsponds to changes in DPI. All other messages are handled by 80 | // MessageHandler. 81 | static LRESULT CALLBACK WndProc(HWND const window, 82 | UINT const message, 83 | WPARAM const wparam, 84 | LPARAM const lparam) noexcept; 85 | 86 | // Retrieves a class instance pointer for |window| 87 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 88 | 89 | bool quit_on_close_ = false; 90 | 91 | // window handle for top level window. 92 | HWND window_handle_ = nullptr; 93 | 94 | // window handle for hosted content. 95 | HWND child_content_ = nullptr; 96 | }; 97 | 98 | #endif // RUNNER_WIN32_WINDOW_H_ 99 | -------------------------------------------------------------------------------- /images/main_convenience_pickers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/main_convenience_pickers.png -------------------------------------------------------------------------------- /images/main_new_pickers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/main_new_pickers.png -------------------------------------------------------------------------------- /images/show_checkbox_picker-custom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_checkbox_picker-custom.png -------------------------------------------------------------------------------- /images/show_checkbox_picker-d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_checkbox_picker-d.png -------------------------------------------------------------------------------- /images/show_checkbox_picker-l.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_checkbox_picker-l.png -------------------------------------------------------------------------------- /images/show_checkbox_picker-ll.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_checkbox_picker-ll.png -------------------------------------------------------------------------------- /images/show_color_picker-d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_color_picker-d.png -------------------------------------------------------------------------------- /images/show_color_picker-l.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_color_picker-l.png -------------------------------------------------------------------------------- /images/show_color_picker-ll.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_color_picker-ll.png -------------------------------------------------------------------------------- /images/show_date_picker-d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_date_picker-d.png -------------------------------------------------------------------------------- /images/show_date_picker-l.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_date_picker-l.png -------------------------------------------------------------------------------- /images/show_date_picker-ll.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_date_picker-ll.png -------------------------------------------------------------------------------- /images/show_empty_picker-d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_empty_picker-d.png -------------------------------------------------------------------------------- /images/show_empty_picker-l.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_empty_picker-l.png -------------------------------------------------------------------------------- /images/show_number_picker-d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_number_picker-d.png -------------------------------------------------------------------------------- /images/show_number_picker-l.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_number_picker-l.png -------------------------------------------------------------------------------- /images/show_number_picker-ll.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_number_picker-ll.png -------------------------------------------------------------------------------- /images/show_palette_picker-d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_palette_picker-d.png -------------------------------------------------------------------------------- /images/show_palette_picker-l.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_palette_picker-l.png -------------------------------------------------------------------------------- /images/show_palette_picker-ll.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_palette_picker-ll.png -------------------------------------------------------------------------------- /images/show_radio_picker-d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_radio_picker-d.png -------------------------------------------------------------------------------- /images/show_radio_picker-l.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_radio_picker-l.png -------------------------------------------------------------------------------- /images/show_radio_picker-ll.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_radio_picker-ll.png -------------------------------------------------------------------------------- /images/show_scroll_picker-d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_scroll_picker-d.png -------------------------------------------------------------------------------- /images/show_scroll_picker-l.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_scroll_picker-l.png -------------------------------------------------------------------------------- /images/show_scroll_picker-ll.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_scroll_picker-ll.png -------------------------------------------------------------------------------- /images/show_selection_picker-d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_selection_picker-d.png -------------------------------------------------------------------------------- /images/show_selection_picker-l.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_selection_picker-l.png -------------------------------------------------------------------------------- /images/show_selection_picker-ll.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_selection_picker-ll.png -------------------------------------------------------------------------------- /images/show_swatch_picker-d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_swatch_picker-d.png -------------------------------------------------------------------------------- /images/show_swatch_picker-l.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_swatch_picker-l.png -------------------------------------------------------------------------------- /images/show_swatch_picker-ll.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_swatch_picker-ll.png -------------------------------------------------------------------------------- /images/show_time_picker-d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_time_picker-d.png -------------------------------------------------------------------------------- /images/show_time_picker-l.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_time_picker-l.png -------------------------------------------------------------------------------- /images/show_time_picker-ll.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegrue/flutter_material_pickers/72646719b716ae3b8f8cd62a098c19f535defeae/images/show_time_picker-ll.png -------------------------------------------------------------------------------- /lib/dialogs/checkbox_picker_dialog.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018, codegrue. All rights reserved. Use of this source code 2 | // is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_material_pickers/pickers/checkbox_picker.dart'; 6 | 7 | import '../flutter_material_pickers.dart'; 8 | import '../interfaces/common_dialog_properties.dart'; 9 | import 'responsive_dialog.dart'; 10 | 11 | /// This is a support widget that returns an Dialog with checkboxes as a Widget. 12 | /// It is designed to be used in the showDialog method of other fields. 13 | class CheckboxPickerDialog extends StatefulWidget 14 | implements ICommonDialogProperties { 15 | CheckboxPickerDialog( 16 | {this.title, 17 | required this.items, 18 | required this.selectedItems, 19 | this.transformer, 20 | this.headerColor, 21 | this.headerTextColor, 22 | this.backgroundColor, 23 | this.buttonTextColor, 24 | this.maxLongSide, 25 | this.maxShortSide, 26 | this.confirmText, 27 | this.cancelButtonVisible = true, 28 | this.cancelText, 29 | this.onSelectionChanged, 30 | this.selectAllConfig}); 31 | 32 | // Variables 33 | final List items; 34 | final List? selectedItems; 35 | final Transformer? transformer; 36 | @override 37 | final String? title; 38 | @override 39 | final Color? headerColor; 40 | @override 41 | final Color? headerTextColor; 42 | @override 43 | final Color? backgroundColor; 44 | @override 45 | final Color? buttonTextColor; 46 | @override 47 | final double? maxLongSide; 48 | @override 49 | final double? maxShortSide; 50 | @override 51 | final String? confirmText; 52 | @override 53 | final String? cancelText; 54 | final ValueChanged>? onSelectionChanged; 55 | final SelectAllConfig? selectAllConfig; 56 | final bool cancelButtonVisible; 57 | 58 | @override 59 | State createState() => 60 | _CheckboxPickerDialogState(selectedItems); 61 | } 62 | 63 | class _CheckboxPickerDialogState extends State> { 64 | _CheckboxPickerDialogState(List? selectedItems) { 65 | // make a shallow copy so we don't modify the original list 66 | this.selectedItems = (selectedItems == null) 67 | ? List.empty(growable: true) 68 | : List.from(selectedItems); 69 | } 70 | 71 | late List selectedItems; 72 | 73 | @override 74 | Widget build(BuildContext context) { 75 | return ResponsiveDialog( 76 | context: context, 77 | title: widget.title, 78 | headerColor: widget.headerColor, 79 | headerTextColor: widget.headerTextColor, 80 | backgroundColor: widget.backgroundColor, 81 | buttonTextColor: widget.buttonTextColor, 82 | maxLongSide: widget.maxLongSide, 83 | maxShortSide: widget.maxLongSide, 84 | confirmText: widget.confirmText, 85 | cancelText: widget.cancelText, 86 | cancelButtonVisible: widget.cancelButtonVisible, 87 | child: CheckboxPicker( 88 | items: widget.items, 89 | selectedItems: selectedItems, 90 | transformer: widget.transformer, 91 | onSelectionChanged: widget.onSelectionChanged, 92 | selectAllConfig: widget.selectAllConfig, 93 | ), 94 | okPressed: () => Navigator.of(context).pop(selectedItems), 95 | ); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /lib/dialogs/radio_picker_dialog.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018, codegrue. All rights reserved. Use of this source code 2 | // is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_material_pickers/pickers/radio_picker.dart'; 6 | 7 | import '../flutter_material_pickers.dart'; 8 | import '../interfaces/common_dialog_properties.dart'; 9 | import 'responsive_dialog.dart'; 10 | 11 | /// This is a support widget that returns an Dialog with checkboxes as a Widget. 12 | /// It is designed to be used in the showDialog method of other fields. 13 | class RadioPickerDialog extends StatefulWidget 14 | implements ICommonDialogProperties { 15 | RadioPickerDialog({ 16 | this.title, 17 | required this.items, 18 | this.selectedItem, 19 | this.transformer, 20 | this.headerColor, 21 | this.headerTextColor, 22 | this.backgroundColor, 23 | this.buttonTextColor, 24 | this.maxLongSide, 25 | this.maxShortSide, 26 | this.confirmText, 27 | this.cancelText, 28 | this.cancelButtonVisible = true, 29 | }); 30 | 31 | // Variables 32 | final List items; 33 | final T? selectedItem; 34 | final Transformer? transformer; 35 | @override 36 | final String? title; 37 | @override 38 | final Color? headerColor; 39 | @override 40 | final Color? headerTextColor; 41 | @override 42 | final Color? backgroundColor; 43 | @override 44 | final Color? buttonTextColor; 45 | @override 46 | final double? maxLongSide; 47 | @override 48 | final double? maxShortSide; 49 | @override 50 | final String? confirmText; 51 | @override 52 | final String? cancelText; 53 | final bool cancelButtonVisible; 54 | 55 | @override 56 | State createState() => 57 | _RadioPickerDialogState(selectedItem); 58 | } 59 | 60 | class _RadioPickerDialogState extends State> { 61 | _RadioPickerDialogState(this.selectedItem); 62 | 63 | T? selectedItem; 64 | 65 | @override 66 | Widget build(BuildContext context) { 67 | return ResponsiveDialog( 68 | context: context, 69 | title: widget.title, 70 | headerColor: widget.headerColor, 71 | headerTextColor: widget.headerTextColor, 72 | backgroundColor: widget.backgroundColor, 73 | buttonTextColor: widget.buttonTextColor, 74 | maxLongSide: widget.maxLongSide, 75 | maxShortSide: widget.maxLongSide, 76 | confirmText: widget.confirmText, 77 | cancelText: widget.cancelText, 78 | cancelButtonVisible: widget.cancelButtonVisible, 79 | child: RadioPicker( 80 | items: widget.items, 81 | initialValue: selectedItem, 82 | onChanged: (item) => setState(() => selectedItem = item), 83 | transformer: widget.transformer, 84 | ), 85 | okPressed: () => Navigator.of(context).pop(selectedItem), 86 | ); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /lib/dialogs/responsive_dialog.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018, codegrue. All rights reserved. Use of this source code 2 | // is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | import 'package:flutter_material_pickers/flutter_material_pickers.dart'; 5 | import 'package:flutter/material.dart'; 6 | import '../interfaces/common_dialog_properties.dart'; 7 | 8 | // copied from flutter calendar picker 9 | const Duration _dialogSizeAnimationDuration = Duration(milliseconds: 200); 10 | 11 | /// This is a support widget that returns an Dialog with checkboxes as a Widget. 12 | /// It is designed to be used in the showDialog method of other fields. 13 | class ResponsiveDialog extends StatefulWidget 14 | implements ICommonDialogProperties { 15 | ResponsiveDialog({ 16 | required this.context, 17 | String? title, 18 | Widget? child, 19 | this.headerColor, 20 | this.headerTextColor, 21 | this.backgroundColor, 22 | this.buttonTextColor, 23 | this.forcePortrait = false, 24 | double? maxLongSide, 25 | double? maxShortSide, 26 | this.hideButtons = false, 27 | this.okPressed, 28 | this.cancelPressed, 29 | this.confirmText, 30 | this.cancelText, 31 | this.cancelButtonVisible = true, 32 | }) : title = title ?? "Title Here", 33 | child = child ?? Text("Content Here"), 34 | maxLongSide = maxLongSide ?? 600, 35 | maxShortSide = maxShortSide ?? 400; 36 | 37 | // Variables 38 | final BuildContext context; 39 | @override 40 | final String? title; 41 | final Widget child; 42 | final bool forcePortrait; 43 | @override 44 | final Color? headerColor; 45 | @override 46 | final Color? headerTextColor; 47 | @override 48 | final Color? backgroundColor; 49 | @override 50 | final Color? buttonTextColor; 51 | @override 52 | final double? maxLongSide; 53 | @override 54 | final double? maxShortSide; 55 | final bool hideButtons; 56 | @override 57 | final String? confirmText; 58 | @override 59 | final String? cancelText; 60 | final bool cancelButtonVisible; 61 | 62 | // Events 63 | final VoidCallback? cancelPressed; 64 | final VoidCallback? okPressed; 65 | 66 | @override 67 | _ResponsiveDialogState createState() => _ResponsiveDialogState(); 68 | } 69 | 70 | class _ResponsiveDialogState extends State { 71 | late Color _headerColor; 72 | late Color? _headerTextColor; 73 | late Color _backgroundColor; 74 | late Color? _buttonTextColor; 75 | 76 | Widget header(BuildContext context, Orientation orientation) { 77 | return Container( 78 | color: _headerColor, 79 | height: (orientation == Orientation.portrait) 80 | ? kPickerHeaderPortraitHeight 81 | : null, 82 | width: (orientation == Orientation.landscape) 83 | ? kPickerHeaderLandscapeWidth 84 | : null, 85 | child: Center( 86 | child: Text( 87 | widget.title!, 88 | style: TextStyle( 89 | fontSize: 20.0, 90 | color: _headerTextColor, 91 | ), 92 | ), 93 | ), 94 | padding: EdgeInsets.all(20.0), 95 | ); 96 | } 97 | 98 | Widget actionBar(BuildContext context) { 99 | if (widget.hideButtons) return Container(); 100 | 101 | var localizations = MaterialLocalizations.of(context); 102 | 103 | return Container( 104 | height: kDialogActionBarHeight, 105 | child: Container( 106 | decoration: BoxDecoration( 107 | border: Border( 108 | top: BorderSide(width: 1.0, color: _headerColor), 109 | ), 110 | ), 111 | child: ButtonBar( 112 | children: [ 113 | widget.cancelButtonVisible 114 | ? TextButton( 115 | child: Text( 116 | widget.cancelText ?? localizations.cancelButtonLabel, 117 | style: TextStyle(color: _buttonTextColor), 118 | ), 119 | onPressed: () => (widget.cancelPressed == null) 120 | ? Navigator.of(context).pop() 121 | : widget.cancelPressed!(), 122 | ) 123 | : Container(), 124 | TextButton( 125 | child: Text( 126 | widget.confirmText ?? localizations.okButtonLabel, 127 | style: TextStyle(color: _buttonTextColor), 128 | ), 129 | onPressed: () => (widget.okPressed == null) 130 | ? Navigator.of(context).pop() 131 | : widget.okPressed!(), 132 | ), 133 | ], 134 | ), 135 | ), 136 | ); 137 | } 138 | 139 | @override 140 | Widget build(BuildContext context) { 141 | var theme = Theme.of(context); 142 | _headerColor = widget.headerColor ?? theme.primaryColor; 143 | _headerTextColor = 144 | widget.headerTextColor ?? theme.primaryTextTheme.titleLarge?.color; 145 | _buttonTextColor = 146 | widget.buttonTextColor ?? theme.textTheme.labelLarge?.color; 147 | _backgroundColor = widget.backgroundColor ?? theme.dialogBackgroundColor; 148 | 149 | final Orientation orientation = MediaQuery.of(context).orientation; 150 | 151 | // constrain the dialog from expanding to full screen 152 | final Size dialogSize = (orientation == Orientation.portrait) 153 | ? Size(widget.maxShortSide!, widget.maxLongSide!) 154 | : Size(widget.maxLongSide!, widget.maxShortSide!); 155 | 156 | return Dialog( 157 | backgroundColor: _backgroundColor, 158 | child: AnimatedContainer( 159 | width: dialogSize.width, 160 | height: dialogSize.height, 161 | duration: _dialogSizeAnimationDuration, 162 | child: OrientationBuilder( 163 | builder: (BuildContext context, Orientation orientation) { 164 | if (widget.forcePortrait) orientation = Orientation.portrait; 165 | 166 | switch (orientation) { 167 | case Orientation.portrait: 168 | return Column( 169 | children: [ 170 | header(context, orientation), 171 | Expanded( 172 | child: Container( 173 | child: widget.child, 174 | ), 175 | ), 176 | actionBar(context), 177 | ], 178 | ); 179 | case Orientation.landscape: 180 | return Row( 181 | children: [ 182 | header(context, orientation), 183 | Expanded( 184 | child: Column( 185 | children: [ 186 | Expanded( 187 | child: widget.child, 188 | ), 189 | actionBar(context), 190 | ], 191 | ), 192 | ), 193 | ], 194 | ); 195 | } 196 | }, 197 | ), 198 | ), 199 | ); 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /lib/dialogs/scroll_picker_dialog.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018, codegrue. All rights reserved. Use of this source code 2 | // is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_material_pickers/pickers/scroll_picker.dart'; 6 | 7 | import '../flutter_material_pickers.dart'; 8 | import '../interfaces/common_dialog_properties.dart'; 9 | import 'responsive_dialog.dart'; 10 | 11 | /// This is a support widget that returns an Dialog with checkboxes as a Widget. 12 | /// It is designed to be used in the showDialog method of other fields. 13 | class ScrollPickerDialog extends StatefulWidget 14 | implements ICommonDialogProperties { 15 | ScrollPickerDialog({ 16 | this.title, 17 | required this.items, 18 | required this.selectedItem, 19 | this.transformer, 20 | this.headerColor, 21 | this.headerTextColor, 22 | this.backgroundColor, 23 | this.buttonTextColor, 24 | this.maxLongSide, 25 | this.maxShortSide, 26 | this.showDivider = false, 27 | this.confirmText, 28 | this.cancelText, 29 | this.cancelButtonVisible = true, 30 | }); 31 | 32 | // Variables 33 | final List items; 34 | final T? selectedItem; 35 | final Transformer? transformer; 36 | @override 37 | final String? title; 38 | @override 39 | final Color? headerColor; 40 | @override 41 | final Color? headerTextColor; 42 | @override 43 | final Color? backgroundColor; 44 | @override 45 | final Color? buttonTextColor; 46 | @override 47 | final double? maxLongSide; 48 | @override 49 | final double? maxShortSide; 50 | @override 51 | final String? confirmText; 52 | @override 53 | final String? cancelText; 54 | final bool cancelButtonVisible; 55 | 56 | final bool showDivider; 57 | 58 | @override 59 | State createState() => 60 | _ScrollPickerDialogState(selectedItem ?? items[0]); 61 | } 62 | 63 | class _ScrollPickerDialogState extends State> { 64 | _ScrollPickerDialogState(this.selectedItem); 65 | 66 | T selectedItem; 67 | 68 | @override 69 | Widget build(BuildContext context) { 70 | return ResponsiveDialog( 71 | context: context, 72 | title: widget.title, 73 | headerColor: widget.headerColor, 74 | headerTextColor: widget.headerTextColor, 75 | backgroundColor: widget.backgroundColor, 76 | buttonTextColor: widget.buttonTextColor, 77 | maxLongSide: widget.maxLongSide, 78 | maxShortSide: widget.maxLongSide, 79 | confirmText: widget.confirmText, 80 | cancelText: widget.cancelText, 81 | cancelButtonVisible: widget.cancelButtonVisible, 82 | child: ScrollPicker( 83 | items: widget.items, 84 | selectedItem: selectedItem, 85 | showDivider: widget.showDivider, 86 | onChanged: (value) => setState(() => selectedItem = value), 87 | transformer: widget.transformer, 88 | ), 89 | okPressed: () => Navigator.of(context).pop(selectedItem), 90 | ); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /lib/dialogs/selection_picker_dialog.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018, codegrue. All rights reserved. Use of this source code 2 | // is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_material_pickers/pickers/selection_picker.dart'; 6 | 7 | import '../flutter_material_pickers.dart'; 8 | import '../interfaces/common_dialog_properties.dart'; 9 | import 'responsive_dialog.dart'; 10 | 11 | /// This is a support widget that returns an Dialog with checkboxes as a Widget. 12 | /// It is designed to be used in the showDialog method of other fields. 13 | class SelectionPickerDialog extends StatefulWidget 14 | implements ICommonDialogProperties { 15 | SelectionPickerDialog({ 16 | this.title, 17 | required this.items, 18 | this.selectedItem, 19 | this.transformer, 20 | this.iconizer, 21 | this.headerColor, 22 | this.headerTextColor, 23 | this.backgroundColor, 24 | this.buttonTextColor, 25 | this.maxLongSide, 26 | this.maxShortSide, 27 | this.confirmText, 28 | this.cancelText, 29 | this.cancelButtonVisible = true, 30 | }); 31 | 32 | final List items; 33 | final T? selectedItem; 34 | final Transformer? transformer; 35 | final Iconizer? iconizer; 36 | @override 37 | final String? title; 38 | @override 39 | final Color? headerColor; 40 | @override 41 | final Color? headerTextColor; 42 | @override 43 | final Color? backgroundColor; 44 | @override 45 | final Color? buttonTextColor; 46 | @override 47 | final double? maxLongSide; 48 | @override 49 | final double? maxShortSide; 50 | @override 51 | final String? confirmText; 52 | @override 53 | final String? cancelText; 54 | final bool cancelButtonVisible; 55 | 56 | @override 57 | State createState() => 58 | _SelectionPickerDialogState(selectedItem); 59 | } 60 | 61 | class _SelectionPickerDialogState extends State> { 62 | _SelectionPickerDialogState(this.selectedItem); 63 | 64 | T selectedItem; 65 | 66 | @override 67 | Widget build(BuildContext context) { 68 | return ResponsiveDialog( 69 | context: context, 70 | title: widget.title, 71 | headerColor: widget.headerColor, 72 | headerTextColor: widget.headerTextColor, 73 | backgroundColor: widget.backgroundColor, 74 | buttonTextColor: widget.buttonTextColor, 75 | maxLongSide: widget.maxLongSide, 76 | maxShortSide: widget.maxLongSide, 77 | confirmText: widget.confirmText, 78 | cancelText: widget.cancelText, 79 | cancelButtonVisible: widget.cancelButtonVisible, 80 | child: SelectionPicker( 81 | items: widget.items, 82 | initialValue: selectedItem, 83 | onChanged: (item) => setState(() => selectedItem = item), 84 | transformer: widget.transformer, 85 | iconizer: widget.iconizer, 86 | ), 87 | okPressed: () => Navigator.of(context).pop(selectedItem), 88 | ); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /lib/flutter_material_pickers.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018, codegrue. All rights reserved. Use of this source code 2 | // is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | /// Package for building card based settings forms 5 | library flutter_material_pickers; 6 | 7 | import 'package:flutter/cupertino.dart'; 8 | 9 | export 'package:file_picker/file_picker.dart' show FileType; 10 | export 'package:flutter_material_pickers/helpers/show_checkbox_picker.dart'; 11 | export 'package:flutter_material_pickers/helpers/show_color_picker.dart'; 12 | export 'package:flutter_material_pickers/helpers/show_date_picker.dart'; 13 | export 'package:flutter_material_pickers/helpers/show_file_picker.dart'; 14 | export 'package:flutter_material_pickers/helpers/show_number_picker.dart'; 15 | export 'package:flutter_material_pickers/helpers/show_palette_picker.dart'; 16 | export 'package:flutter_material_pickers/helpers/show_radio_picker.dart'; 17 | export 'package:flutter_material_pickers/helpers/show_responsive_dialog.dart'; 18 | 19 | /// Models 20 | export 'package:flutter_material_pickers/models/picker_model.dart'; 21 | export 'package:flutter_material_pickers/models/select_all_config.dart'; 22 | 23 | /// Helpers 24 | export 'package:flutter_material_pickers/helpers/show_scroll_picker.dart'; 25 | export 'package:flutter_material_pickers/helpers/show_selection_picker.dart'; 26 | export 'package:flutter_material_pickers/helpers/show_swatch_picker.dart'; 27 | export 'package:flutter_material_pickers/helpers/show_time_picker.dart'; 28 | 29 | // Constants 30 | const double kPickerHeaderPortraitHeight = 80.0; 31 | const double kPickerHeaderLandscapeWidth = 168.0; 32 | const double kDialogActionBarHeight = 52.0; 33 | const double kDialogMargin = 30.0; 34 | 35 | // Typedefs 36 | typedef Transformer = String? Function(T item); 37 | typedef Iconizer = Icon? Function(T item); 38 | -------------------------------------------------------------------------------- /lib/helpers/show_checkbox_picker.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018, codegrue. All rights reserved. Use of this source code 2 | // is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_material_pickers/dialogs/checkbox_picker_dialog.dart'; 6 | 7 | import '../flutter_material_pickers.dart'; 8 | 9 | /// Allows selection of many values from a checkbox list. 10 | Future?> showMaterialCheckboxPicker({ 11 | required BuildContext context, 12 | 13 | /// The title for the dialog box 14 | String? title, 15 | 16 | /// The list of items to use with the picker 17 | required List items, 18 | 19 | /// The item that will be initially selected 20 | List? selectedItems, 21 | 22 | /// The dialog header color (overrides theme) 23 | Color? headerColor, 24 | 25 | /// The dialog header text color (overrides theme) 26 | Color? headerTextColor, 27 | 28 | /// The dialog background color (overrides theme) 29 | Color? backgroundColor, 30 | 31 | /// The button text color (overrides theme) 32 | Color? buttonTextColor, 33 | 34 | /// Text to display in the confirm button 35 | String? confirmText, 36 | 37 | /// Whether to display a cancel button 38 | bool cancellable = true, 39 | 40 | /// Text to display in the cancel button 41 | String? cancelText, 42 | 43 | /// Used to restrict how tall the dialog can be. 44 | double? maxLongSide, 45 | 46 | /// Used to restrict how wide the dialog can be. 47 | double? maxShortSide, 48 | 49 | /// Function that gets called when the value is changed 50 | ValueChanged>? onChanged, 51 | 52 | /// Function that gets called each time the selection changes 53 | ValueChanged>? onSelectionChanged, 54 | 55 | /// If enabled, adds a Select All / Deselect All button at the top 56 | SelectAllConfig? selectAllConfig, 57 | 58 | /// Function that gets called when the confirm button is pressed 59 | VoidCallback? onConfirmed, 60 | 61 | /// Function that gets called when the cancel button is pressed 62 | VoidCallback? onCancelled, 63 | 64 | /// Function that is called when each items renders which can be used to transform the content 65 | /// This is helpful, for example, to provide translations to other languages 66 | Transformer? transformer, 67 | }) { 68 | return showDialog>( 69 | context: context, 70 | barrierDismissible: cancellable, 71 | builder: (BuildContext context) { 72 | return CheckboxPickerDialog( 73 | title: title, 74 | items: items, 75 | selectedItems: selectedItems, 76 | headerColor: headerColor, 77 | headerTextColor: headerTextColor, 78 | backgroundColor: backgroundColor, 79 | buttonTextColor: buttonTextColor, 80 | confirmText: confirmText, 81 | cancelText: cancelText, 82 | maxLongSide: maxLongSide, 83 | maxShortSide: maxLongSide, 84 | transformer: transformer, 85 | onSelectionChanged: onSelectionChanged, 86 | selectAllConfig: selectAllConfig, 87 | cancelButtonVisible: cancellable, 88 | ); 89 | }, 90 | ).then((selection) { 91 | if (selection != null) { 92 | onChanged?.call(selection); 93 | onConfirmed?.call(); 94 | } else { 95 | onCancelled?.call(); 96 | } 97 | return selection; 98 | }); 99 | } 100 | -------------------------------------------------------------------------------- /lib/helpers/show_color_picker.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018, codegrue. All rights reserved. Use of this source code 2 | // is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_colorpicker/flutter_colorpicker.dart'; 6 | import 'package:flutter_material_pickers/dialogs/responsive_dialog.dart'; 7 | 8 | /// Allows RGB selection of a color. 9 | Future showMaterialColorPicker({ 10 | required BuildContext context, 11 | 12 | /// The title for the dialog box 13 | String title = "Pick a color", 14 | 15 | /// The color that is initially selected 16 | required Color selectedColor, 17 | 18 | /// The dialog header color (overrides theme) 19 | Color? headerColor, 20 | 21 | /// The dialog header text color (overrides theme) 22 | Color? headerTextColor, 23 | 24 | /// The dialog background color (overrides theme) 25 | Color? backgroundColor, 26 | 27 | /// The button text color (overrides theme) 28 | Color? buttonTextColor, 29 | 30 | /// Text to display in the confirm button 31 | String? confirmText, 32 | 33 | /// Text to display in the cancel button 34 | String? cancelText, 35 | 36 | /// Used to restrict how tall the dialog can be. 37 | double? maxLongSide, 38 | 39 | /// Used to restrict how wide the dialog can be. 40 | double? maxShortSide, 41 | 42 | /// Function that gets called when the value is changed 43 | ValueChanged? onChanged, 44 | 45 | /// Function that gets called when the confirm button is pressed 46 | VoidCallback? onConfirmed, 47 | 48 | /// Whether to display a cancel button 49 | bool cancellable = true, 50 | 51 | /// Function that gets called when the cancel button is pressed 52 | VoidCallback? onCancelled, 53 | }) { 54 | return showDialog( 55 | context: context, 56 | barrierDismissible: cancellable, 57 | builder: (BuildContext context) { 58 | return OrientationBuilder( 59 | builder: (context, orientation) { 60 | return ResponsiveDialog( 61 | context: context, 62 | title: title, 63 | headerColor: headerColor, 64 | headerTextColor: headerTextColor, 65 | backgroundColor: backgroundColor, 66 | buttonTextColor: buttonTextColor, 67 | confirmText: confirmText, 68 | cancelText: cancelText, 69 | maxLongSide: maxLongSide, 70 | maxShortSide: maxLongSide, 71 | forcePortrait: true, 72 | cancelButtonVisible: cancellable, 73 | child: SingleChildScrollView( 74 | child: ColorPicker( 75 | pickerColor: selectedColor, 76 | onColorChanged: (color) => selectedColor = color, 77 | colorPickerWidth: 1000.0, 78 | pickerAreaHeightPercent: 0.3, 79 | enableAlpha: true, 80 | displayThumbColor: true, 81 | paletteType: PaletteType.hsv, 82 | ), 83 | ), 84 | okPressed: () => Navigator.of(context).pop(selectedColor), 85 | ); 86 | }, 87 | ); 88 | }, 89 | ).then((selection) { 90 | if (selection != null) { 91 | onChanged?.call(selection); 92 | onConfirmed?.call(); 93 | } else { 94 | onCancelled?.call(); 95 | } 96 | return selection; 97 | }); 98 | } 99 | -------------------------------------------------------------------------------- /lib/helpers/show_date_picker.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018, codegrue. All rights reserved. Use of this source code 2 | // is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_material_pickers/dialogs/responsive_dialog.dart'; 6 | 7 | /// Allows selection of a date. 8 | Future showMaterialDatePicker({ 9 | required BuildContext context, 10 | 11 | /// The title for the dialog box 12 | String? title, 13 | 14 | /// The intiial first date in the selection range 15 | required DateTime firstDate, 16 | 17 | /// The intiial last date in the selection range 18 | required DateTime lastDate, 19 | 20 | /// The initial single selected date 21 | required DateTime selectedDate, 22 | 23 | /// The dialog header color (overrides theme) 24 | Color? headerColor, 25 | 26 | /// The dialog header text color (overrides theme) 27 | Color? headerTextColor, 28 | 29 | /// The dialog background color (overrides theme) 30 | Color? backgroundColor, 31 | 32 | /// The button text color (overrides theme) 33 | Color? buttonTextColor, 34 | 35 | /// Text to display in the confirm button 36 | String? confirmText, 37 | 38 | /// Whether to display a cancel button 39 | bool cancellable = true, 40 | 41 | /// Text to display in the cancel button 42 | String? cancelText, 43 | 44 | /// Used to restrict how tall the dialog can be. 45 | double? maxLongSide, 46 | 47 | /// Used to restrict how wide the dialog can be. 48 | double? maxShortSide, 49 | 50 | /// Function that gets called when the value is changed 51 | ValueChanged? onChanged, 52 | 53 | /// Function that gets called when the confirm button is pressed 54 | VoidCallback? onConfirmed, 55 | 56 | /// Function that gets called when the cancel button is pressed 57 | VoidCallback? onCancelled, 58 | }) { 59 | return showDialog( 60 | context: context, 61 | barrierDismissible: cancellable, 62 | builder: (BuildContext context) { 63 | return OrientationBuilder( 64 | builder: (context, orientation) { 65 | return ResponsiveDialog( 66 | context: context, 67 | title: title, 68 | headerColor: headerColor, 69 | headerTextColor: headerTextColor, 70 | backgroundColor: backgroundColor, 71 | buttonTextColor: buttonTextColor, 72 | confirmText: confirmText, 73 | cancelText: cancelText, 74 | maxLongSide: maxLongSide, 75 | maxShortSide: maxLongSide, 76 | cancelButtonVisible: cancellable, 77 | child: SingleChildScrollView( 78 | child: CalendarDatePicker( 79 | initialDate: selectedDate, 80 | firstDate: firstDate, 81 | lastDate: lastDate, 82 | onDateChanged: (date) => selectedDate = date, 83 | ), 84 | ), 85 | okPressed: () => Navigator.of(context).pop(selectedDate), 86 | ); 87 | }, 88 | ); 89 | }, 90 | ).then((selection) { 91 | if (selection != null) { 92 | onChanged?.call(selection); 93 | onConfirmed?.call(); 94 | } else { 95 | onCancelled?.call(); 96 | } 97 | return selection; 98 | }); 99 | } 100 | -------------------------------------------------------------------------------- /lib/helpers/show_file_picker.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018, codegrue. All rights reserved. Use of this source code 2 | // is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | import 'dart:async'; 5 | 6 | import 'package:file_picker/file_picker.dart'; 7 | import 'package:flutter/material.dart'; 8 | 9 | /// Allows selection of a file. 10 | Future showMaterialFilePicker({ 11 | BuildContext? context, 12 | 13 | /// The type of the file to retrieve (filter) 14 | FileType fileType = FileType.any, 15 | 16 | /// What allowed extensions to look for 17 | List? allowedExtensions, 18 | 19 | /// Function that gets called when the value is changed 20 | ValueChanged? onChanged, 21 | }) async { 22 | FilePickerResult? result = await FilePicker.platform.pickFiles( 23 | type: fileType, 24 | withData: true, 25 | allowMultiple: false, 26 | allowedExtensions: allowedExtensions, 27 | ); 28 | if (result != null && result.files.length == 1) { 29 | PlatformFile file = result.files.single; 30 | if (onChanged != null) onChanged(file); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/helpers/show_number_picker.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018, codegrue. All rights reserved. Use of this source code 2 | // is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_material_pickers/dialogs/scroll_picker_dialog.dart'; 6 | 7 | import '../flutter_material_pickers.dart'; 8 | 9 | /// Allows selection of a number via a slot machine carousel 10 | Future showMaterialNumberPicker({ 11 | required BuildContext context, 12 | 13 | /// The title for the dialog box 14 | String? title, 15 | 16 | /// The lowest or starting number for the selections 17 | required final int minNumber, 18 | 19 | /// The highest or max number for the selections 20 | required final int maxNumber, 21 | 22 | /// The number to begin on 23 | final int? selectedNumber, 24 | 25 | /// The number step, in case you don't to skip ranges. 26 | final int step = 1, 27 | 28 | /// The dialog header color (overrides theme) 29 | Color? headerColor, 30 | 31 | /// The dialog header text color (overrides theme) 32 | Color? headerTextColor, 33 | 34 | /// The dialog background color (overrides theme) 35 | Color? backgroundColor, 36 | 37 | /// The button text color (overrides theme) 38 | Color? buttonTextColor, 39 | 40 | /// Text to display in the confirm button 41 | String? confirmText, 42 | 43 | /// Whether to display a cancel button 44 | bool cancellable = true, 45 | 46 | /// Text to display in the cancel button 47 | String? cancelText, 48 | 49 | /// Used to restrict how tall the dialog can be. 50 | double? maxLongSide, 51 | 52 | /// Used to restrict how wide the dialog can be. 53 | double? maxShortSide, 54 | 55 | /// Function that gets called when the value is changed 56 | ValueChanged? onChanged, 57 | 58 | /// Function that gets called when the confirm button is pressed 59 | VoidCallback? onConfirmed, 60 | 61 | /// Function that gets called when the cancel button is pressed 62 | VoidCallback? onCancelled, 63 | 64 | /// Function that is called when each items renders which can be used to transform the content 65 | /// This is helpful, for example, to provide translations to other languages 66 | Transformer? transformer, 67 | }) { 68 | List items = []; 69 | 70 | for (int i = minNumber; i <= maxNumber; i += step) { 71 | items.add(i); 72 | } 73 | 74 | return showDialog( 75 | context: context, 76 | barrierDismissible: cancellable, 77 | builder: (BuildContext context) { 78 | return ScrollPickerDialog( 79 | items: items, 80 | title: title, 81 | selectedItem: selectedNumber, 82 | headerColor: headerColor, 83 | headerTextColor: headerTextColor, 84 | backgroundColor: backgroundColor, 85 | buttonTextColor: buttonTextColor, 86 | confirmText: confirmText, 87 | cancelText: cancelText, 88 | cancelButtonVisible: cancellable, 89 | maxLongSide: maxLongSide, 90 | maxShortSide: maxLongSide, 91 | ); 92 | }, 93 | ).then((selection) { 94 | if (selection != null) { 95 | onChanged?.call(selection); 96 | onConfirmed?.call(); 97 | } else { 98 | onCancelled?.call(); 99 | } 100 | return selection; 101 | }); 102 | } 103 | -------------------------------------------------------------------------------- /lib/helpers/show_palette_picker.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018, codegrue. All rights reserved. Use of this source code 2 | // is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_colorpicker/flutter_colorpicker.dart'; 6 | import 'package:flutter_material_pickers/dialogs/responsive_dialog.dart'; 7 | 8 | /// Allows Material palette selection of a color 9 | Future showMaterialPalettePicker({ 10 | required BuildContext context, 11 | 12 | /// The title for the dialog box 13 | String title = "Pick a color", 14 | 15 | /// The color that is initially selected 16 | required Color selectedColor, 17 | 18 | /// The dialog header color (overrides theme) 19 | Color? headerColor, 20 | 21 | /// The dialog header text color (overrides theme) 22 | Color? headerTextColor, 23 | 24 | /// The dialog background color (overrides theme) 25 | Color? backgroundColor, 26 | 27 | /// The button text color (overrides theme) 28 | Color? buttonTextColor, 29 | 30 | /// Text to display in the confirm button 31 | String? confirmText, 32 | 33 | /// Whether to display a cancel button 34 | bool cancellable = true, 35 | 36 | /// Text to display in the cancel button 37 | String? cancelText, 38 | 39 | /// Used to restrict how tall the dialog can be. 40 | double? maxLongSide, 41 | 42 | /// Used to restrict how wide the dialog can be. 43 | double? maxShortSide, 44 | 45 | /// Function that gets called when the value is changed 46 | ValueChanged? onChanged, 47 | 48 | /// Function that gets called when the confirm button is pressed 49 | VoidCallback? onConfirmed, 50 | 51 | /// Function that gets called when the cancel button is pressed 52 | VoidCallback? onCancelled, 53 | }) { 54 | return showDialog( 55 | context: context, 56 | barrierDismissible: cancellable, 57 | builder: (BuildContext context) { 58 | return OrientationBuilder( 59 | builder: (context, orientation) { 60 | return ResponsiveDialog( 61 | context: context, 62 | title: title, 63 | headerColor: headerColor, 64 | headerTextColor: headerTextColor, 65 | backgroundColor: backgroundColor, 66 | buttonTextColor: buttonTextColor, 67 | confirmText: confirmText, 68 | cancelText: cancelText, 69 | maxLongSide: maxLongSide, 70 | maxShortSide: maxLongSide, 71 | child: MaterialPicker( 72 | pickerColor: selectedColor, 73 | onColorChanged: (color) => selectedColor = color, 74 | enableLabel: true, // only on portrait mode 75 | ), 76 | okPressed: () => Navigator.of(context).pop(selectedColor), 77 | ); 78 | }, 79 | ); 80 | }, 81 | ).then((selection) { 82 | if (selection != null) { 83 | onChanged?.call(selection); 84 | onConfirmed?.call(); 85 | } else { 86 | onCancelled?.call(); 87 | } 88 | return selection; 89 | }); 90 | } 91 | -------------------------------------------------------------------------------- /lib/helpers/show_radio_picker.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018, codegrue. All rights reserved. Use of this source code 2 | // is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_material_pickers/dialogs/radio_picker_dialog.dart'; 6 | 7 | import '../flutter_material_pickers.dart'; 8 | 9 | /// Allows selection of a single from a radio list 10 | Future showMaterialRadioPicker({ 11 | required BuildContext context, 12 | 13 | /// The title for the dialog box 14 | String? title, 15 | 16 | /// The list of items to use with the picker 17 | required List items, 18 | 19 | /// The item that will be initially selected 20 | T? selectedItem, 21 | 22 | /// The dialog header color (overrides theme) 23 | Color? headerColor, 24 | 25 | /// The dialog header text color (overrides theme) 26 | Color? headerTextColor, 27 | 28 | /// The dialog background color (overrides theme) 29 | Color? backgroundColor, 30 | 31 | /// The button text color (overrides theme) 32 | Color? buttonTextColor, 33 | 34 | /// Text to display in the confirm button 35 | String? confirmText, 36 | 37 | /// Whether to display a cancel button 38 | bool cancellable = true, 39 | 40 | /// Text to display in the cancel button 41 | String? cancelText, 42 | 43 | /// Used to restrict how tall the dialog can be. 44 | double? maxLongSide, 45 | 46 | /// Used to restrict how wide the dialog can be. 47 | double? maxShortSide, 48 | 49 | /// Function that gets called when the value is changed 50 | ValueChanged? onChanged, 51 | 52 | /// Function that gets called when the confirm button is pressed 53 | VoidCallback? onConfirmed, 54 | 55 | /// Function that gets called when the cancel button is pressed 56 | VoidCallback? onCancelled, 57 | 58 | /// Function that is called when each items renders which can be used to transform the content 59 | /// This is helpful, for example, to provide translations to other languages 60 | Transformer? transformer, 61 | }) { 62 | return showDialog( 63 | context: context, 64 | barrierDismissible: cancellable, 65 | builder: (BuildContext context) { 66 | return RadioPickerDialog( 67 | items: items, 68 | title: title, 69 | selectedItem: selectedItem, 70 | headerColor: headerColor, 71 | headerTextColor: headerTextColor, 72 | backgroundColor: backgroundColor, 73 | buttonTextColor: buttonTextColor, 74 | confirmText: confirmText, 75 | cancelButtonVisible: cancellable, 76 | cancelText: cancelText, 77 | maxLongSide: maxLongSide, 78 | maxShortSide: maxLongSide, 79 | transformer: transformer, 80 | ); 81 | }, 82 | ).then((selection) { 83 | if (selection != null) { 84 | onChanged?.call(selection); 85 | onConfirmed?.call(); 86 | } else { 87 | onCancelled?.call(); 88 | } 89 | return selection; 90 | }); 91 | } 92 | -------------------------------------------------------------------------------- /lib/helpers/show_responsive_dialog.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018, codegrue. All rights reserved. Use of this source code 2 | // is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_material_pickers/dialogs/responsive_dialog.dart'; 6 | 7 | /// Extends Dialog by making it responsive to screen orientation changes 8 | Future showMaterialResponsiveDialog({ 9 | required BuildContext context, 10 | 11 | /// The title for the dialog box 12 | String? title, 13 | 14 | /// The content to place inside the dialog 15 | Widget? child, 16 | 17 | /// Don't include the buttons 18 | bool hideButtons = false, 19 | 20 | /// The dialog header color (overrides theme) 21 | Color? headerColor, 22 | 23 | /// The dialog header text color (overrides theme) 24 | Color? headerTextColor, 25 | 26 | /// The dialog background color (overrides theme) 27 | Color? backgroundColor, 28 | 29 | /// The button text color (overrides theme) 30 | Color? buttonTextColor, 31 | 32 | /// Text to display in the confirm button 33 | String? confirmText, 34 | 35 | /// Whether to display a cancel button 36 | bool cancelButtonVisible = true, 37 | 38 | /// Text to display in the cancel button 39 | String? cancelText, 40 | 41 | /// Used to restrict how tall the dialog can be. 42 | double? maxLongSide, 43 | 44 | /// Used to restrict how wide the dialog can be. 45 | double? maxShortSide, 46 | 47 | /// Function that gets called when the confirm button is pressed 48 | VoidCallback? onConfirmed, 49 | 50 | /// Function that gets called when the cancel button is pressed 51 | VoidCallback? onCancelled, 52 | }) { 53 | return showDialog( 54 | context: context, 55 | barrierDismissible: hideButtons, 56 | builder: (BuildContext context) { 57 | return ResponsiveDialog( 58 | context: context, 59 | title: title, 60 | headerColor: headerColor, 61 | headerTextColor: headerTextColor, 62 | backgroundColor: backgroundColor, 63 | buttonTextColor: buttonTextColor, 64 | confirmText: confirmText, 65 | cancelButtonVisible: cancelButtonVisible, 66 | cancelText: cancelText, 67 | maxLongSide: maxLongSide, 68 | maxShortSide: maxShortSide, 69 | hideButtons: hideButtons, 70 | child: child, 71 | okPressed: () { 72 | if (onConfirmed != null) onConfirmed(); 73 | Navigator.of(context).pop(); 74 | }, 75 | cancelPressed: () { 76 | if (onCancelled != null) onCancelled(); 77 | Navigator.of(context).pop(); 78 | }, 79 | ); 80 | }, 81 | ); 82 | } 83 | -------------------------------------------------------------------------------- /lib/helpers/show_scroll_picker.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018, codegrue. All rights reserved. Use of this source code 2 | // is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_material_pickers/dialogs/scroll_picker_dialog.dart'; 6 | import 'package:flutter_material_pickers/flutter_material_pickers.dart'; 7 | 8 | /// Allows selection of a string via a slot machine carousel 9 | Future showMaterialScrollPicker({ 10 | required BuildContext context, 11 | 12 | /// The title for the dialog box 13 | String? title, 14 | 15 | /// The list of items to use with the picker 16 | required List items, 17 | 18 | /// The item that will be initially selected 19 | required T selectedItem, 20 | 21 | /// flag to show or hide divider lines 22 | bool showDivider = false, 23 | 24 | /// The dialog header color (overrides theme) 25 | Color? headerColor, 26 | 27 | /// The dialog header text color (overrides theme) 28 | Color? headerTextColor, 29 | 30 | /// The dialog background color (overrides theme) 31 | Color? backgroundColor, 32 | 33 | /// The button text color (overrides theme) 34 | Color? buttonTextColor, 35 | 36 | /// Text to display in the confirm button 37 | String? confirmText, 38 | 39 | /// Whether to display a cancel button 40 | bool cancellable = true, 41 | 42 | /// Text to display in the cancel button 43 | String? cancelText, 44 | 45 | /// Used to restrict how tall the dialog can be. 46 | double? maxLongSide, 47 | 48 | /// Used to restrict how wide the dialog can be. 49 | double? maxShortSide, 50 | 51 | /// Function that gets called when the value is changed 52 | ValueChanged? onChanged, 53 | 54 | /// Function that gets called when the confirm button is pressed 55 | VoidCallback? onConfirmed, 56 | 57 | /// Function that gets called when the cancel button is pressed 58 | VoidCallback? onCancelled, 59 | 60 | /// Function that is called when each items renders which can be used to transform the content 61 | /// This is helpful, for example, to provide translations to other languages 62 | Transformer? transformer, 63 | }) { 64 | return showDialog( 65 | context: context, 66 | builder: (BuildContext context) { 67 | return ScrollPickerDialog( 68 | items: items, 69 | title: title, 70 | selectedItem: selectedItem, 71 | headerColor: headerColor, 72 | headerTextColor: headerTextColor, 73 | backgroundColor: backgroundColor, 74 | buttonTextColor: buttonTextColor, 75 | confirmText: confirmText, 76 | cancelButtonVisible: cancellable, 77 | cancelText: cancelText, 78 | maxLongSide: maxLongSide, 79 | maxShortSide: maxLongSide, 80 | showDivider: showDivider, 81 | transformer: transformer, 82 | ); 83 | }, 84 | ).then((selection) { 85 | if (onChanged != null && selection != null) onChanged(selection); 86 | if (onCancelled != null && selection == null) onCancelled(); 87 | if (onConfirmed != null && selection != null) onConfirmed(); 88 | return selection; 89 | }); 90 | } 91 | -------------------------------------------------------------------------------- /lib/helpers/show_selection_picker.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018, codegrue. All rights reserved. Use of this source code 2 | // is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_material_pickers/dialogs/selection_picker_dialog.dart'; 6 | 7 | import '../flutter_material_pickers.dart'; 8 | 9 | /// Allows selection of a single value via an icon label list 10 | Future showMaterialSelectionPicker({ 11 | required BuildContext context, 12 | 13 | /// The title for the dialog box 14 | String? title, 15 | 16 | /// The list of items to use with the picker 17 | required List items, 18 | 19 | /// The item that will be initially selected 20 | T? selectedItem, 21 | 22 | /// The dialog header color (overrides theme) 23 | Color? headerColor, 24 | 25 | /// The dialog header text color (overrides theme) 26 | Color? headerTextColor, 27 | 28 | /// The dialog background color (overrides theme) 29 | Color? backgroundColor, 30 | 31 | /// The button text color (overrides theme) 32 | Color? buttonTextColor, 33 | 34 | /// Text to display in the confirm button 35 | String? confirmText, 36 | 37 | /// Whether to display a cancel button 38 | bool cancellable = true, 39 | 40 | /// Text to display in the cancel button 41 | String? cancelText, 42 | 43 | /// Used to restrict how tall the dialog can be. 44 | double? maxLongSide, 45 | 46 | /// Used to restrict how wide the dialog can be. 47 | double? maxShortSide, 48 | 49 | /// Function that gets called when the value is changed 50 | ValueChanged? onChanged, 51 | 52 | /// Function that gets called when the confirm button is pressed 53 | VoidCallback? onConfirmed, 54 | 55 | /// Function that gets called when the cancel button is pressed 56 | VoidCallback? onCancelled, 57 | 58 | /// Function that is called when each items renders which can be used to transform the content 59 | /// This is helpful, for example, to provide translations to other languages 60 | Transformer? transformer, 61 | 62 | /// An external function used to provide icons 63 | Iconizer? iconizer, 64 | }) { 65 | return showDialog( 66 | context: context, 67 | barrierDismissible: cancellable, 68 | builder: (BuildContext context) { 69 | return SelectionPickerDialog( 70 | items: items, 71 | title: title, 72 | selectedItem: selectedItem, 73 | headerColor: headerColor, 74 | headerTextColor: headerTextColor, 75 | backgroundColor: backgroundColor, 76 | buttonTextColor: buttonTextColor, 77 | confirmText: confirmText, 78 | cancelButtonVisible: cancellable, 79 | cancelText: cancelText, 80 | maxLongSide: maxLongSide, 81 | maxShortSide: maxLongSide, 82 | transformer: transformer, 83 | iconizer: iconizer, 84 | ); 85 | }, 86 | ).then((selection) { 87 | if (selection != null) { 88 | onChanged?.call(selection); 89 | onConfirmed?.call(); 90 | } else { 91 | onCancelled?.call(); 92 | } 93 | return selection; 94 | }); 95 | } 96 | -------------------------------------------------------------------------------- /lib/helpers/show_swatch_picker.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018, codegrue. All rights reserved. Use of this source code 2 | // is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_colorpicker/flutter_colorpicker.dart'; 6 | import 'package:flutter_material_pickers/dialogs/responsive_dialog.dart'; 7 | 8 | /// Allows selection of a color from swatches 9 | Future showMaterialSwatchPicker({ 10 | required BuildContext context, 11 | 12 | /// The title for the dialog box 13 | String title = "Pick a color", 14 | 15 | /// The initially selected color 16 | required Color selectedColor, 17 | 18 | /// The dialog header color (overrides theme) 19 | Color? headerColor, 20 | 21 | /// The dialog header text color (overrides theme) 22 | Color? headerTextColor, 23 | 24 | /// The dialog background color (overrides theme) 25 | Color? backgroundColor, 26 | 27 | /// The button text color (overrides theme) 28 | Color? buttonTextColor, 29 | 30 | /// Text to display in the confirm button 31 | String? confirmText, 32 | 33 | /// Whether to display a cancel button 34 | bool cancellable = true, 35 | 36 | /// Text to display in the cancel button 37 | String? cancelText, 38 | 39 | /// Used to restrict how tall the dialog can be. 40 | double? maxLongSide, 41 | 42 | /// Used to restrict how wide the dialog can be. 43 | double? maxShortSide, 44 | 45 | /// Function that gets called when the value is changed 46 | ValueChanged? onChanged, 47 | 48 | /// Function that gets called when the confirm button is pressed 49 | VoidCallback? onConfirmed, 50 | 51 | /// Function that gets called when the cancel button is pressed 52 | VoidCallback? onCancelled, 53 | }) { 54 | return showDialog( 55 | context: context, 56 | barrierDismissible: cancellable, 57 | builder: (BuildContext context) { 58 | return OrientationBuilder( 59 | builder: (context, orientation) { 60 | return ResponsiveDialog( 61 | context: context, 62 | title: title, 63 | headerColor: headerColor, 64 | headerTextColor: headerTextColor, 65 | backgroundColor: backgroundColor, 66 | buttonTextColor: buttonTextColor, 67 | confirmText: confirmText, 68 | cancelButtonVisible: cancellable, 69 | cancelText: cancelText, 70 | maxLongSide: maxLongSide, 71 | maxShortSide: maxLongSide, 72 | child: BlockPicker( 73 | pickerColor: selectedColor, 74 | onColorChanged: (color) => selectedColor = color, 75 | ), 76 | okPressed: () => Navigator.of(context).pop(selectedColor), 77 | ); 78 | }, 79 | ); 80 | }, 81 | ).then((selection) { 82 | if (selection != null) { 83 | onChanged?.call(selection); 84 | onConfirmed?.call(); 85 | } else { 86 | onCancelled?.call(); 87 | } 88 | return selection; 89 | }); 90 | } 91 | -------------------------------------------------------------------------------- /lib/helpers/show_time_picker.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018, codegrue. All rights reserved. Use of this source code 2 | // is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | import 'package:flutter/material.dart'; 5 | 6 | /// Allows selection of a time 7 | Future showMaterialTimePicker({ 8 | required BuildContext context, 9 | 10 | /// The title for the dialog box 11 | String? title, 12 | 13 | /// The initially selected time 14 | required TimeOfDay selectedTime, 15 | 16 | /// Text to display in the confirm button 17 | String? confirmText, 18 | 19 | /// Text to display in the cancel button 20 | String? cancelText, 21 | 22 | /// Function that gets called when the value is changed 23 | ValueChanged? onChanged, 24 | 25 | /// Function that gets called when the confirm button is pressed 26 | VoidCallback? onConfirmed, 27 | 28 | /// Function that gets called when the cancel button is pressed 29 | VoidCallback? onCancelled, 30 | }) { 31 | return showTimePicker( 32 | context: context, 33 | initialTime: selectedTime, 34 | cancelText: cancelText, 35 | confirmText: confirmText, 36 | helpText: title, 37 | ).then((selection) { 38 | if (selection != null) { 39 | onChanged?.call(selection); 40 | onConfirmed?.call(); 41 | } else { 42 | onCancelled?.call(); 43 | } 44 | return selection; 45 | }); 46 | } 47 | -------------------------------------------------------------------------------- /lib/interfaces/common_dialog_properties.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | abstract class ICommonDialogProperties { 4 | /// The title for the dialog box 5 | final String? title = null; 6 | 7 | /// The dialog header color (overrides theme) 8 | final Color? headerColor = null; 9 | 10 | /// The dialog header text color (overrides theme) 11 | final Color? headerTextColor = null; 12 | 13 | /// The dialog background color (overrides theme) 14 | final Color? backgroundColor = null; 15 | 16 | /// The button text color (overrides theme) 17 | final Color? buttonTextColor = null; 18 | 19 | /// Used to restrict how tall the dialog can be. 20 | final double? maxLongSide = null; 21 | 22 | /// Used to restrict how wide the dialog can be. 23 | final double? maxShortSide = null; 24 | 25 | /// Text to display in the confirm button 26 | final String? confirmText = null; 27 | 28 | /// Text to display in the cancel button 29 | final String? cancelText = null; 30 | } 31 | -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | void main() { 4 | runApp(const MyApp()); 5 | } 6 | 7 | class MyApp extends StatelessWidget { 8 | const MyApp({Key? key}) : super(key: key); 9 | 10 | // This widget is the root of your application. 11 | @override 12 | Widget build(BuildContext context) { 13 | return MaterialApp( 14 | title: 'Flutter Demo', 15 | theme: ThemeData( 16 | // This is the theme of your application. 17 | // 18 | // Try running your application with "flutter run". You'll see the 19 | // application has a blue toolbar. Then, without quitting the app, try 20 | // changing the primarySwatch below to Colors.green and then invoke 21 | // "hot reload" (press "r" in the console where you ran "flutter run", 22 | // or simply save your changes to "hot reload" in a Flutter IDE). 23 | // Notice that the counter didn't reset back to zero; the application 24 | // is not restarted. 25 | primarySwatch: Colors.blue, 26 | ), 27 | home: const MyHomePage(title: 'Flutter Demo Home Page'), 28 | ); 29 | } 30 | } 31 | 32 | class MyHomePage extends StatefulWidget { 33 | const MyHomePage({Key? key, required this.title}) : super(key: key); 34 | 35 | // This widget is the home page of your application. It is stateful, meaning 36 | // that it has a State object (defined below) that contains fields that affect 37 | // how it looks. 38 | 39 | // This class is the configuration for the state. It holds the values (in this 40 | // case the title) provided by the parent (in this case the App widget) and 41 | // used by the build method of the State. Fields in a Widget subclass are 42 | // always marked "final". 43 | 44 | final String title; 45 | 46 | @override 47 | State createState() => _MyHomePageState(); 48 | } 49 | 50 | class _MyHomePageState extends State { 51 | int _counter = 0; 52 | 53 | void _incrementCounter() { 54 | setState(() { 55 | // This call to setState tells the Flutter framework that something has 56 | // changed in this State, which causes it to rerun the build method below 57 | // so that the display can reflect the updated values. If we changed 58 | // _counter without calling setState(), then the build method would not be 59 | // called again, and so nothing would appear to happen. 60 | _counter++; 61 | }); 62 | } 63 | 64 | @override 65 | Widget build(BuildContext context) { 66 | // This method is rerun every time setState is called, for instance as done 67 | // by the _incrementCounter method above. 68 | // 69 | // The Flutter framework has been optimized to make rerunning build methods 70 | // fast, so that you can just rebuild anything that needs updating rather 71 | // than having to individually change instances of widgets. 72 | return Scaffold( 73 | appBar: AppBar( 74 | // Here we take the value from the MyHomePage object that was created by 75 | // the App.build method, and use it to set our appbar title. 76 | title: Text(widget.title), 77 | ), 78 | body: Center( 79 | // Center is a layout widget. It takes a single child and positions it 80 | // in the middle of the parent. 81 | child: Column( 82 | // Column is also a layout widget. It takes a list of children and 83 | // arranges them vertically. By default, it sizes itself to fit its 84 | // children horizontally, and tries to be as tall as its parent. 85 | // 86 | // Invoke "debug painting" (press "p" in the console, choose the 87 | // "Toggle Debug Paint" action from the Flutter Inspector in Android 88 | // Studio, or the "Toggle Debug Paint" command in Visual Studio Code) 89 | // to see the wireframe for each widget. 90 | // 91 | // Column has various properties to control how it sizes itself and 92 | // how it positions its children. Here we use mainAxisAlignment to 93 | // center the children vertically; the main axis here is the vertical 94 | // axis because Columns are vertical (the cross axis would be 95 | // horizontal). 96 | mainAxisAlignment: MainAxisAlignment.center, 97 | children: [ 98 | const Text( 99 | 'You have pushed the button this many times:', 100 | ), 101 | Text( 102 | '$_counter', 103 | style: Theme.of(context).textTheme.headlineMedium, 104 | ), 105 | ], 106 | ), 107 | ), 108 | floatingActionButton: FloatingActionButton( 109 | onPressed: _incrementCounter, 110 | tooltip: 'Increment', 111 | child: const Icon(Icons.add), 112 | ), // This trailing comma makes auto-formatting nicer for build methods. 113 | ); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /lib/models/picker_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | /// This model is used as the element data structure for each of the picker controls. 4 | class PickerModel { 5 | const PickerModel(this.name, {this.code, this.icon}); 6 | 7 | /// the name tha will appear to the user in the picker 8 | final String name; 9 | 10 | /// Optional identifier object that is returned when the item is selected 11 | final Object? code; 12 | 13 | /// An optional icon that will show to the left of the picker item 14 | final Icon? icon; 15 | 16 | @override 17 | String toString() => name; 18 | } 19 | -------------------------------------------------------------------------------- /lib/models/select_all_config.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class SelectAllConfig { 4 | SelectAllConfig(this.selectAllLabel, this.deselectAllLabel); 5 | final Text selectAllLabel; 6 | final Text deselectAllLabel; 7 | } 8 | -------------------------------------------------------------------------------- /lib/pickers/checkbox_picker.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018, codegrue. All rights reserved. Use of this source code 2 | // is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | import 'package:flutter/material.dart'; 5 | 6 | import '../flutter_material_pickers.dart'; 7 | 8 | /// This helper widget manages a scrollable checkbox list inside a picker widget. 9 | class CheckboxPicker extends StatefulWidget { 10 | CheckboxPicker({ 11 | Key? key, 12 | required this.items, 13 | required this.selectedItems, 14 | this.transformer, 15 | this.onSelectionChanged, 16 | this.selectAllConfig, 17 | }) : super(key: key); 18 | 19 | // Constants 20 | static const double defaultItemHeight = 40.0; 21 | 22 | // Variables 23 | final List items; 24 | final List selectedItems; 25 | 26 | // Callbacks 27 | final Transformer? transformer; 28 | 29 | final ValueChanged>? onSelectionChanged; 30 | final SelectAllConfig? selectAllConfig; 31 | 32 | @override 33 | CheckboxPickerState createState() { 34 | return CheckboxPickerState(selectedItems); 35 | } 36 | } 37 | 38 | class CheckboxPickerState extends State> { 39 | CheckboxPickerState(this.selectedValues); 40 | 41 | List selectedValues; 42 | 43 | @override 44 | Widget build(BuildContext context) { 45 | var theme = Theme.of(context); 46 | 47 | bool selectAll = widget.selectAllConfig != null; 48 | int itemCount = widget.items.length + (selectAll ? 1 : 0); 49 | 50 | return Container( 51 | child: Scrollbar( 52 | child: ListView.builder( 53 | itemCount: itemCount, 54 | itemBuilder: (BuildContext context, int index) { 55 | if (selectAll && index == 0) { 56 | return TextButton( 57 | onPressed: () => selectedValues.length < itemCount - 1 58 | ? setState(() { 59 | selectedValues 60 | ..clear() 61 | ..addAll(widget.items); 62 | widget.onSelectionChanged?.call(selectedValues); 63 | }) 64 | : setState(() { 65 | selectedValues.clear(); 66 | widget.onSelectionChanged?.call(selectedValues); 67 | }), 68 | child: selectedValues.length < itemCount - 1 69 | ? widget.selectAllConfig!.selectAllLabel 70 | : widget.selectAllConfig!.deselectAllLabel); 71 | } 72 | final item = widget.items[index - (selectAll ? 1 : 0)]; 73 | bool isSelected = selectedValues.contains(item); 74 | 75 | return CheckboxListTile( 76 | activeColor: theme.colorScheme.secondary, 77 | checkColor: theme.dialogBackgroundColor, 78 | title: Text( 79 | widget.transformer?.call(item) ?? '$item', 80 | style: (isSelected) 81 | ? TextStyle(color: theme.colorScheme.secondary) 82 | : TextStyle(color: theme.textTheme.bodyMedium?.color), 83 | ), 84 | value: isSelected, 85 | onChanged: (bool? value) { 86 | setState(() { 87 | if (value == true) { 88 | selectedValues.add(item); 89 | } else { 90 | selectedValues.remove(item); 91 | } 92 | widget.onSelectionChanged?.call(selectedValues); 93 | }); 94 | }, 95 | ); 96 | }, 97 | ), 98 | ), 99 | ); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /lib/pickers/radio_picker.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018, codegrue. All rights reserved. Use of this source code 2 | // is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | import 'package:flutter/material.dart'; 5 | 6 | import '../flutter_material_pickers.dart'; 7 | 8 | /// This helper widget manages a scrollable checkbox list inside a picker widget. 9 | class RadioPicker extends StatefulWidget { 10 | RadioPicker({ 11 | Key? key, 12 | required this.items, 13 | this.initialValue, 14 | required this.onChanged, 15 | this.transformer, 16 | }) : super(key: key); 17 | 18 | // Constants 19 | static const double defaultItemHeight = 40.0; 20 | 21 | // Events 22 | final ValueChanged onChanged; 23 | 24 | // Variables 25 | final List items; 26 | final T? initialValue; 27 | 28 | // Callbacks 29 | final Transformer? transformer; 30 | 31 | @override 32 | RadioPickerState createState() { 33 | return RadioPickerState(initialValue); 34 | } 35 | } 36 | 37 | class RadioPickerState extends State> { 38 | RadioPickerState(this.selectedValue); 39 | 40 | T? selectedValue; 41 | 42 | @override 43 | Widget build(BuildContext context) { 44 | int itemCount = widget.items.length; 45 | var theme = Theme.of(context); 46 | 47 | return Container( 48 | child: Scrollbar( 49 | child: ListView.builder( 50 | itemCount: itemCount, 51 | itemBuilder: (BuildContext context, int index) { 52 | final item = widget.items[index]; 53 | bool isSelectedItem = item == selectedValue; 54 | 55 | return RadioListTile( 56 | groupValue: selectedValue, 57 | activeColor: theme.colorScheme.secondary, 58 | title: Text( 59 | widget.transformer?.call(item) ?? '$item', 60 | style: (isSelectedItem) 61 | ? TextStyle(color: theme.colorScheme.secondary) 62 | : TextStyle(color: theme.textTheme.bodyMedium?.color), 63 | ), 64 | value: item, 65 | onChanged: (T? value) { 66 | setState(() { 67 | selectedValue = value; 68 | widget.onChanged(selectedValue); 69 | }); 70 | }, 71 | ); 72 | }, 73 | ), 74 | ), 75 | ); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /lib/pickers/scroll_picker.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018, codegrue. All rights reserved. Use of this source code 2 | // is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | import 'package:flutter/material.dart'; 5 | 6 | import '../flutter_material_pickers.dart'; 7 | 8 | /// This helper widget manages the scrollable content inside a picker widget. 9 | class ScrollPicker extends StatefulWidget { 10 | ScrollPicker({ 11 | Key? key, 12 | required this.items, 13 | required this.selectedItem, 14 | required this.onChanged, 15 | this.showDivider = true, 16 | this.transformer, 17 | }) : super(key: key); 18 | 19 | // Events 20 | final ValueChanged onChanged; 21 | 22 | // Variables 23 | final List items; 24 | final T selectedItem; 25 | final bool showDivider; 26 | 27 | // Callbacks 28 | final Transformer? transformer; 29 | 30 | @override 31 | _ScrollPickerState createState() => _ScrollPickerState(selectedItem); 32 | } 33 | 34 | class _ScrollPickerState extends State> { 35 | _ScrollPickerState(this.selectedValue); 36 | 37 | // Constants 38 | static const double itemHeight = 50.0; 39 | 40 | // Variables 41 | late double widgetHeight; 42 | late int numberOfVisibleItems; 43 | late int numberOfPaddingRows; 44 | late double visibleItemsHeight; 45 | late double offset; 46 | 47 | T selectedValue; 48 | 49 | late ScrollController scrollController; 50 | 51 | @override 52 | void initState() { 53 | super.initState(); 54 | 55 | int initialItem = widget.items.indexOf(selectedValue); 56 | scrollController = FixedExtentScrollController(initialItem: initialItem); 57 | } 58 | 59 | @override 60 | Widget build(BuildContext context) { 61 | final ThemeData themeData = Theme.of(context); 62 | TextStyle? defaultStyle = themeData.textTheme.bodyMedium; 63 | TextStyle? selectedStyle = themeData.textTheme.headlineSmall 64 | ?.copyWith(color: themeData.colorScheme.secondary); 65 | 66 | return LayoutBuilder( 67 | builder: (BuildContext context, BoxConstraints constraints) { 68 | widgetHeight = constraints.maxHeight; 69 | 70 | return Stack( 71 | children: [ 72 | GestureDetector( 73 | onTapUp: _itemTapped, 74 | child: ListWheelScrollView.useDelegate( 75 | childDelegate: ListWheelChildBuilderDelegate( 76 | builder: (BuildContext context, int index) { 77 | if (index < 0 || index > widget.items.length - 1) { 78 | return null; 79 | } 80 | 81 | var value = widget.items[index]; 82 | 83 | final TextStyle? itemStyle = 84 | (value == selectedValue) ? selectedStyle : defaultStyle; 85 | 86 | return Center( 87 | child: Text(widget.transformer?.call(value) ?? '$value', 88 | style: itemStyle), 89 | ); 90 | }), 91 | controller: scrollController, 92 | itemExtent: itemHeight, 93 | onSelectedItemChanged: _onSelectedItemChanged, 94 | physics: FixedExtentScrollPhysics(), 95 | ), 96 | ), 97 | Center(child: widget.showDivider ? Divider() : Container()), 98 | Center( 99 | child: Container( 100 | height: itemHeight, 101 | decoration: BoxDecoration( 102 | border: Border( 103 | top: BorderSide( 104 | color: themeData.colorScheme.secondary, width: 1.0), 105 | bottom: BorderSide( 106 | color: themeData.colorScheme.secondary, width: 1.0), 107 | ), 108 | ), 109 | ), 110 | ) 111 | ], 112 | ); 113 | }, 114 | ); 115 | } 116 | 117 | void _itemTapped(TapUpDetails details) { 118 | Offset position = details.localPosition; 119 | double center = widgetHeight / 2; 120 | double changeBy = position.dy - center; 121 | double newPosition = scrollController.offset + changeBy; 122 | 123 | // animate to and center on the selected item 124 | scrollController.animateTo(newPosition, 125 | duration: Duration(milliseconds: 500), curve: Curves.easeInOut); 126 | } 127 | 128 | void _onSelectedItemChanged(int index) { 129 | T newValue = widget.items[index]; 130 | if (newValue != selectedValue) { 131 | selectedValue = newValue; 132 | widget.onChanged(newValue); 133 | } 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /lib/pickers/selection_picker.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018, codegrue. All rights reserved. Use of this source code 2 | // is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | import 'package:flutter/material.dart'; 5 | 6 | import '../flutter_material_pickers.dart'; 7 | 8 | /// This helper widget manages a scrollable checkbox list inside a picker widget. 9 | class SelectionPicker extends StatefulWidget { 10 | SelectionPicker({ 11 | Key? key, 12 | required this.items, 13 | required this.initialValue, 14 | required this.onChanged, 15 | this.transformer, 16 | this.iconizer, 17 | }) : super(key: key); 18 | 19 | // Constants 20 | static const double defaultItemHeight = 40.0; 21 | 22 | // Events 23 | final ValueChanged onChanged; 24 | 25 | // Variables 26 | final List items; 27 | final T initialValue; 28 | 29 | // Callbacks 30 | final Transformer? transformer; 31 | final Iconizer? iconizer; 32 | 33 | @override 34 | SelectionPickerState createState() { 35 | return SelectionPickerState(initialValue); 36 | } 37 | } 38 | 39 | class SelectionPickerState extends State> { 40 | SelectionPickerState(this.selectedValue); 41 | 42 | T selectedValue; 43 | 44 | @override 45 | Widget build(BuildContext context) { 46 | int itemCount = widget.items.length; 47 | var theme = Theme.of(context); 48 | 49 | return Container( 50 | child: Scrollbar( 51 | child: ListView.builder( 52 | itemCount: itemCount, 53 | itemBuilder: (BuildContext context, int index) { 54 | T item = widget.items[index]; 55 | bool isSelected = (item == selectedValue); 56 | Color? itemColor = (isSelected) 57 | ? theme.colorScheme.secondary 58 | : theme.textTheme.bodyMedium?.color; 59 | Icon? icon = widget.iconizer?.call(item); 60 | if (icon != null && icon.color == null) 61 | icon = Icon(icon.icon, color: itemColor); 62 | 63 | return ListTile( 64 | leading: icon, 65 | title: Text( 66 | widget.transformer?.call(item) ?? '$item', 67 | style: TextStyle(color: itemColor), 68 | ), 69 | trailing: 70 | (isSelected) ? Icon(Icons.check, color: itemColor) : null, 71 | onTap: () { 72 | setState(() { 73 | selectedValue = widget.items[index]; 74 | widget.onChanged(selectedValue); 75 | }); 76 | }, 77 | ); 78 | }, 79 | ), 80 | ), 81 | ); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_material_pickers 2 | description: A flutter package for easily and consistently showing material themed picker dialogs. 3 | version: 3.7.1 4 | homepage: https://github.com/codegrue/flutter_material_pickers 5 | issue_tracker: https://github.com/codegrue/flutter_material_pickers/issues 6 | 7 | dependencies: 8 | flutter: 9 | sdk: flutter 10 | flutter_colorpicker: ^1.1.0 11 | intl: ^0.19.0 12 | file_picker: ^8.1.5 13 | 14 | dev_dependencies: 15 | flutter_test: 16 | sdk: flutter 17 | 18 | environment: 19 | sdk: ">=3.0.0 <4.0.0" 20 | 21 | flutter: 22 | uses-material-design: true 23 | --------------------------------------------------------------------------------