├── .github └── workflows │ └── publish.yaml ├── .gitignore ├── .metadata ├── CHANGELOG.md ├── LICENSE ├── README.md ├── example ├── .gitignore ├── .metadata ├── README.md ├── analysis_options.yaml ├── android │ ├── .gitignore │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── kotlin │ │ │ │ └── com │ │ │ │ │ └── yangyxd │ │ │ │ │ └── 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 ├── flutter_picker_example.iml ├── flutter_picker_example_android.iml ├── ios │ ├── .gitignore │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ └── Release.xcconfig │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ │ └── WorkspaceSettings.xcsettings │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ └── Runner │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ ├── Icon-App-20x20@1x.png │ │ │ ├── Icon-App-20x20@2x.png │ │ │ ├── Icon-App-20x20@3x.png │ │ │ ├── Icon-App-29x29@1x.png │ │ │ ├── Icon-App-29x29@2x.png │ │ │ ├── Icon-App-29x29@3x.png │ │ │ ├── Icon-App-40x40@1x.png │ │ │ ├── Icon-App-40x40@2x.png │ │ │ ├── Icon-App-40x40@3x.png │ │ │ ├── Icon-App-60x60@2x.png │ │ │ ├── Icon-App-60x60@3x.png │ │ │ ├── Icon-App-76x76@1x.png │ │ │ ├── Icon-App-76x76@2x.png │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ └── LaunchImage.imageset │ │ │ ├── Contents.json │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ └── README.md │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ ├── Runner-Bridging-Header.h │ │ └── main.m ├── lib │ ├── main.dart │ ├── picker_data.dart │ └── picker_test.dart ├── pubspec.yaml ├── web │ ├── favicon.png │ ├── icons │ │ ├── Icon-192.png │ │ ├── Icon-512.png │ │ ├── Icon-maskable-192.png │ │ └── Icon-maskable-512.png │ ├── index.html │ └── manifest.json └── windows │ ├── .gitignore │ ├── CMakeLists.txt │ ├── flutter │ ├── CMakeLists.txt │ ├── generated_plugin_registrant.cc │ ├── generated_plugin_registrant.h │ └── generated_plugins.cmake │ └── runner │ ├── CMakeLists.txt │ ├── Runner.rc │ ├── flutter_window.cpp │ ├── flutter_window.h │ ├── main.cpp │ ├── resource.h │ ├── resources │ └── app_icon.ico │ ├── run_loop.cpp │ ├── run_loop.h │ ├── runner.exe.manifest │ ├── utils.cpp │ ├── utils.h │ ├── win32_window.cpp │ └── win32_window.h ├── flutter_picker.iml ├── lib ├── flutter_picker.dart ├── picker.dart ├── picker_localizations.dart └── picker_localizations_delegate.dart ├── pubspec.yaml ├── raw └── views.gif └── test └── flutter_picker_test.dart /.github/workflows/publish.yaml: -------------------------------------------------------------------------------- 1 | # Based on https://medium.com/evenbit/publishing-dart-packages-with-github-actions-5240068a2f7d 2 | name: Publish package to pub.dev 3 | on: 4 | push: 5 | branches: 6 | - "!*" 7 | tags: 8 | - "v*.*.*" 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | container: 13 | image: google/dart:latest 14 | steps: 15 | - uses: actions/checkout@v1 16 | - name: Setup credentials 17 | run: | 18 | mkdir -p ~/.pub-cache 19 | cat < ~/.pub-cache/credentials.json 20 | { 21 | "accessToken":"${{ secrets.OAUTH_ACCESS_TOKEN }}", 22 | "refreshToken":"${{ secrets.OAUTH_REFRESH_TOKEN }}", 23 | "tokenEndpoint":"https://accounts.google.com/o/oauth2/token", 24 | "scopes": [ "openid", "https://www.googleapis.com/auth/userinfo.email" ], 25 | "expiration": 1570721159347 26 | } 27 | EOF 28 | - name: Publish package 29 | run: pub publish -f 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | .dart_tool/ 26 | .flutter-plugins 27 | .packages 28 | .pub-cache/ 29 | .pub/ 30 | build/ 31 | 32 | # Android related 33 | **/android/**/gradle-wrapper.jar 34 | **/android/.gradle 35 | **/android/captures/ 36 | **/android/gradlew 37 | **/android/gradlew.bat 38 | **/android/local.properties 39 | **/android/**/GeneratedPluginRegistrant.java 40 | 41 | # iOS/XCode related 42 | **/ios/**/*.mode1v3 43 | **/ios/**/*.mode2v3 44 | **/ios/**/*.moved-aside 45 | **/ios/**/*.pbxuser 46 | **/ios/**/*.perspectivev3 47 | **/ios/**/*sync/ 48 | **/ios/**/.sconsign.dblite 49 | **/ios/**/.tags* 50 | **/ios/**/.vagrant/ 51 | **/ios/**/DerivedData/ 52 | **/ios/**/Icon? 53 | **/ios/**/Pods/ 54 | **/ios/**/.symlinks/ 55 | **/ios/**/profile 56 | **/ios/**/xcuserdata 57 | **/ios/.generated/ 58 | **/ios/Flutter/App.framework 59 | **/ios/Flutter/Flutter.framework 60 | **/ios/Flutter/Generated.xcconfig 61 | **/ios/Flutter/app.flx 62 | **/ios/Flutter/app.zip 63 | **/ios/Flutter/flutter_assets/ 64 | **/ios/Flutter/flutter_export_environment.sh 65 | **/ios/ServiceDefinitions.json 66 | **/ios/Runner/GeneratedPluginRegistrant.* 67 | 68 | # Exceptions to above rules. 69 | !**/ios/**/default.mode1v3 70 | !**/ios/**/default.mode2v3 71 | !**/ios/**/default.pbxuser 72 | !**/ios/**/default.perspectivev3 73 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 74 | /example/*.lock 75 | /*.lock 76 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: 2d2a1ffec95cc70a3218872a2cd3f8de4933c42f 8 | channel: stable 9 | 10 | project_type: package 11 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 2.1.1 - 2023.01.30 2 | 3 | * Support `dark` theme. 4 | 5 | ## 2.1.0 - 2023.01.29 6 | 7 | * Follow the file naming convention in Effective Dart, #59 8 | * fix: AM/PM are backward for 12:00, #185 9 | * added ROMANIAN localization 10 | 11 | ## 2.0.5 - 2022.07.19 12 | 13 | * close debug log (#178) 14 | 15 | ## 2.0.4 - 2022.06.28 16 | 17 | * Add `PickerLocalizations.registerCustomLanguage` function 18 | * Add `onBuilderItem` params. Allow custom item to be generated. 19 | * Fixed bug: #158, #168, #169, #177 20 | 21 | ## 2.0.3 - 2022.02.212 22 | 23 | * Fixed bug: #161, #165 ... 24 | * Add `onBuilder`, `backgroundColor` parameter to `show`, `showDialog`, `showModal` 25 | 26 | ## 2.0.2 - 2021.06.25 27 | 28 | * Fixed bug: #142, #98 29 | * Add demo DurationPicker 30 | * Add onConfirmBefore callback event; 31 | 32 | ## 2.0.1 33 | * Fixed bug. 34 | * Add PickerWidget.of(context) Get Picker 35 | * Add selectedIconTheme property 36 | 37 | ## 2.0.0 38 | * Support Null safety 39 | * Optimize code, Update demo list 40 | 41 | ## 1.1.5 42 | * Repair BUG (Including the problem of datetime adapter before the month, add the needUpdatePrev interface to the adapter) 43 | * add builderHeader params. Allow custom headers to be generated. 44 | * DateTimePickerAdapter add minHour, maxHour. 45 | * Thank you for your timely feedback in GitHub! 46 | 47 | ## 1.1.4 48 | * performance optimization 49 | * Add a demo with a pop-up fillet background at the bottom. 50 | 51 | ## 1.1.3 52 | * return for showDialog , add barrierDismissible (thanks: Ali1Ammar) 53 | 54 | ## 1.1.2 55 | * Add the ability to jump minutes in DateTimePickerAdapter #76 (thank: MoacirSchmidt) 56 | * Repair BUG 57 | 58 | ## 1.1.1 59 | * Add localization for Turkish language 60 | * Refactor localization code 61 | * Repair BUG 62 | 63 | ## 1.1.0 64 | 65 | * Project reconstruction, removing Android, IOS directory. 66 | * Add localization for Spanish language 67 | 68 | ## 1.0.15 69 | 70 | * Move the edge of the head to the bottom of the head so that it can be hidden by customization. #55 (thank: @StarOfLife) 71 | * Repair bug: .showDialog(context) - error for define style #49 (thank: @nielgomes) 72 | * Repair bug: Change superior data, lower data display blank #48 (thank: @DemoJameson) 73 | 74 | ## 1.0.14 75 | 76 | * Added return for showModal #44 (thank: @GiorgioBertolotti) 77 | 78 | ## 1.0.13 79 | 80 | * Add parameter: selectedTextStyle, Styles for setting selected items. (thank: @TristanWYL) 81 | * Add parameter: footer, Widgets can be added at the bottom. 82 | 83 | ## 1.0.12 84 | 85 | * Repair BUG: #38, #40 86 | * DateTimePickerAdapter: Add the twoDigitYear attribute to support small screens (#39) 87 | 88 | ## 1.0.11 89 | 90 | * Add localization for Arabic language 91 | * Add parameter: cancel and confirm, Allow yourself to specify widgets to be placed in the identified and cancelled locations 92 | * DateTimePickerAdapter supports minValue and maxValue, which are used to limit the upper and lower bounds for selecting date and time. 93 | 94 | ## 1.0.10 95 | 96 | * Solving #25 Problem 97 | * Add attributes: headerDecoration, Can be used to control header borders. 98 | * Add Italian locale. 99 | 100 | ## 1.0.9 101 | 102 | * Add the ability to jump numbers in NumberPickerColumn (thank: @jesusrp98) 103 | 104 | ## 1.0.8 105 | 106 | * Repair Bug: showDialog 107 | 108 | ## 1.0.7 109 | 110 | * Add korea locale 111 | 112 | ## 1.0.6 113 | 114 | * Remove debugging output information 115 | 116 | ## 1.0.5 117 | 118 | * Modifying description information 119 | 120 | ## 1.0.3 121 | 122 | * Repair Bug. 123 | * NumberPickerAdapter, data Add onFormatValue property 124 | * DateTimePickerAdapter, Add customColumnType property, Support custom column order. 125 | 126 | ## 1.0.2 127 | 128 | * Repair Bug. 129 | 130 | ## 1.0.1 131 | 132 | * NumberPickerAdapter Support postfix; suffix. 133 | 134 | ## 1.0.0 135 | 136 | * Add NumberPickerAdapter, Support specified number range 137 | * Add isLinkage property, Support Array. 138 | * Add delimiter, Insert separators between columns 139 | * Add localization support 140 | * Optimization code 141 | 142 | ## 0.0.5 143 | 144 | * Adapter add notifyDataChanged function. 145 | 146 | ## 0.0.4 147 | 148 | * Add PickerDateTimeType.kYM. 149 | 150 | ## 0.0.3 151 | 152 | * Support column Flex setting. Add new DateTimeAdapter type. 153 | 154 | ## 0.0.2 155 | 156 | * Code refactoring, adding adapters. Support dialog box. Increase the date and time selection. 157 | 158 | 159 | ## 0.0.1 160 | 161 | * Describe initial release. 162 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 - 2019 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # flutter_picker 2 | 3 | [![pub package](https://img.shields.io/pub/v/flutter_picker.svg)](https://pub.dartlang.org/packages/flutter_picker) 4 | ![GitHub](https://img.shields.io/github/license/yangyxd/flutter_picker.svg) 5 | [![GitHub stars](https://img.shields.io/github/stars/yangyxd/flutter_picker.svg?style=social&label=Stars)](https://github.com/yangyxd/flutter_picker) 6 | 7 | Flutter plugin picker. Include NumberPicker, DateTimePicker, ArrayPicker, and default linkage Picker. Provide flexible parameters to meet various needs. At the same time, you can extend more functions through custom adapters. 8 | 9 | > Supported Platforms 10 | > * Android 11 | > * IOS 12 | > * Windows 13 | > * MacOS 14 | > * Linux 15 | > * Web 16 | 17 | ![image](https://github.com/yangyxd/flutter_picker/blob/master/raw/views.gif) 18 | 19 | ## How to Use 20 | 21 | ```yaml 22 | # add this line to your dependencies 23 | flutter_picker: 24 | git: 25 | url: https://github.com/yangyxd/flutter_picker.git 26 | ``` 27 | ```dart 28 | import 'package:flutter_picker/flutter_picker.dart'; 29 | ``` 30 | 31 | ```dart 32 | 33 | showPicker(BuildContext context) { 34 | Picker picker = new Picker( 35 | adapter: PickerDataAdapter(pickerdata: new JsonDecoder().convert(PickerData)), 36 | changeToFirst: true, 37 | textAlign: TextAlign.left, 38 | columnPadding: const EdgeInsets.all(8.0), 39 | onConfirm: (Picker picker, List value) { 40 | print(value.toString()); 41 | print(picker.getSelectedValues()); 42 | } 43 | ); 44 | picker.show(_scaffoldKey.currentState); 45 | } 46 | 47 | showPickerModal(BuildContext context) { 48 | new Picker( 49 | adapter: PickerDataAdapter(pickerdata: new JsonDecoder().convert(PickerData)), 50 | changeToFirst: true, 51 | hideHeader: false, 52 | onConfirm: (Picker picker, List value) { 53 | print(value.toString()); 54 | print(picker.adapter.text); 55 | } 56 | ).showModal(this.context); //_scaffoldKey.currentState); 57 | } 58 | 59 | showPickerIcons(BuildContext context) { 60 | new Picker( 61 | adapter: PickerDataAdapter(data: [ 62 | new PickerItem(text: Icon(Icons.add), value: Icons.add, children: [ 63 | new PickerItem(text: Icon(Icons.more)), 64 | new PickerItem(text: Icon(Icons.aspect_ratio)), 65 | new PickerItem(text: Icon(Icons.android)), 66 | new PickerItem(text: Icon(Icons.menu)), 67 | ]), 68 | new PickerItem(text: Icon(Icons.title), value: Icons.title, children: [ 69 | new PickerItem(text: Icon(Icons.more_vert)), 70 | new PickerItem(text: Icon(Icons.ac_unit)), 71 | new PickerItem(text: Icon(Icons.access_alarm)), 72 | new PickerItem(text: Icon(Icons.account_balance)), 73 | ]), 74 | new PickerItem(text: Icon(Icons.face), value: Icons.face, children: [ 75 | new PickerItem(text: Icon(Icons.add_circle_outline)), 76 | new PickerItem(text: Icon(Icons.add_a_photo)), 77 | new PickerItem(text: Icon(Icons.access_time)), 78 | new PickerItem(text: Icon(Icons.adjust)), 79 | ]), 80 | new PickerItem(text: Icon(Icons.linear_scale), value: Icons.linear_scale, children: [ 81 | new PickerItem(text: Icon(Icons.assistant_photo)), 82 | new PickerItem(text: Icon(Icons.account_balance)), 83 | new PickerItem(text: Icon(Icons.airline_seat_legroom_extra)), 84 | new PickerItem(text: Icon(Icons.airport_shuttle)), 85 | new PickerItem(text: Icon(Icons.settings_bluetooth)), 86 | ]), 87 | new PickerItem(text: Icon(Icons.close), value: Icons.close), 88 | ]), 89 | title: new Text("Select Icon"), 90 | onConfirm: (Picker picker, List value) { 91 | print(value.toString()); 92 | print(picker.getSelectedValues()); 93 | } 94 | ).show(_scaffoldKey.currentState); 95 | } 96 | 97 | showPickerDialog(BuildContext context) { 98 | new Picker( 99 | adapter: PickerDataAdapter(pickerdata: new JsonDecoder().convert(PickerData)), 100 | hideHeader: true, 101 | title: new Text("Select Data"), 102 | onConfirm: (Picker picker, List value) { 103 | print(value.toString()); 104 | print(picker.getSelectedValues()); 105 | } 106 | ).showDialog(context); 107 | } 108 | 109 | showPickerArray(BuildContext context) { 110 | new Picker( 111 | adapter: PickerDataAdapter(pickerdata: new JsonDecoder().convert(PickerData2), isArray: true), 112 | hideHeader: true, 113 | title: new Text("Please Select"), 114 | onConfirm: (Picker picker, List value) { 115 | print(value.toString()); 116 | print(picker.getSelectedValues()); 117 | } 118 | ).showDialog(context); 119 | } 120 | 121 | showPickerNumber(BuildContext context) { 122 | new Picker( 123 | adapter: NumberPickerAdapter(data: [ 124 | NumberPickerColumn(begin: 0, end: 999), 125 | NumberPickerColumn(begin: 100, end: 200), 126 | ]), 127 | delimiter: [ 128 | PickerDelimiter(child: Container( 129 | width: 30.0, 130 | alignment: Alignment.center, 131 | child: Icon(Icons.more_vert), 132 | )) 133 | ], 134 | hideHeader: true, 135 | title: new Text("Please Select"), 136 | onConfirm: (Picker picker, List value) { 137 | print(value.toString()); 138 | print(picker.getSelectedValues()); 139 | } 140 | ).showDialog(context); 141 | } 142 | 143 | ``` 144 | ## PickerData Example 145 | 146 | ### Array 147 | 148 | ```dart 149 | 150 | const PickerData2 = ''' 151 | [ 152 | [ 153 | 1, 154 | 2, 155 | 3, 156 | 4 157 | ], 158 | [ 159 | 11, 160 | 22, 161 | 33, 162 | 44 163 | ], 164 | [ 165 | "aaa", 166 | "bbb", 167 | "ccc" 168 | ] 169 | ] 170 | '''; 171 | ``` 172 | 173 | ### Linkage 174 | ```dart 175 | const PickerData = ''' 176 | [ 177 | { 178 | "a": [ 179 | { 180 | "a1": [ 181 | 1, 182 | 2, 183 | 3, 184 | 4 185 | ] 186 | }, 187 | { 188 | "a2": [ 189 | 5, 190 | 6, 191 | 7, 192 | 8 193 | ] 194 | }, 195 | { 196 | "a3": [ 197 | 9, 198 | 10, 199 | 11, 200 | 12 201 | ] 202 | } 203 | ] 204 | }, 205 | { 206 | "b": [ 207 | { 208 | "b1": [ 209 | 11, 210 | 22, 211 | 33, 212 | 44 213 | ] 214 | }, 215 | { 216 | "b2": [ 217 | 55, 218 | 66, 219 | 77, 220 | 88 221 | ] 222 | }, 223 | { 224 | "b3": [ 225 | 99, 226 | 1010, 227 | 1111, 228 | 1212 229 | ] 230 | } 231 | ] 232 | }, 233 | { 234 | "c": [ 235 | { 236 | "c1": [ 237 | "a", 238 | "b", 239 | "c" 240 | ] 241 | }, 242 | { 243 | "c2": [ 244 | "aa", 245 | "bb", 246 | "cc" 247 | ] 248 | }, 249 | { 250 | "c3": [ 251 | "aaa", 252 | "bbb", 253 | "ccc" 254 | ] 255 | } 256 | ] 257 | } 258 | ] 259 | '''; 260 | ``` -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .dart_tool/ 3 | 4 | .packages 5 | .pub/ 6 | 7 | build/ 8 | 9 | .flutter-plugins 10 | -------------------------------------------------------------------------------- /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: cd41fdd495f6944ecd3506c21e94c6567b073278 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: cd41fdd495f6944ecd3506c21e94c6567b073278 17 | base_revision: cd41fdd495f6944ecd3506c21e94c6567b073278 18 | - platform: android 19 | create_revision: cd41fdd495f6944ecd3506c21e94c6567b073278 20 | base_revision: cd41fdd495f6944ecd3506c21e94c6567b073278 21 | - platform: ios 22 | create_revision: cd41fdd495f6944ecd3506c21e94c6567b073278 23 | base_revision: cd41fdd495f6944ecd3506c21e94c6567b073278 24 | - platform: linux 25 | create_revision: cd41fdd495f6944ecd3506c21e94c6567b073278 26 | base_revision: cd41fdd495f6944ecd3506c21e94c6567b073278 27 | - platform: macos 28 | create_revision: cd41fdd495f6944ecd3506c21e94c6567b073278 29 | base_revision: cd41fdd495f6944ecd3506c21e94c6567b073278 30 | - platform: web 31 | create_revision: cd41fdd495f6944ecd3506c21e94c6567b073278 32 | base_revision: cd41fdd495f6944ecd3506c21e94c6567b073278 33 | - platform: windows 34 | create_revision: cd41fdd495f6944ecd3506c21e94c6567b073278 35 | base_revision: cd41fdd495f6944ecd3506c21e94c6567b073278 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_picker_example 2 | 3 | Demonstrates how to use the flutter_picker plugin. 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 | compileSdkVersion flutter.compileSdkVersion 30 | ndkVersion flutter.ndkVersion 31 | 32 | compileOptions { 33 | sourceCompatibility JavaVersion.VERSION_1_8 34 | targetCompatibility JavaVersion.VERSION_1_8 35 | } 36 | 37 | kotlinOptions { 38 | jvmTarget = '1.8' 39 | } 40 | 41 | sourceSets { 42 | main.java.srcDirs += 'src/main/kotlin' 43 | } 44 | 45 | defaultConfig { 46 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 47 | applicationId "com.yangyxd.example" 48 | // You can update the following values to match your application needs. 49 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. 50 | minSdkVersion flutter.minSdkVersion 51 | targetSdkVersion flutter.targetSdkVersion 52 | versionCode flutterVersionCode.toInteger() 53 | versionName flutterVersionName 54 | } 55 | 56 | buildTypes { 57 | release { 58 | // TODO: Add your own signing config for the release build. 59 | // Signing with the debug keys for now, so `flutter run --release` works. 60 | signingConfig signingConfigs.debug 61 | } 62 | } 63 | } 64 | 65 | flutter { 66 | source '../..' 67 | } 68 | 69 | dependencies { 70 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 71 | } 72 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 15 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /example/android/app/src/main/kotlin/com/yangyxd/example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.yangyxd.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/yangyxd/flutter_picker/c47b3d53e94cee651d82e6feac0fa3c3ec8d63bc/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/yangyxd/flutter_picker/c47b3d53e94cee651d82e6feac0fa3c3ec8d63bc/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/yangyxd/flutter_picker/c47b3d53e94cee651d82e6feac0fa3c3ec8d63bc/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/yangyxd/flutter_picker/c47b3d53e94cee651d82e6feac0fa3c3ec8d63bc/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/yangyxd/flutter_picker/c47b3d53e94cee651d82e6feac0fa3c3ec8d63bc/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.6.10' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.1.2' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | mavenCentral() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | task clean(type: Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip 7 | -------------------------------------------------------------------------------- /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/flutter_picker_example.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /example/flutter_picker_example_android.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /example/ios/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vagrant/ 3 | .sconsign.dblite 4 | .svn/ 5 | 6 | .DS_Store 7 | *.swp 8 | profile 9 | 10 | DerivedData/ 11 | build/ 12 | GeneratedPluginRegistrant.h 13 | GeneratedPluginRegistrant.m 14 | 15 | .generated/ 16 | 17 | *.pbxuser 18 | *.mode1v3 19 | *.mode2v3 20 | *.perspectivev3 21 | 22 | !default.pbxuser 23 | !default.mode1v3 24 | !default.mode2v3 25 | !default.perspectivev3 26 | 27 | xcuserdata 28 | 29 | *.moved-aside 30 | 31 | *.pyc 32 | *sync/ 33 | Icon? 34 | .tags* 35 | 36 | /Flutter/app.flx 37 | /Flutter/app.zip 38 | /Flutter/flutter_assets/ 39 | /Flutter/App.framework 40 | /Flutter/Flutter.framework 41 | /Flutter/Generated.xcconfig 42 | /ServiceDefinitions.json 43 | 44 | Pods/ 45 | .symlinks/ 46 | -------------------------------------------------------------------------------- /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 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 11 | 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; }; 12 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 13 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; 14 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 15 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; 16 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 17 | 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; }; 18 | 9740EEB51CF90195004384FC /* Generated.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB31CF90195004384FC /* Generated.xcconfig */; }; 19 | 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; 20 | 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; 21 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 22 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 23 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 24 | /* End PBXBuildFile section */ 25 | 26 | /* Begin PBXCopyFilesBuildPhase section */ 27 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = { 28 | isa = PBXCopyFilesBuildPhase; 29 | buildActionMask = 2147483647; 30 | dstPath = ""; 31 | dstSubfolderSpec = 10; 32 | files = ( 33 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */, 34 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */, 35 | ); 36 | name = "Embed Frameworks"; 37 | runOnlyForDeploymentPostprocessing = 0; 38 | }; 39 | /* End PBXCopyFilesBuildPhase section */ 40 | 41 | /* Begin PBXFileReference section */ 42 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 43 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 44 | 2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; }; 45 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 46 | 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; 47 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 48 | 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 49 | 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 50 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 51 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 52 | 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; }; 53 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 54 | 97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 55 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 56 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 57 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 58 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 59 | /* End PBXFileReference section */ 60 | 61 | /* Begin PBXFrameworksBuildPhase section */ 62 | 97C146EB1CF9000F007C117D /* Frameworks */ = { 63 | isa = PBXFrameworksBuildPhase; 64 | buildActionMask = 2147483647; 65 | files = ( 66 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, 67 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, 68 | ); 69 | runOnlyForDeploymentPostprocessing = 0; 70 | }; 71 | /* End PBXFrameworksBuildPhase section */ 72 | 73 | /* Begin PBXGroup section */ 74 | 9740EEB11CF90186004384FC /* Flutter */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | 2D5378251FAA1A9400D5DBA9 /* flutter_assets */, 78 | 3B80C3931E831B6300D905FE /* App.framework */, 79 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 80 | 9740EEBA1CF902C7004384FC /* Flutter.framework */, 81 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 82 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 83 | 9740EEB31CF90195004384FC /* Generated.xcconfig */, 84 | ); 85 | name = Flutter; 86 | sourceTree = ""; 87 | }; 88 | 97C146E51CF9000F007C117D = { 89 | isa = PBXGroup; 90 | children = ( 91 | 9740EEB11CF90186004384FC /* Flutter */, 92 | 97C146F01CF9000F007C117D /* Runner */, 93 | 97C146EF1CF9000F007C117D /* Products */, 94 | CF3B75C9A7D2FA2A4C99F110 /* Frameworks */, 95 | ); 96 | sourceTree = ""; 97 | }; 98 | 97C146EF1CF9000F007C117D /* Products */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | 97C146EE1CF9000F007C117D /* Runner.app */, 102 | ); 103 | name = Products; 104 | sourceTree = ""; 105 | }; 106 | 97C146F01CF9000F007C117D /* Runner */ = { 107 | isa = PBXGroup; 108 | children = ( 109 | 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */, 110 | 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */, 111 | 97C146FA1CF9000F007C117D /* Main.storyboard */, 112 | 97C146FD1CF9000F007C117D /* Assets.xcassets */, 113 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 114 | 97C147021CF9000F007C117D /* Info.plist */, 115 | 97C146F11CF9000F007C117D /* Supporting Files */, 116 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 117 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 118 | ); 119 | path = Runner; 120 | sourceTree = ""; 121 | }; 122 | 97C146F11CF9000F007C117D /* Supporting Files */ = { 123 | isa = PBXGroup; 124 | children = ( 125 | 97C146F21CF9000F007C117D /* main.m */, 126 | ); 127 | name = "Supporting Files"; 128 | sourceTree = ""; 129 | }; 130 | /* End PBXGroup section */ 131 | 132 | /* Begin PBXNativeTarget section */ 133 | 97C146ED1CF9000F007C117D /* Runner */ = { 134 | isa = PBXNativeTarget; 135 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; 136 | buildPhases = ( 137 | 9740EEB61CF901F6004384FC /* Run Script */, 138 | 97C146EA1CF9000F007C117D /* Sources */, 139 | 97C146EB1CF9000F007C117D /* Frameworks */, 140 | 97C146EC1CF9000F007C117D /* Resources */, 141 | 9705A1C41CF9048500538489 /* Embed Frameworks */, 142 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 143 | ); 144 | buildRules = ( 145 | ); 146 | dependencies = ( 147 | ); 148 | name = Runner; 149 | productName = Runner; 150 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */; 151 | productType = "com.apple.product-type.application"; 152 | }; 153 | /* End PBXNativeTarget section */ 154 | 155 | /* Begin PBXProject section */ 156 | 97C146E61CF9000F007C117D /* Project object */ = { 157 | isa = PBXProject; 158 | attributes = { 159 | LastUpgradeCheck = 0910; 160 | ORGANIZATIONNAME = "The Chromium Authors"; 161 | TargetAttributes = { 162 | 97C146ED1CF9000F007C117D = { 163 | CreatedOnToolsVersion = 7.3.1; 164 | }; 165 | }; 166 | }; 167 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; 168 | compatibilityVersion = "Xcode 3.2"; 169 | developmentRegion = English; 170 | hasScannedForEncodings = 0; 171 | knownRegions = ( 172 | en, 173 | Base, 174 | ); 175 | mainGroup = 97C146E51CF9000F007C117D; 176 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */; 177 | projectDirPath = ""; 178 | projectRoot = ""; 179 | targets = ( 180 | 97C146ED1CF9000F007C117D /* Runner */, 181 | ); 182 | }; 183 | /* End PBXProject section */ 184 | 185 | /* Begin PBXResourcesBuildPhase section */ 186 | 97C146EC1CF9000F007C117D /* Resources */ = { 187 | isa = PBXResourcesBuildPhase; 188 | buildActionMask = 2147483647; 189 | files = ( 190 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 191 | 9740EEB51CF90195004384FC /* Generated.xcconfig in Resources */, 192 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 193 | 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */, 194 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 195 | 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */, 196 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 197 | ); 198 | runOnlyForDeploymentPostprocessing = 0; 199 | }; 200 | /* End PBXResourcesBuildPhase section */ 201 | 202 | /* Begin PBXShellScriptBuildPhase section */ 203 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 204 | isa = PBXShellScriptBuildPhase; 205 | buildActionMask = 2147483647; 206 | files = ( 207 | ); 208 | inputPaths = ( 209 | ); 210 | name = "Thin Binary"; 211 | outputPaths = ( 212 | ); 213 | runOnlyForDeploymentPostprocessing = 0; 214 | shellPath = /bin/sh; 215 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; 216 | }; 217 | 9740EEB61CF901F6004384FC /* Run Script */ = { 218 | isa = PBXShellScriptBuildPhase; 219 | buildActionMask = 2147483647; 220 | files = ( 221 | ); 222 | inputPaths = ( 223 | ); 224 | name = "Run Script"; 225 | outputPaths = ( 226 | ); 227 | runOnlyForDeploymentPostprocessing = 0; 228 | shellPath = /bin/sh; 229 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 230 | }; 231 | /* End PBXShellScriptBuildPhase section */ 232 | 233 | /* Begin PBXSourcesBuildPhase section */ 234 | 97C146EA1CF9000F007C117D /* Sources */ = { 235 | isa = PBXSourcesBuildPhase; 236 | buildActionMask = 2147483647; 237 | files = ( 238 | 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */, 239 | 97C146F31CF9000F007C117D /* main.m in Sources */, 240 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 241 | ); 242 | runOnlyForDeploymentPostprocessing = 0; 243 | }; 244 | /* End PBXSourcesBuildPhase section */ 245 | 246 | /* Begin PBXVariantGroup section */ 247 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = { 248 | isa = PBXVariantGroup; 249 | children = ( 250 | 97C146FB1CF9000F007C117D /* Base */, 251 | ); 252 | name = Main.storyboard; 253 | sourceTree = ""; 254 | }; 255 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { 256 | isa = PBXVariantGroup; 257 | children = ( 258 | 97C147001CF9000F007C117D /* Base */, 259 | ); 260 | name = LaunchScreen.storyboard; 261 | sourceTree = ""; 262 | }; 263 | /* End PBXVariantGroup section */ 264 | 265 | /* Begin XCBuildConfiguration section */ 266 | 97C147031CF9000F007C117D /* Debug */ = { 267 | isa = XCBuildConfiguration; 268 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 269 | buildSettings = { 270 | ALWAYS_SEARCH_USER_PATHS = NO; 271 | CLANG_ANALYZER_NONNULL = YES; 272 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 273 | CLANG_CXX_LIBRARY = "libc++"; 274 | CLANG_ENABLE_MODULES = YES; 275 | CLANG_ENABLE_OBJC_ARC = YES; 276 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 277 | CLANG_WARN_BOOL_CONVERSION = YES; 278 | CLANG_WARN_COMMA = YES; 279 | CLANG_WARN_CONSTANT_CONVERSION = YES; 280 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 281 | CLANG_WARN_EMPTY_BODY = YES; 282 | CLANG_WARN_ENUM_CONVERSION = YES; 283 | CLANG_WARN_INFINITE_RECURSION = YES; 284 | CLANG_WARN_INT_CONVERSION = YES; 285 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 286 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 287 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 288 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 289 | CLANG_WARN_STRICT_PROTOTYPES = YES; 290 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 291 | CLANG_WARN_UNREACHABLE_CODE = YES; 292 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 293 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 294 | COPY_PHASE_STRIP = NO; 295 | DEBUG_INFORMATION_FORMAT = dwarf; 296 | ENABLE_STRICT_OBJC_MSGSEND = YES; 297 | ENABLE_TESTABILITY = YES; 298 | GCC_C_LANGUAGE_STANDARD = gnu99; 299 | GCC_DYNAMIC_NO_PIC = NO; 300 | GCC_NO_COMMON_BLOCKS = YES; 301 | GCC_OPTIMIZATION_LEVEL = 0; 302 | GCC_PREPROCESSOR_DEFINITIONS = ( 303 | "DEBUG=1", 304 | "$(inherited)", 305 | ); 306 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 307 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 308 | GCC_WARN_UNDECLARED_SELECTOR = YES; 309 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 310 | GCC_WARN_UNUSED_FUNCTION = YES; 311 | GCC_WARN_UNUSED_VARIABLE = YES; 312 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 313 | MTL_ENABLE_DEBUG_INFO = YES; 314 | ONLY_ACTIVE_ARCH = YES; 315 | SDKROOT = iphoneos; 316 | TARGETED_DEVICE_FAMILY = "1,2"; 317 | }; 318 | name = Debug; 319 | }; 320 | 97C147041CF9000F007C117D /* Release */ = { 321 | isa = XCBuildConfiguration; 322 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 323 | buildSettings = { 324 | ALWAYS_SEARCH_USER_PATHS = NO; 325 | CLANG_ANALYZER_NONNULL = YES; 326 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 327 | CLANG_CXX_LIBRARY = "libc++"; 328 | CLANG_ENABLE_MODULES = YES; 329 | CLANG_ENABLE_OBJC_ARC = YES; 330 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 331 | CLANG_WARN_BOOL_CONVERSION = YES; 332 | CLANG_WARN_COMMA = YES; 333 | CLANG_WARN_CONSTANT_CONVERSION = YES; 334 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 335 | CLANG_WARN_EMPTY_BODY = YES; 336 | CLANG_WARN_ENUM_CONVERSION = YES; 337 | CLANG_WARN_INFINITE_RECURSION = YES; 338 | CLANG_WARN_INT_CONVERSION = YES; 339 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 340 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 341 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 342 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 343 | CLANG_WARN_STRICT_PROTOTYPES = YES; 344 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 345 | CLANG_WARN_UNREACHABLE_CODE = YES; 346 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 347 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 348 | COPY_PHASE_STRIP = NO; 349 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 350 | ENABLE_NS_ASSERTIONS = NO; 351 | ENABLE_STRICT_OBJC_MSGSEND = YES; 352 | GCC_C_LANGUAGE_STANDARD = gnu99; 353 | GCC_NO_COMMON_BLOCKS = YES; 354 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 355 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 356 | GCC_WARN_UNDECLARED_SELECTOR = YES; 357 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 358 | GCC_WARN_UNUSED_FUNCTION = YES; 359 | GCC_WARN_UNUSED_VARIABLE = YES; 360 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 361 | MTL_ENABLE_DEBUG_INFO = NO; 362 | SDKROOT = iphoneos; 363 | TARGETED_DEVICE_FAMILY = "1,2"; 364 | VALIDATE_PRODUCT = YES; 365 | }; 366 | name = Release; 367 | }; 368 | 97C147061CF9000F007C117D /* Debug */ = { 369 | isa = XCBuildConfiguration; 370 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 371 | buildSettings = { 372 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 373 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 374 | ENABLE_BITCODE = NO; 375 | FRAMEWORK_SEARCH_PATHS = ( 376 | "$(inherited)", 377 | "$(PROJECT_DIR)/Flutter", 378 | ); 379 | INFOPLIST_FILE = Runner/Info.plist; 380 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 381 | LIBRARY_SEARCH_PATHS = ( 382 | "$(inherited)", 383 | "$(PROJECT_DIR)/Flutter", 384 | ); 385 | PRODUCT_BUNDLE_IDENTIFIER = com.yangyxd.flutterPickerExample; 386 | PRODUCT_NAME = "$(TARGET_NAME)"; 387 | VERSIONING_SYSTEM = "apple-generic"; 388 | }; 389 | name = Debug; 390 | }; 391 | 97C147071CF9000F007C117D /* Release */ = { 392 | isa = XCBuildConfiguration; 393 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 394 | buildSettings = { 395 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 396 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 397 | ENABLE_BITCODE = NO; 398 | FRAMEWORK_SEARCH_PATHS = ( 399 | "$(inherited)", 400 | "$(PROJECT_DIR)/Flutter", 401 | ); 402 | INFOPLIST_FILE = Runner/Info.plist; 403 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 404 | LIBRARY_SEARCH_PATHS = ( 405 | "$(inherited)", 406 | "$(PROJECT_DIR)/Flutter", 407 | ); 408 | PRODUCT_BUNDLE_IDENTIFIER = com.yangyxd.flutterPickerExample; 409 | PRODUCT_NAME = "$(TARGET_NAME)"; 410 | VERSIONING_SYSTEM = "apple-generic"; 411 | }; 412 | name = Release; 413 | }; 414 | /* End XCBuildConfiguration section */ 415 | 416 | /* Begin XCConfigurationList section */ 417 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 418 | isa = XCConfigurationList; 419 | buildConfigurations = ( 420 | 97C147031CF9000F007C117D /* Debug */, 421 | 97C147041CF9000F007C117D /* Release */, 422 | ); 423 | defaultConfigurationIsVisible = 0; 424 | defaultConfigurationName = Release; 425 | }; 426 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 427 | isa = XCConfigurationList; 428 | buildConfigurations = ( 429 | 97C147061CF9000F007C117D /* Debug */, 430 | 97C147071CF9000F007C117D /* Release */, 431 | ); 432 | defaultConfigurationIsVisible = 0; 433 | defaultConfigurationName = Release; 434 | }; 435 | /* End XCConfigurationList section */ 436 | }; 437 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 438 | } 439 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 33 | 34 | 40 | 41 | 42 | 43 | 44 | 45 | 56 | 58 | 64 | 65 | 66 | 67 | 68 | 69 | 75 | 77 | 83 | 84 | 85 | 86 | 88 | 89 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : FlutterAppDelegate 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #include "AppDelegate.h" 2 | #include "GeneratedPluginRegistrant.h" 3 | 4 | @implementation AppDelegate 5 | 6 | - (BOOL)application:(UIApplication *)application 7 | didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 8 | [GeneratedPluginRegistrant registerWithRegistry:self]; 9 | // Override point for customization after application launch. 10 | return [super application:application didFinishLaunchingWithOptions:launchOptions]; 11 | } 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangyxd/flutter_picker/c47b3d53e94cee651d82e6feac0fa3c3ec8d63bc/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/yangyxd/flutter_picker/c47b3d53e94cee651d82e6feac0fa3c3ec8d63bc/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/yangyxd/flutter_picker/c47b3d53e94cee651d82e6feac0fa3c3ec8d63bc/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/yangyxd/flutter_picker/c47b3d53e94cee651d82e6feac0fa3c3ec8d63bc/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/yangyxd/flutter_picker/c47b3d53e94cee651d82e6feac0fa3c3ec8d63bc/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/yangyxd/flutter_picker/c47b3d53e94cee651d82e6feac0fa3c3ec8d63bc/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/yangyxd/flutter_picker/c47b3d53e94cee651d82e6feac0fa3c3ec8d63bc/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/yangyxd/flutter_picker/c47b3d53e94cee651d82e6feac0fa3c3ec8d63bc/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/yangyxd/flutter_picker/c47b3d53e94cee651d82e6feac0fa3c3ec8d63bc/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/yangyxd/flutter_picker/c47b3d53e94cee651d82e6feac0fa3c3ec8d63bc/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/yangyxd/flutter_picker/c47b3d53e94cee651d82e6feac0fa3c3ec8d63bc/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/yangyxd/flutter_picker/c47b3d53e94cee651d82e6feac0fa3c3ec8d63bc/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/yangyxd/flutter_picker/c47b3d53e94cee651d82e6feac0fa3c3ec8d63bc/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/yangyxd/flutter_picker/c47b3d53e94cee651d82e6feac0fa3c3ec8d63bc/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/yangyxd/flutter_picker/c47b3d53e94cee651d82e6feac0fa3c3ec8d63bc/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/yangyxd/flutter_picker/c47b3d53e94cee651d82e6feac0fa3c3ec8d63bc/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangyxd/flutter_picker/c47b3d53e94cee651d82e6feac0fa3c3ec8d63bc/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangyxd/flutter_picker/c47b3d53e94cee651d82e6feac0fa3c3ec8d63bc/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | flutter_picker_example 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(FLUTTER_BUILD_NAME) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UIViewControllerBasedStatusBarAppearance 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /example/ios/Runner/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char* argv[]) { 6 | @autoreleasepool { 7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | import 'dart:ui'; 3 | 4 | import 'package:flutter/material.dart'; 5 | import 'dart:convert'; 6 | import 'package:flutter_picker/flutter_picker.dart'; 7 | import 'package:flutter_picker_example/picker_test.dart'; 8 | import 'picker_data.dart'; 9 | import 'package:flutter_localizations/flutter_localizations.dart'; 10 | 11 | void main() => runApp(MyApp()); 12 | 13 | class MyApp extends StatefulWidget { 14 | @override 15 | _MyAppState createState() => _MyAppState(); 16 | } 17 | 18 | final String _fontFamily = Platform.isWindows ? "Roboto" : ""; 19 | 20 | const Set _kTouchLikeDeviceTypes = { 21 | PointerDeviceKind.touch, 22 | PointerDeviceKind.mouse, 23 | PointerDeviceKind.stylus, 24 | PointerDeviceKind.invertedStylus, 25 | PointerDeviceKind.unknown 26 | }; 27 | 28 | class _MyAppState extends State { 29 | bool dark = false; 30 | 31 | @override 32 | Widget build(BuildContext context) { 33 | return MaterialApp( 34 | theme: ThemeData( 35 | primarySwatch: Colors.blue, 36 | fontFamily: _fontFamily, 37 | brightness: dark ? Brightness.dark : Brightness.light, 38 | primaryTextTheme: TextTheme().apply(fontFamily: _fontFamily), 39 | ), 40 | scrollBehavior: const MaterialScrollBehavior() 41 | .copyWith(scrollbars: true, dragDevices: _kTouchLikeDeviceTypes), 42 | localizationsDelegates: [ 43 | PickerLocalizationsDelegate.delegate, // 如果要使用本地化,请添加此行,则可以显示中文按钮 44 | GlobalMaterialLocalizations.delegate, 45 | GlobalWidgetsLocalizations.delegate, 46 | ], 47 | supportedLocales: [ 48 | const Locale('en', 'US'), 49 | const Locale('zh', 'CH'), 50 | const Locale('ko', 'KO'), 51 | const Locale('it', 'IT'), 52 | const Locale('ar', 'AR'), 53 | const Locale('tr', 'TR'), 54 | const Locale('ro', 'RO'), 55 | ], 56 | home: MyHomePage()); 57 | } 58 | } 59 | 60 | class MyHomePage extends StatefulWidget { 61 | @override 62 | _MyHomePageState createState() => _MyHomePageState(); 63 | } 64 | 65 | class _MyHomePageState extends State { 66 | final double listSpec = 4.0; 67 | final GlobalKey _scaffoldKey = GlobalKey(); 68 | String stateText = ""; 69 | 70 | @override 71 | Widget build(BuildContext context) { 72 | return Scaffold( 73 | key: _scaffoldKey, 74 | appBar: AppBar( 75 | title: Text('Picker ${stateText.isEmpty ? "" : " - " + stateText}'), 76 | automaticallyImplyLeading: false, 77 | elevation: 0.0, 78 | actions: [ 79 | IconButton( 80 | onPressed: () { 81 | final appState = context.findAncestorStateOfType<_MyAppState>(); 82 | if (appState == null) return; 83 | appState.setState(() { 84 | appState.dark = !appState.dark; 85 | }); 86 | }, 87 | icon: Icon(Icons.sunny_snowing)), 88 | IconButton( 89 | onPressed: () => Navigator.push( 90 | context, MaterialPageRoute(builder: (v) => RawPickerTest())), 91 | icon: Icon(Icons.add)), 92 | ], 93 | ), 94 | body: Builder( 95 | builder: (context) => ListView( 96 | padding: EdgeInsets.all(10.0), 97 | children: [ 98 | ListTile( 99 | title: Text('1. Picker Show'), 100 | onTap: () { 101 | showPicker(context); 102 | }, 103 | ), 104 | ListTile( 105 | title: Text('2. Picker Show Modal'), 106 | onTap: () { 107 | showPickerModal(context); 108 | }, 109 | ), 110 | ListTile( 111 | title: Text('3. Picker Show Icons'), 112 | onTap: () { 113 | showPickerIcons(context); 114 | }, 115 | ), 116 | ListTile( 117 | title: Text('4. Picker Show (Array)'), 118 | onTap: () { 119 | showPickerArray(context); 120 | }, 121 | ), 122 | ListTile( 123 | title: Text('5. Picker Show Number'), 124 | onTap: () { 125 | showPickerNumber(context); 126 | }, 127 | ), 128 | ListTile( 129 | title: Text('6. Picker Show Number FormatValue'), 130 | onTap: () { 131 | showPickerNumberFormatValue(context); 132 | }, 133 | ), 134 | ListTile( 135 | title: Text('7. Picker Show Date'), 136 | onTap: () { 137 | showPickerDate(context); 138 | }, 139 | ), 140 | ListTile( 141 | title: Text('8. Picker Show Datetime'), 142 | onTap: () { 143 | showPickerDateTime(context); 144 | }, 145 | ), 146 | ListTile( 147 | title: Text('9. Picker Show Date (Custom)'), 148 | onTap: () { 149 | showPickerDateCustom(context); 150 | }, 151 | ), 152 | ListTile( 153 | title: Text('10. Picker Show Datetime (24)'), 154 | onTap: () { 155 | showPickerDateTime24(context); 156 | }, 157 | ), 158 | ListTile( 159 | title: Text('11. Picker Show Datetime (Round background)'), 160 | onTap: () { 161 | showPickerDateTimeRoundBg(context); 162 | }, 163 | ), 164 | ListTile( 165 | title: Text('12. Picker Show Date Range'), 166 | onTap: () { 167 | showPickerDateRange(context); 168 | }, 169 | ), 170 | ListTile( 171 | title: Text('13. DurationPicker (time)'), 172 | onTap: () { 173 | showPickerDurationSelect(context); 174 | }, 175 | ), 176 | ListTile( 177 | title: Text('14. Customize UI effects (time)'), 178 | onTap: () { 179 | showPickerCustomizeUI(context); 180 | }, 181 | ), 182 | ListTile( 183 | title: Text('15. Use onBuilderItem'), 184 | onTap: () { 185 | showPickerCustomBuilder(context); 186 | }, 187 | ), 188 | ListTile( 189 | title: Text('16. Select year'), 190 | onTap: () { 191 | showPickerSelectYear(context); 192 | }, 193 | ), 194 | const SizedBox(height: 60), 195 | ], 196 | )), 197 | ); 198 | } 199 | 200 | showMsg(String msg) { 201 | final state = ScaffoldMessenger.of(context); 202 | state.showSnackBar(SnackBar(content: Text(msg))); 203 | } 204 | 205 | showPicker(BuildContext context) async { 206 | Picker picker = Picker( 207 | adapter: PickerDataAdapter( 208 | pickerData: JsonDecoder().convert(PickerData)), 209 | changeToFirst: false, 210 | textAlign: TextAlign.left, 211 | textStyle: TextStyle( 212 | color: Theme.of(context).brightness == Brightness.dark 213 | ? Colors.yellow 214 | : Colors.blue, 215 | fontFamily: _fontFamily), 216 | selectedTextStyle: TextStyle(color: Colors.red), 217 | columnPadding: const EdgeInsets.all(8.0), 218 | onConfirm: (Picker picker, List value) { 219 | print(value.toString()); 220 | print(picker.getSelectedValues()); 221 | }); 222 | picker.showBottomSheet(context); 223 | } 224 | 225 | showPickerModal(BuildContext context) async { 226 | final result = await Picker( 227 | adapter: PickerDataAdapter( 228 | pickerData: JsonDecoder().convert(PickerData)), 229 | changeToFirst: true, 230 | hideHeader: false, 231 | selectedTextStyle: TextStyle(color: Colors.blue), 232 | // builderHeader: (context) { 233 | // final picker = PickerWidget.of(context); 234 | // return picker?.data?.title ?? Text("xxx"); 235 | // }, 236 | onConfirm: (picker, value) { 237 | print(value.toString()); 238 | print(picker.adapter.text); 239 | Navigator.push( 240 | context, 241 | MaterialPageRoute( 242 | builder: (context) => Scaffold( 243 | appBar: AppBar(title: Text("Hello")), 244 | body: Center( 245 | child: Column( 246 | mainAxisSize: MainAxisSize.min, 247 | crossAxisAlignment: CrossAxisAlignment.start, 248 | children: [ 249 | Text("You click the Confirm button."), 250 | SizedBox(height: 32), 251 | Text("result: \n ${picker.adapter.text}") 252 | ], 253 | )), 254 | ))); 255 | }).showModal(this.context); //_sca 256 | print("result: $result"); // ffoldKey.currentState); 257 | } 258 | 259 | showPickerIcons(BuildContext context) { 260 | Picker( 261 | adapter: PickerDataAdapter(data: [ 262 | PickerItem(text: Icon(Icons.add), value: Icons.add, children: [ 263 | PickerItem(text: Icon(Icons.more)), 264 | PickerItem(text: Icon(Icons.aspect_ratio)), 265 | PickerItem(text: Icon(Icons.android)), 266 | PickerItem(text: Icon(Icons.menu), children: [ 267 | // 测试:多加了一维数据 268 | PickerItem(text: Icon(Icons.account_box)), 269 | PickerItem(text: Icon(Icons.analytics)), 270 | ]), 271 | ]), 272 | PickerItem(text: Icon(Icons.title), value: Icons.title, children: [ 273 | PickerItem(text: Icon(Icons.more_vert)), 274 | PickerItem(text: Icon(Icons.ac_unit)), 275 | PickerItem(text: Icon(Icons.access_alarm)), 276 | PickerItem(text: Icon(Icons.account_balance)), 277 | ]), 278 | PickerItem(text: Icon(Icons.face), value: Icons.face, children: [ 279 | PickerItem(text: Icon(Icons.add_circle_outline)), 280 | PickerItem(text: Icon(Icons.add_a_photo)), 281 | PickerItem(text: Icon(Icons.access_time)), 282 | PickerItem(text: Icon(Icons.adjust)), 283 | ]), 284 | PickerItem( 285 | text: Icon(Icons.linear_scale), 286 | value: Icons.linear_scale, 287 | children: [ 288 | PickerItem(text: Icon(Icons.assistant_photo)), 289 | PickerItem(text: Icon(Icons.account_balance)), 290 | PickerItem(text: Icon(Icons.airline_seat_legroom_extra)), 291 | PickerItem(text: Icon(Icons.airport_shuttle)), 292 | PickerItem(text: Icon(Icons.settings_bluetooth)), 293 | ]), 294 | PickerItem(text: Icon(Icons.close), value: Icons.close), 295 | ]), 296 | title: Text("Select Icon"), 297 | selectedTextStyle: TextStyle(color: Colors.blue, fontSize: 12), 298 | onConfirm: (Picker picker, List value) { 299 | print(value.toString()); 300 | print(picker.getSelectedValues()); 301 | }, 302 | ).showBottomSheet(context); 303 | } 304 | 305 | showPickerDialog(BuildContext context) { 306 | Picker( 307 | adapter: PickerDataAdapter( 308 | pickerData: JsonDecoder().convert(PickerData)), 309 | hideHeader: true, 310 | title: Text("Select Data"), 311 | selectedTextStyle: TextStyle(color: Colors.blue), 312 | onConfirm: (Picker picker, List value) { 313 | print(value.toString()); 314 | print(picker.getSelectedValues()); 315 | }).showDialog(context); 316 | } 317 | 318 | showPickerArray(BuildContext context) { 319 | Picker( 320 | adapter: PickerDataAdapter( 321 | pickerData: JsonDecoder().convert(PickerData2), 322 | isArray: true, 323 | ), 324 | hideHeader: true, 325 | selecteds: [3, 0, 2], 326 | title: Text("Please Select"), 327 | selectedTextStyle: TextStyle(color: Colors.blue), 328 | cancel: TextButton( 329 | onPressed: () { 330 | Navigator.pop(context); 331 | }, 332 | child: Icon(Icons.child_care)), 333 | onConfirm: (Picker picker, List value) { 334 | print(value.toString()); 335 | print(picker.getSelectedValues()); 336 | }).showDialog(context); 337 | } 338 | 339 | showPickerNumber(BuildContext context) { 340 | Picker( 341 | adapter: NumberPickerAdapter(data: [ 342 | NumberPickerColumn( 343 | begin: 0, 344 | end: 999, 345 | postfix: Text("\$"), 346 | suffix: Icon(Icons.insert_emoticon)), 347 | NumberPickerColumn(begin: 200, end: 100, jump: -10), 348 | ]), 349 | delimiter: [ 350 | PickerDelimiter( 351 | child: Container( 352 | width: 30.0, 353 | alignment: Alignment.center, 354 | child: Icon(Icons.more_vert), 355 | )) 356 | ], 357 | hideHeader: true, 358 | title: Text("Please Select"), 359 | selectedTextStyle: TextStyle(color: Colors.blue), 360 | onConfirm: (Picker picker, List value) { 361 | print(value.toString()); 362 | print(picker.getSelectedValues()); 363 | }).showDialog(context); 364 | } 365 | 366 | showPickerNumberFormatValue(BuildContext context) { 367 | Picker( 368 | adapter: NumberPickerAdapter(data: [ 369 | NumberPickerColumn( 370 | begin: 0, 371 | end: 999, 372 | onFormatValue: (v) { 373 | return v < 10 ? "0$v" : "$v"; 374 | }), 375 | NumberPickerColumn(begin: 100, end: 200), 376 | ]), 377 | delimiter: [ 378 | PickerDelimiter( 379 | child: Container( 380 | width: 30.0, 381 | alignment: Alignment.center, 382 | child: Icon(Icons.more_vert), 383 | )) 384 | ], 385 | hideHeader: true, 386 | title: Text("Please Select"), 387 | selectedTextStyle: TextStyle(color: Colors.blue), 388 | onConfirm: (Picker picker, List value) { 389 | print(value.toString()); 390 | print(picker.getSelectedValues()); 391 | }).showDialog(context); 392 | } 393 | 394 | showPickerDate(BuildContext context) { 395 | Picker( 396 | hideHeader: true, 397 | adapter: DateTimePickerAdapter(), 398 | title: Text("Select Data"), 399 | selectedTextStyle: TextStyle(color: Colors.blue), 400 | onConfirm: (Picker picker, List value) { 401 | print((picker.adapter as DateTimePickerAdapter).value); 402 | }).showDialog(context); 403 | } 404 | 405 | showPickerDateCustom(BuildContext context) { 406 | Picker( 407 | hideHeader: true, 408 | adapter: DateTimePickerAdapter( 409 | customColumnType: [2, 1, 0, 3, 4], 410 | ), 411 | title: Text("Select Data"), 412 | selectedTextStyle: TextStyle(color: Colors.blue), 413 | onConfirm: (Picker picker, List value) { 414 | print((picker.adapter as DateTimePickerAdapter).value); 415 | }).showDialog(context); 416 | } 417 | 418 | showPickerDateTime(BuildContext context) { 419 | Picker( 420 | adapter: DateTimePickerAdapter( 421 | type: PickerDateTimeType.kMDYHM_AP, 422 | isNumberMonth: true, 423 | //strAMPM: const["上午", "下午"], 424 | yearSuffix: "年", 425 | monthSuffix: "月", 426 | daySuffix: "日", 427 | hourSuffix: "時", 428 | minuteSuffix: "分", 429 | secondSuffix: "秒", 430 | minValue: DateTime.now(), 431 | minuteInterval: 30, 432 | //value: DateTime.tryParse("2026-01-29 00:00:00.000"), 433 | //minHour: 1, 434 | //maxHour: 23, 435 | // twoDigitYear: true, 436 | ), 437 | title: Text("Select DateTime"), 438 | textAlign: TextAlign.right, 439 | // selectedTextStyle: TextStyle(color: Colors.blue), 440 | delimiter: [ 441 | PickerDelimiter( 442 | column: 5, 443 | child: Container( 444 | width: 16.0, 445 | alignment: Alignment.center, 446 | child: Text(':', style: TextStyle(fontWeight: FontWeight.bold)), 447 | )) 448 | ], 449 | footer: Container( 450 | height: 50.0, 451 | alignment: Alignment.center, 452 | child: Text('Footer'), 453 | ), 454 | onConfirm: (Picker picker, List value) { 455 | print(picker.adapter.text); 456 | }, 457 | onSelect: (Picker picker, int index, List selected) { 458 | setState(() { 459 | stateText = picker.adapter.toString(); 460 | }); 461 | }).showBottomSheet(context); 462 | } 463 | 464 | showPickerDateRange(BuildContext context) { 465 | print("canceltext: ${PickerLocalizations.of(context).cancelText}"); 466 | 467 | Picker ps = Picker( 468 | hideHeader: true, 469 | adapter: DateTimePickerAdapter( 470 | type: PickerDateTimeType.kYMD, isNumberMonth: true), 471 | onConfirm: (Picker picker, List value) { 472 | print((picker.adapter as DateTimePickerAdapter).value); 473 | }); 474 | 475 | Picker pe = Picker( 476 | hideHeader: true, 477 | adapter: DateTimePickerAdapter(type: PickerDateTimeType.kYMD), 478 | onConfirm: (Picker picker, List value) { 479 | print((picker.adapter as DateTimePickerAdapter).value); 480 | }); 481 | 482 | List actions = [ 483 | TextButton( 484 | onPressed: () { 485 | Navigator.pop(context); 486 | }, 487 | child: Text(PickerLocalizations.of(context).cancelText ?? '')), 488 | TextButton( 489 | onPressed: () { 490 | Navigator.pop(context); 491 | ps.onConfirm?.call(ps, ps.selecteds); 492 | pe.onConfirm?.call(pe, pe.selecteds); 493 | }, 494 | child: Text(PickerLocalizations.of(context).confirmText ?? '')) 495 | ]; 496 | 497 | showDialog( 498 | context: context, 499 | builder: (BuildContext context) { 500 | return AlertDialog( 501 | title: Text("Select Date Range"), 502 | actions: actions, 503 | content: Container( 504 | child: Column( 505 | crossAxisAlignment: CrossAxisAlignment.start, 506 | mainAxisSize: MainAxisSize.min, 507 | children: [ 508 | Text("Begin:"), 509 | ps.makePicker(), 510 | Text("End:"), 511 | pe.makePicker() 512 | ], 513 | ), 514 | ), 515 | ); 516 | }); 517 | } 518 | 519 | showPickerDateTime24(BuildContext context) { 520 | Picker( 521 | adapter: DateTimePickerAdapter( 522 | type: PickerDateTimeType.kMDYHM, 523 | isNumberMonth: true, 524 | yearSuffix: "年", 525 | monthSuffix: "月", 526 | daySuffix: "日", 527 | hourSuffix: "時", 528 | minuteSuffix: "分", 529 | secondSuffix: "秒", 530 | minHour: 8, 531 | maxHour: 19, 532 | yearBegin: 1950, 533 | yearEnd: 1998, 534 | ), 535 | title: Text("Select DateTime"), 536 | onConfirm: (Picker picker, List value) { 537 | print(picker.adapter.text); 538 | }, 539 | onSelect: (Picker picker, int index, List selected) { 540 | showMsg(picker.adapter.toString()); 541 | }).showBottomSheet(context); 542 | } 543 | 544 | /// 圆角背景 545 | showPickerDateTimeRoundBg(BuildContext context) { 546 | var picker = Picker( 547 | backgroundColor: Colors.transparent, 548 | headerDecoration: BoxDecoration( 549 | border: 550 | Border(bottom: BorderSide(color: Colors.black12, width: 0.5))), 551 | adapter: DateTimePickerAdapter( 552 | type: PickerDateTimeType.kMDYHM, 553 | isNumberMonth: true, 554 | yearSuffix: "年", 555 | monthSuffix: "月", 556 | daySuffix: "日"), 557 | delimiter: [ 558 | PickerDelimiter( 559 | column: 3, 560 | child: Container( 561 | width: 8.0, 562 | alignment: Alignment.center, 563 | )), 564 | PickerDelimiter( 565 | column: 5, 566 | child: Container( 567 | width: 12.0, 568 | alignment: Alignment.center, 569 | child: Text(':', style: TextStyle(fontWeight: FontWeight.bold)), 570 | )), 571 | ], 572 | title: Text("Select DateTime"), 573 | onConfirm: (Picker picker, List value) { 574 | print(picker.adapter.text); 575 | }, 576 | onSelect: (Picker picker, int index, List selected) { 577 | showMsg(picker.adapter.toString()); 578 | }); 579 | picker.showModal(context, backgroundColor: Colors.transparent, 580 | builder: (context, view) { 581 | return Material( 582 | // color: Colors.white, 583 | borderRadius: BorderRadius.only( 584 | topLeft: Radius.circular(10), topRight: Radius.circular(10)), 585 | child: Container( 586 | padding: const EdgeInsets.only(top: 4), 587 | child: view, 588 | )); 589 | }); 590 | } 591 | 592 | /// 使用 onBuilderItem 方法 593 | showPickerCustomBuilder(BuildContext context) { 594 | Picker( 595 | hideHeader: true, 596 | adapter: DateTimePickerAdapter( 597 | customColumnType: [2, 1, 0, 3, 4], 598 | ), 599 | title: Text("Select Data"), 600 | selectedTextStyle: TextStyle(color: Colors.blue), 601 | onBuilderItem: (context, text, child, selected, col, index) { 602 | if (col == 0 || selected) return null; 603 | return Text(text ?? '', 604 | style: TextStyle( 605 | color: Colors.green, 606 | )); 607 | }, 608 | onConfirm: (Picker picker, List value) { 609 | print((picker.adapter as DateTimePickerAdapter).value); 610 | }).showDialog(context); 611 | } 612 | 613 | /// 自定义UI效果 614 | showPickerCustomizeUI(BuildContext context) { 615 | final itemExtent = 42.0; 616 | final bgColor = Colors.greenAccent.shade700; 617 | final txtColor = Colors.white; 618 | final txtStyle = TextStyle(color: txtColor); 619 | final selectColor = Colors.black.withOpacity(0.20); 620 | final delimiterChild = Align( 621 | alignment: Alignment.center, 622 | child: Container(width: 50, height: itemExtent, color: selectColor), 623 | ); 624 | Picker( 625 | itemExtent: itemExtent, 626 | backgroundColor: Colors.transparent, 627 | containerColor: bgColor, 628 | selectionOverlay: Container(height: itemExtent, color: selectColor), 629 | headerDecoration: BoxDecoration(color: Colors.black.withOpacity(0.05)), 630 | textStyle: txtStyle, 631 | cancelTextStyle: txtStyle, 632 | confirmTextStyle: txtStyle, 633 | selectedTextStyle: TextStyle(color: txtColor, fontSize: 20), 634 | adapter: DateTimePickerAdapter(type: PickerDateTimeType.kHM), 635 | delimiter: [ 636 | PickerDelimiter(column: 0, child: delimiterChild), 637 | PickerDelimiter( 638 | column: 2, 639 | child: Align( 640 | alignment: Alignment.center, 641 | child: Container( 642 | width: 15, 643 | height: itemExtent, 644 | color: selectColor, 645 | alignment: Alignment.center, 646 | child: Text(':', 647 | style: TextStyle( 648 | fontWeight: FontWeight.bold, color: txtColor)), 649 | ), 650 | )), 651 | PickerDelimiter(column: 4, child: delimiterChild), 652 | ], 653 | title: Padding( 654 | padding: const EdgeInsets.fromLTRB(0, 12, 0, 12), 655 | child: Text("Select Time", style: txtStyle), 656 | ), 657 | onConfirm: (Picker picker, List value) { 658 | print(picker.adapter.text); 659 | }).showModal(context, builder: (context, view) { 660 | return Material( 661 | elevation: 0.0, 662 | color: Colors.transparent, 663 | child: Container( 664 | padding: const EdgeInsets.only(top: 0, left: 0, right: 0), 665 | decoration: BoxDecoration( 666 | color: bgColor, 667 | borderRadius: BorderRadius.only( 668 | topLeft: Radius.circular(10), topRight: Radius.circular(10)), 669 | ), 670 | child: view, 671 | )); 672 | }, backgroundColor: Colors.transparent); 673 | } 674 | 675 | showPickerDurationSelect(BuildContext context) { 676 | final range = [ 677 | DateTime(0, 1, 1, 8, 30), 678 | DateTime(0, 1, 1, 14, 30) 679 | ]; 680 | final p1 = Picker( 681 | adapter: DateTimePickerAdapter( 682 | customColumnType: [6, 7, 4], 683 | value: range[0], 684 | ), 685 | delimiter: [ 686 | PickerDelimiter( 687 | column: 0, 688 | child: Container( 689 | alignment: Alignment.center, 690 | width: 100, 691 | padding: EdgeInsets.fromLTRB(12, 0, 8, 0), 692 | child: Text('Start', 693 | style: TextStyle( 694 | fontWeight: FontWeight.bold, 695 | color: Colors.red, 696 | fontSize: 14)), 697 | // color: Colors.white, 698 | )), 699 | ], 700 | onSelect: (Picker picker, int index, List selected) { 701 | range[0] = (picker.adapter as DateTimePickerAdapter).value; 702 | }, 703 | onConfirmBefore: (picker, selected) async { 704 | if (range[0] == null) { 705 | showMsg("Please select the start time."); 706 | return false; 707 | } 708 | if (range[1] == null) { 709 | showMsg("Please select the end time."); 710 | return false; 711 | } 712 | return true; 713 | }, 714 | onConfirm: (picker, selected) { 715 | showMsg( 716 | "Start: ${range[0].toString()}, End: ${range[1].toString()}, ${picker.adapter}"); 717 | }); 718 | final p2 = Picker( 719 | adapter: DateTimePickerAdapter( 720 | customColumnType: [6, 7, 4], 721 | value: range[1], 722 | ), 723 | hideHeader: true, 724 | delimiter: [ 725 | PickerDelimiter( 726 | column: 0, 727 | child: Container( 728 | alignment: Alignment.center, 729 | padding: EdgeInsets.fromLTRB(12, 0, 8, 0), 730 | width: 100, 731 | child: Text('End', 732 | style: TextStyle( 733 | fontWeight: FontWeight.bold, 734 | color: Colors.red, 735 | fontSize: 14)), 736 | // color: Colors.white, 737 | )), 738 | ], 739 | onSelect: (Picker picker, int index, List selected) { 740 | range[1] = (picker.adapter as DateTimePickerAdapter).value; 741 | }); 742 | showBottomSheet( 743 | context: context, 744 | builder: (BuildContext context) { 745 | return Column( 746 | mainAxisSize: MainAxisSize.min, 747 | children: [p1.makePicker(), p2.makePicker()], 748 | ); 749 | }); 750 | } 751 | 752 | showPickerSelectYear(BuildContext context) { 753 | Picker( 754 | adapter: DateTimePickerAdapter( 755 | type: PickerDateTimeType.kY, 756 | yearSuffix: "年", 757 | yearBegin: 1950, 758 | yearEnd: 2025, 759 | ), 760 | title: Text("Select Year"), 761 | onConfirm: (Picker picker, List value) { 762 | print(picker.adapter.text); 763 | }, 764 | onSelect: (Picker picker, int index, List selected) { 765 | print(picker.adapter.toString()); 766 | }).showBottomSheet(context); 767 | } 768 | } 769 | -------------------------------------------------------------------------------- /example/lib/picker_data.dart: -------------------------------------------------------------------------------- 1 | const PickerData = ''' 2 | [ 3 | { 4 | "a": [ 5 | { 6 | "a1": [ 7 | 1, 8 | 2, 9 | 3, 10 | 4 11 | ] 12 | }, 13 | { 14 | "a2": [ 15 | 5, 16 | 6, 17 | 7, 18 | 8, 19 | 555, 20 | 666, 21 | 999 22 | ] 23 | }, 24 | { 25 | "a3": [ 26 | 9, 27 | 10, 28 | 11, 29 | 12 30 | ] 31 | } 32 | ] 33 | }, 34 | { 35 | "b": [ 36 | { 37 | "b1": [ 38 | 11, 39 | 22, 40 | 33, 41 | 44 42 | ] 43 | }, 44 | { 45 | "b2": [ 46 | 55, 47 | 66, 48 | 77, 49 | 88, 50 | 99, 51 | 1010, 52 | 1111, 53 | 1212, 54 | 1313, 55 | 1414, 56 | 1515, 57 | 1616 58 | ] 59 | }, 60 | { 61 | "b3": [ 62 | 1010, 63 | 1111, 64 | 1212, 65 | 1313, 66 | 1414, 67 | 1515, 68 | 1616 69 | ] 70 | } 71 | ] 72 | }, 73 | { 74 | "c": [ 75 | { 76 | "c1": [ 77 | "a", 78 | "b", 79 | "c" 80 | ] 81 | }, 82 | { 83 | "c2": [ 84 | "aa", 85 | "bb", 86 | "cc" 87 | ] 88 | }, 89 | { 90 | "c3": [ 91 | "aaa", 92 | "bbb", 93 | "ccc" 94 | ] 95 | }, 96 | { 97 | "c4": [ 98 | "a1", 99 | "b1", 100 | "c1", 101 | "d1" 102 | ] 103 | } 104 | ] 105 | } 106 | ] 107 | '''; 108 | 109 | const PickerData2 = ''' 110 | [ 111 | [ 112 | 1, 113 | 2, 114 | 3, 115 | 4 116 | ], 117 | [ 118 | 11, 119 | 22, 120 | 33, 121 | 44 122 | ], 123 | [ 124 | "aaa", 125 | "bbb", 126 | "ccc" 127 | ] 128 | ] 129 | '''; -------------------------------------------------------------------------------- /example/lib/picker_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | class RawPickerTest extends StatefulWidget { 5 | const RawPickerTest({Key? key}) : super(key: key); 6 | 7 | @override 8 | State createState() => _RawPickerTestState(); 9 | } 10 | 11 | class _RawPickerTestState extends State { 12 | @override 13 | Widget build(BuildContext context) { 14 | return Scaffold( 15 | appBar: AppBar(title: Text('Test Raw Picker')), 16 | body: Column( 17 | mainAxisSize: MainAxisSize.min, 18 | children: [ 19 | SizedBox(height: 50), 20 | SizedBox( 21 | height: 320, 22 | child: Row( 23 | children: [ 24 | Expanded(child: _buildCupertinoPicker(context, 0, 20, ValueKey(0))), 25 | Expanded(child: _buildCupertinoPicker(context, 1, 120, ValueKey(1))), 26 | Expanded(child: _buildCupertinoPicker(context, 2, 50, ValueKey(2))), 27 | ], 28 | ), 29 | ) 30 | ], 31 | ), 32 | ); 33 | } 34 | 35 | Widget _buildCupertinoPicker(BuildContext context, 36 | int i, int _length, Key? key) { 37 | return CupertinoPicker.builder( 38 | key: key, 39 | scrollController: FixedExtentScrollController(), 40 | itemExtent: 42, 41 | selectionOverlay: const CupertinoPickerDefaultSelectionOverlay(), 42 | childCount: _length, 43 | itemBuilder: (context, index) { 44 | return Text("$i.$index"); 45 | }, 46 | onSelectedItemChanged: (int _index) { 47 | if (_length <= 0) return; 48 | var index = _index % _length; 49 | print("onSelectedItemChanged. col: $i, row: $index"); 50 | }, 51 | ); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_picker_example 2 | description: Demonstrates how to use the flutter_picker plugin. 3 | 4 | # The following defines the version and build number for your application. 5 | # A version number is three numbers separated by dots, like 1.2.43 6 | # followed by an optional build number separated by a +. 7 | # Both the version and the builder number may be overridden in flutter 8 | # build by specifying --build-name and --build-number, respectively. 9 | # Read more about versioning at semver.org. 10 | version: 1.0.0+1 11 | 12 | environment: 13 | sdk: '>=2.12.0 <3.0.0' 14 | 15 | dependencies: 16 | flutter: 17 | sdk: flutter 18 | 19 | flutter_localizations: 20 | sdk: flutter 21 | 22 | # intl: 0.18.0 23 | 24 | # The following adds the Cupertino Icons font to your application. 25 | # Use with the CupertinoIcons class for iOS style icons. 26 | cupertino_icons: ^1.0.5 27 | 28 | dev_dependencies: 29 | flutter_test: 30 | sdk: flutter 31 | 32 | flutter_picker: 33 | path: ../ 34 | 35 | # For information on the generic Dart part of this file, see the 36 | # following page: https://www.dartlang.org/tools/pub/pubspec 37 | 38 | # The following section is specific to Flutter. 39 | flutter: 40 | 41 | # The following line ensures that the Material Icons font is 42 | # included with your application, so that you can use the icons in 43 | # the material Icons class. 44 | uses-material-design: true 45 | 46 | # To add assets to your application, add an assets section, like this: 47 | # assets: 48 | # - images/a_dot_burr.jpeg 49 | # - images/a_dot_ham.jpeg 50 | 51 | # An image asset can refer to one or more resolution-specific "variants", see 52 | # https://flutter.io/assets-and-images/#resolution-aware. 53 | 54 | # For details regarding adding assets from package dependencies, see 55 | # https://flutter.io/assets-and-images/#from-packages 56 | 57 | # To add custom fonts to your application, add a fonts section here, 58 | # in this "flutter" section. Each entry in this list should have a 59 | # "family" key with the font family name, and a "fonts" key with a 60 | # list giving the asset and other descriptors for the font. For 61 | # example: 62 | # fonts: 63 | # - family: Schyler 64 | # fonts: 65 | # - asset: fonts/Schyler-Regular.ttf 66 | # - asset: fonts/Schyler-Italic.ttf 67 | # style: italic 68 | # - family: Trajan Pro 69 | # fonts: 70 | # - asset: fonts/TrajanPro.ttf 71 | # - asset: fonts/TrajanPro_Bold.ttf 72 | # weight: 700 73 | # 74 | # For details regarding fonts from package dependencies, 75 | # see https://flutter.io/custom-fonts/#from-packages 76 | -------------------------------------------------------------------------------- /example/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangyxd/flutter_picker/c47b3d53e94cee651d82e6feac0fa3c3ec8d63bc/example/web/favicon.png -------------------------------------------------------------------------------- /example/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangyxd/flutter_picker/c47b3d53e94cee651d82e6feac0fa3c3ec8d63bc/example/web/icons/Icon-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangyxd/flutter_picker/c47b3d53e94cee651d82e6feac0fa3c3ec8d63bc/example/web/icons/Icon-512.png -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangyxd/flutter_picker/c47b3d53e94cee651d82e6feac0fa3c3ec8d63bc/example/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangyxd/flutter_picker/c47b3d53e94cee651d82e6feac0fa3c3ec8d63bc/example/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /example/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | example 33 | 34 | 35 | 39 | 40 | 41 | 42 | 43 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /example/web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "short_name": "example", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "A new Flutter project.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /example/windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /example/windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15) 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.15) 2 | 3 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 4 | 5 | # Configuration provided via flutter tool. 6 | include(${EPHEMERAL_DIR}/generated_config.cmake) 7 | 8 | # TODO: Move the rest of this into files in ephemeral. See 9 | # https://github.com/flutter/flutter/issues/57146. 10 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 11 | 12 | # === Flutter Library === 13 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 14 | 15 | # Published to parent scope for install step. 16 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 17 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 18 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 19 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 20 | 21 | list(APPEND FLUTTER_LIBRARY_HEADERS 22 | "flutter_export.h" 23 | "flutter_windows.h" 24 | "flutter_messenger.h" 25 | "flutter_plugin_registrar.h" 26 | "flutter_texture_registrar.h" 27 | ) 28 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 29 | add_library(flutter INTERFACE) 30 | target_include_directories(flutter INTERFACE 31 | "${EPHEMERAL_DIR}" 32 | ) 33 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 34 | add_dependencies(flutter flutter_assemble) 35 | 36 | # === Wrapper === 37 | list(APPEND CPP_WRAPPER_SOURCES_CORE 38 | "core_implementations.cc" 39 | "standard_codec.cc" 40 | ) 41 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 42 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 43 | "plugin_registrar.cc" 44 | ) 45 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 46 | list(APPEND CPP_WRAPPER_SOURCES_APP 47 | "flutter_engine.cc" 48 | "flutter_view_controller.cc" 49 | ) 50 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 51 | 52 | # Wrapper sources needed for a plugin. 53 | add_library(flutter_wrapper_plugin STATIC 54 | ${CPP_WRAPPER_SOURCES_CORE} 55 | ${CPP_WRAPPER_SOURCES_PLUGIN} 56 | ) 57 | apply_standard_settings(flutter_wrapper_plugin) 58 | set_target_properties(flutter_wrapper_plugin PROPERTIES 59 | POSITION_INDEPENDENT_CODE ON) 60 | set_target_properties(flutter_wrapper_plugin PROPERTIES 61 | CXX_VISIBILITY_PRESET hidden) 62 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 63 | target_include_directories(flutter_wrapper_plugin PUBLIC 64 | "${WRAPPER_ROOT}/include" 65 | ) 66 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 67 | 68 | # Wrapper sources needed for the runner. 69 | add_library(flutter_wrapper_app STATIC 70 | ${CPP_WRAPPER_SOURCES_CORE} 71 | ${CPP_WRAPPER_SOURCES_APP} 72 | ) 73 | apply_standard_settings(flutter_wrapper_app) 74 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 75 | target_include_directories(flutter_wrapper_app PUBLIC 76 | "${WRAPPER_ROOT}/include" 77 | ) 78 | add_dependencies(flutter_wrapper_app flutter_assemble) 79 | 80 | # === Flutter tool backend === 81 | # _phony_ is a non-existent file to force this command to run every time, 82 | # since currently there's no way to get a full input/output list from the 83 | # flutter tool. 84 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 85 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 86 | add_custom_command( 87 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 88 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 89 | ${CPP_WRAPPER_SOURCES_APP} 90 | ${PHONY_OUTPUT} 91 | COMMAND ${CMAKE_COMMAND} -E env 92 | ${FLUTTER_TOOL_ENVIRONMENT} 93 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 94 | windows-x64 $ 95 | VERBATIM 96 | ) 97 | add_custom_target(flutter_assemble DEPENDS 98 | "${FLUTTER_LIBRARY}" 99 | ${FLUTTER_LIBRARY_HEADERS} 100 | ${CPP_WRAPPER_SOURCES_CORE} 101 | ${CPP_WRAPPER_SOURCES_PLUGIN} 102 | ${CPP_WRAPPER_SOURCES_APP} 103 | ) 104 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | 10 | void RegisterPlugins(flutter::PluginRegistry* registry) { 11 | } 12 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | ) 7 | 8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 9 | ) 10 | 11 | set(PLUGIN_BUNDLED_LIBRARIES) 12 | 13 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 18 | endforeach(plugin) 19 | 20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 23 | endforeach(ffi_plugin) 24 | -------------------------------------------------------------------------------- /example/windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15) 2 | project(runner LANGUAGES CXX) 3 | 4 | add_executable(${BINARY_NAME} WIN32 5 | "flutter_window.cpp" 6 | "main.cpp" 7 | "run_loop.cpp" 8 | "utils.cpp" 9 | "win32_window.cpp" 10 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 11 | "Runner.rc" 12 | "runner.exe.manifest" 13 | ) 14 | apply_standard_settings(${BINARY_NAME}) 15 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 16 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 17 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 18 | add_dependencies(${BINARY_NAME} flutter_assemble) 19 | -------------------------------------------------------------------------------- /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.yangyxd" "\0" 93 | VALUE "FileDescription", "A new Flutter project." "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "example" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2021 com.yangyxd. 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(RunLoop* run_loop, 8 | const flutter::DartProject& project) 9 | : run_loop_(run_loop), project_(project) {} 10 | 11 | FlutterWindow::~FlutterWindow() {} 12 | 13 | bool FlutterWindow::OnCreate() { 14 | if (!Win32Window::OnCreate()) { 15 | return false; 16 | } 17 | 18 | RECT frame = GetClientArea(); 19 | 20 | // The size here must match the window dimensions to avoid unnecessary surface 21 | // creation / destruction in the startup path. 22 | flutter_controller_ = std::make_unique( 23 | frame.right - frame.left, frame.bottom - frame.top, project_); 24 | // Ensure that basic setup of the controller was successful. 25 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 26 | return false; 27 | } 28 | RegisterPlugins(flutter_controller_->engine()); 29 | run_loop_->RegisterFlutterInstance(flutter_controller_->engine()); 30 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 31 | return true; 32 | } 33 | 34 | void FlutterWindow::OnDestroy() { 35 | if (flutter_controller_) { 36 | run_loop_->UnregisterFlutterInstance(flutter_controller_->engine()); 37 | flutter_controller_ = nullptr; 38 | } 39 | 40 | Win32Window::OnDestroy(); 41 | } 42 | 43 | LRESULT 44 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 45 | WPARAM const wparam, 46 | LPARAM const lparam) noexcept { 47 | // Give Flutter, including plugins, an opporutunity to handle window messages. 48 | if (flutter_controller_) { 49 | std::optional result = 50 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 51 | lparam); 52 | if (result) { 53 | return *result; 54 | } 55 | } 56 | 57 | switch (message) { 58 | case WM_FONTCHANGE: 59 | flutter_controller_->engine()->ReloadSystemFonts(); 60 | break; 61 | } 62 | 63 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 64 | } 65 | -------------------------------------------------------------------------------- /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 "run_loop.h" 10 | #include "win32_window.h" 11 | 12 | // A window that does nothing but host a Flutter view. 13 | class FlutterWindow : public Win32Window { 14 | public: 15 | // Creates a new FlutterWindow driven by the |run_loop|, hosting a 16 | // Flutter view running |project|. 17 | explicit FlutterWindow(RunLoop* run_loop, 18 | const flutter::DartProject& project); 19 | virtual ~FlutterWindow(); 20 | 21 | protected: 22 | // Win32Window: 23 | bool OnCreate() override; 24 | void OnDestroy() override; 25 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 26 | LPARAM const lparam) noexcept override; 27 | 28 | private: 29 | // The run loop driving events for this window. 30 | RunLoop* run_loop_; 31 | 32 | // The project to run. 33 | flutter::DartProject project_; 34 | 35 | // The Flutter instance hosted by this window. 36 | std::unique_ptr flutter_controller_; 37 | }; 38 | 39 | #endif // RUNNER_FLUTTER_WINDOW_H_ 40 | -------------------------------------------------------------------------------- /example/windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "run_loop.h" 7 | #include "utils.h" 8 | 9 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 10 | _In_ wchar_t *command_line, _In_ int show_command) { 11 | // Attach to console when present (e.g., 'flutter run') or create a 12 | // new console when running with a debugger. 13 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 14 | CreateAndAttachConsole(); 15 | } 16 | 17 | // Initialize COM, so that it is available for use in the library and/or 18 | // plugins. 19 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 20 | 21 | RunLoop run_loop; 22 | 23 | flutter::DartProject project(L"data"); 24 | 25 | std::vector command_line_arguments = 26 | GetCommandLineArguments(); 27 | 28 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 29 | 30 | FlutterWindow window(&run_loop, project); 31 | Win32Window::Point origin(10, 10); 32 | Win32Window::Size size(1280, 720); 33 | if (!window.CreateAndShow(L"example", origin, size)) { 34 | return EXIT_FAILURE; 35 | } 36 | window.SetQuitOnClose(true); 37 | 38 | run_loop.Run(); 39 | 40 | ::CoUninitialize(); 41 | return EXIT_SUCCESS; 42 | } 43 | -------------------------------------------------------------------------------- /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/yangyxd/flutter_picker/c47b3d53e94cee651d82e6feac0fa3c3ec8d63bc/example/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /example/windows/runner/run_loop.cpp: -------------------------------------------------------------------------------- 1 | #include "run_loop.h" 2 | 3 | #include 4 | 5 | #include 6 | 7 | RunLoop::RunLoop() {} 8 | 9 | RunLoop::~RunLoop() {} 10 | 11 | void RunLoop::Run() { 12 | bool keep_running = true; 13 | TimePoint next_flutter_event_time = TimePoint::clock::now(); 14 | while (keep_running) { 15 | std::chrono::nanoseconds wait_duration = 16 | std::max(std::chrono::nanoseconds(0), 17 | next_flutter_event_time - TimePoint::clock::now()); 18 | ::MsgWaitForMultipleObjects( 19 | 0, nullptr, FALSE, static_cast(wait_duration.count() / 1000), 20 | QS_ALLINPUT); 21 | bool processed_events = false; 22 | MSG message; 23 | // All pending Windows messages must be processed; MsgWaitForMultipleObjects 24 | // won't return again for items left in the queue after PeekMessage. 25 | while (::PeekMessage(&message, nullptr, 0, 0, PM_REMOVE)) { 26 | processed_events = true; 27 | if (message.message == WM_QUIT) { 28 | keep_running = false; 29 | break; 30 | } 31 | ::TranslateMessage(&message); 32 | ::DispatchMessage(&message); 33 | // Allow Flutter to process messages each time a Windows message is 34 | // processed, to prevent starvation. 35 | next_flutter_event_time = 36 | std::min(next_flutter_event_time, ProcessFlutterMessages()); 37 | } 38 | // If the PeekMessage loop didn't run, process Flutter messages. 39 | if (!processed_events) { 40 | next_flutter_event_time = 41 | std::min(next_flutter_event_time, ProcessFlutterMessages()); 42 | } 43 | } 44 | } 45 | 46 | void RunLoop::RegisterFlutterInstance( 47 | flutter::FlutterEngine* flutter_instance) { 48 | flutter_instances_.insert(flutter_instance); 49 | } 50 | 51 | void RunLoop::UnregisterFlutterInstance( 52 | flutter::FlutterEngine* flutter_instance) { 53 | flutter_instances_.erase(flutter_instance); 54 | } 55 | 56 | RunLoop::TimePoint RunLoop::ProcessFlutterMessages() { 57 | TimePoint next_event_time = TimePoint::max(); 58 | for (auto instance : flutter_instances_) { 59 | std::chrono::nanoseconds wait_duration = instance->ProcessMessages(); 60 | if (wait_duration != std::chrono::nanoseconds::max()) { 61 | next_event_time = 62 | std::min(next_event_time, TimePoint::clock::now() + wait_duration); 63 | } 64 | } 65 | return next_event_time; 66 | } 67 | -------------------------------------------------------------------------------- /example/windows/runner/run_loop.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_RUN_LOOP_H_ 2 | #define RUNNER_RUN_LOOP_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | // A runloop that will service events for Flutter instances as well 10 | // as native messages. 11 | class RunLoop { 12 | public: 13 | RunLoop(); 14 | ~RunLoop(); 15 | 16 | // Prevent copying 17 | RunLoop(RunLoop const&) = delete; 18 | RunLoop& operator=(RunLoop const&) = delete; 19 | 20 | // Runs the run loop until the application quits. 21 | void Run(); 22 | 23 | // Registers the given Flutter instance for event servicing. 24 | void RegisterFlutterInstance( 25 | flutter::FlutterEngine* flutter_instance); 26 | 27 | // Unregisters the given Flutter instance from event servicing. 28 | void UnregisterFlutterInstance( 29 | flutter::FlutterEngine* flutter_instance); 30 | 31 | private: 32 | using TimePoint = std::chrono::steady_clock::time_point; 33 | 34 | // Processes all currently pending messages for registered Flutter instances. 35 | TimePoint ProcessFlutterMessages(); 36 | 37 | std::set flutter_instances_; 38 | }; 39 | 40 | #endif // RUNNER_RUN_LOOP_H_ 41 | -------------------------------------------------------------------------------- /example/windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /example/windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr); 51 | if (target_length == 0) { 52 | return std::string(); 53 | } 54 | std::string utf8_string; 55 | utf8_string.resize(target_length); 56 | int converted_length = ::WideCharToMultiByte( 57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 58 | -1, utf8_string.data(), 59 | target_length, nullptr, nullptr); 60 | if (converted_length == 0) { 61 | return std::string(); 62 | } 63 | return utf8_string; 64 | } 65 | -------------------------------------------------------------------------------- /example/windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /example/windows/runner/win32_window.cpp: -------------------------------------------------------------------------------- 1 | #include "win32_window.h" 2 | 3 | #include 4 | 5 | #include "resource.h" 6 | 7 | namespace { 8 | 9 | constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; 10 | 11 | // The number of Win32Window objects that currently exist. 12 | static int g_active_window_count = 0; 13 | 14 | using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); 15 | 16 | // Scale helper to convert logical scaler values to physical using passed in 17 | // scale factor 18 | int Scale(int source, double scale_factor) { 19 | return static_cast(source * scale_factor); 20 | } 21 | 22 | // Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. 23 | // This API is only needed for PerMonitor V1 awareness mode. 24 | void EnableFullDpiSupportIfAvailable(HWND hwnd) { 25 | HMODULE user32_module = LoadLibraryA("User32.dll"); 26 | if (!user32_module) { 27 | return; 28 | } 29 | auto enable_non_client_dpi_scaling = 30 | reinterpret_cast( 31 | GetProcAddress(user32_module, "EnableNonClientDpiScaling")); 32 | if (enable_non_client_dpi_scaling != nullptr) { 33 | enable_non_client_dpi_scaling(hwnd); 34 | FreeLibrary(user32_module); 35 | } 36 | } 37 | 38 | } // namespace 39 | 40 | // Manages the Win32Window's window class registration. 41 | class WindowClassRegistrar { 42 | public: 43 | ~WindowClassRegistrar() = default; 44 | 45 | // Returns the singleton registar instance. 46 | static WindowClassRegistrar* GetInstance() { 47 | if (!instance_) { 48 | instance_ = new WindowClassRegistrar(); 49 | } 50 | return instance_; 51 | } 52 | 53 | // Returns the name of the window class, registering the class if it hasn't 54 | // previously been registered. 55 | const wchar_t* GetWindowClass(); 56 | 57 | // Unregisters the window class. Should only be called if there are no 58 | // instances of the window. 59 | void UnregisterWindowClass(); 60 | 61 | private: 62 | WindowClassRegistrar() = default; 63 | 64 | static WindowClassRegistrar* instance_; 65 | 66 | bool class_registered_ = false; 67 | }; 68 | 69 | WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; 70 | 71 | const wchar_t* WindowClassRegistrar::GetWindowClass() { 72 | if (!class_registered_) { 73 | WNDCLASS window_class{}; 74 | window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); 75 | window_class.lpszClassName = kWindowClassName; 76 | window_class.style = CS_HREDRAW | CS_VREDRAW; 77 | window_class.cbClsExtra = 0; 78 | window_class.cbWndExtra = 0; 79 | window_class.hInstance = GetModuleHandle(nullptr); 80 | window_class.hIcon = 81 | LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); 82 | window_class.hbrBackground = 0; 83 | window_class.lpszMenuName = nullptr; 84 | window_class.lpfnWndProc = Win32Window::WndProc; 85 | RegisterClass(&window_class); 86 | class_registered_ = true; 87 | } 88 | return kWindowClassName; 89 | } 90 | 91 | void WindowClassRegistrar::UnregisterWindowClass() { 92 | UnregisterClass(kWindowClassName, nullptr); 93 | class_registered_ = false; 94 | } 95 | 96 | Win32Window::Win32Window() { 97 | ++g_active_window_count; 98 | } 99 | 100 | Win32Window::~Win32Window() { 101 | --g_active_window_count; 102 | Destroy(); 103 | } 104 | 105 | bool Win32Window::CreateAndShow(const std::wstring& title, 106 | const Point& origin, 107 | const Size& size) { 108 | Destroy(); 109 | 110 | const wchar_t* window_class = 111 | WindowClassRegistrar::GetInstance()->GetWindowClass(); 112 | 113 | const POINT target_point = {static_cast(origin.x), 114 | static_cast(origin.y)}; 115 | HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); 116 | UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); 117 | double scale_factor = dpi / 96.0; 118 | 119 | HWND window = CreateWindow( 120 | window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE, 121 | Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), 122 | Scale(size.width, scale_factor), Scale(size.height, scale_factor), 123 | nullptr, nullptr, GetModuleHandle(nullptr), this); 124 | 125 | if (!window) { 126 | return false; 127 | } 128 | 129 | return OnCreate(); 130 | } 131 | 132 | // static 133 | LRESULT CALLBACK Win32Window::WndProc(HWND const window, 134 | UINT const message, 135 | WPARAM const wparam, 136 | LPARAM const lparam) noexcept { 137 | if (message == WM_NCCREATE) { 138 | auto window_struct = reinterpret_cast(lparam); 139 | SetWindowLongPtr(window, GWLP_USERDATA, 140 | reinterpret_cast(window_struct->lpCreateParams)); 141 | 142 | auto that = static_cast(window_struct->lpCreateParams); 143 | EnableFullDpiSupportIfAvailable(window); 144 | that->window_handle_ = window; 145 | } else if (Win32Window* that = GetThisFromHandle(window)) { 146 | return that->MessageHandler(window, message, wparam, lparam); 147 | } 148 | 149 | return DefWindowProc(window, message, wparam, lparam); 150 | } 151 | 152 | LRESULT 153 | Win32Window::MessageHandler(HWND hwnd, 154 | UINT const message, 155 | WPARAM const wparam, 156 | LPARAM const lparam) noexcept { 157 | switch (message) { 158 | case WM_DESTROY: 159 | window_handle_ = nullptr; 160 | Destroy(); 161 | if (quit_on_close_) { 162 | PostQuitMessage(0); 163 | } 164 | return 0; 165 | 166 | case WM_DPICHANGED: { 167 | auto newRectSize = reinterpret_cast(lparam); 168 | LONG newWidth = newRectSize->right - newRectSize->left; 169 | LONG newHeight = newRectSize->bottom - newRectSize->top; 170 | 171 | SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, 172 | newHeight, SWP_NOZORDER | SWP_NOACTIVATE); 173 | 174 | return 0; 175 | } 176 | case WM_SIZE: { 177 | RECT rect = GetClientArea(); 178 | if (child_content_ != nullptr) { 179 | // Size and position the child window. 180 | MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, 181 | rect.bottom - rect.top, TRUE); 182 | } 183 | return 0; 184 | } 185 | 186 | case WM_ACTIVATE: 187 | if (child_content_ != nullptr) { 188 | SetFocus(child_content_); 189 | } 190 | return 0; 191 | } 192 | 193 | return DefWindowProc(window_handle_, message, wparam, lparam); 194 | } 195 | 196 | void Win32Window::Destroy() { 197 | OnDestroy(); 198 | 199 | if (window_handle_) { 200 | DestroyWindow(window_handle_); 201 | window_handle_ = nullptr; 202 | } 203 | if (g_active_window_count == 0) { 204 | WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); 205 | } 206 | } 207 | 208 | Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { 209 | return reinterpret_cast( 210 | GetWindowLongPtr(window, GWLP_USERDATA)); 211 | } 212 | 213 | void Win32Window::SetChildContent(HWND content) { 214 | child_content_ = content; 215 | SetParent(content, window_handle_); 216 | RECT frame = GetClientArea(); 217 | 218 | MoveWindow(content, frame.left, frame.top, frame.right - frame.left, 219 | frame.bottom - frame.top, true); 220 | 221 | SetFocus(child_content_); 222 | } 223 | 224 | RECT Win32Window::GetClientArea() { 225 | RECT frame; 226 | GetClientRect(window_handle_, &frame); 227 | return frame; 228 | } 229 | 230 | HWND Win32Window::GetHandle() { 231 | return window_handle_; 232 | } 233 | 234 | void Win32Window::SetQuitOnClose(bool quit_on_close) { 235 | quit_on_close_ = quit_on_close; 236 | } 237 | 238 | bool Win32Window::OnCreate() { 239 | // No-op; provided for subclasses. 240 | return true; 241 | } 242 | 243 | void Win32Window::OnDestroy() { 244 | // No-op; provided for subclasses. 245 | } 246 | -------------------------------------------------------------------------------- /example/windows/runner/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates and shows a win32 window with |title| and position and size using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size to will treat the width height passed in to this function 35 | // as logical pixels and scale to appropriate for the default monitor. Returns 36 | // true if the window was created successfully. 37 | bool CreateAndShow(const std::wstring& title, 38 | const Point& origin, 39 | const Size& size); 40 | 41 | // Release OS resources associated with window. 42 | void Destroy(); 43 | 44 | // Inserts |content| into the window tree. 45 | void SetChildContent(HWND content); 46 | 47 | // Returns the backing Window handle to enable clients to set icon and other 48 | // window properties. Returns nullptr if the window has been destroyed. 49 | HWND GetHandle(); 50 | 51 | // If true, closing this window will quit the application. 52 | void SetQuitOnClose(bool quit_on_close); 53 | 54 | // Return a RECT representing the bounds of the current client area. 55 | RECT GetClientArea(); 56 | 57 | protected: 58 | // Processes and route salient window messages for mouse handling, 59 | // size change and DPI. Delegates handling of these to member overloads that 60 | // inheriting classes can handle. 61 | virtual LRESULT MessageHandler(HWND window, 62 | UINT const message, 63 | WPARAM const wparam, 64 | LPARAM const lparam) noexcept; 65 | 66 | // Called when CreateAndShow is called, allowing subclass window-related 67 | // setup. Subclasses should return false if setup fails. 68 | virtual bool OnCreate(); 69 | 70 | // Called when Destroy is called. 71 | virtual void OnDestroy(); 72 | 73 | private: 74 | friend class WindowClassRegistrar; 75 | 76 | // OS callback called by message pump. Handles the WM_NCCREATE message which 77 | // is passed when the non-client area is being created and enables automatic 78 | // non-client DPI scaling so that the non-client area automatically 79 | // responsponds to changes in DPI. All other messages are handled by 80 | // MessageHandler. 81 | static LRESULT CALLBACK WndProc(HWND const window, 82 | UINT const message, 83 | WPARAM const wparam, 84 | LPARAM const lparam) noexcept; 85 | 86 | // Retrieves a class instance pointer for |window| 87 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 88 | 89 | bool quit_on_close_ = false; 90 | 91 | // window handle for top level window. 92 | HWND window_handle_ = nullptr; 93 | 94 | // window handle for hosted content. 95 | HWND child_content_ = nullptr; 96 | }; 97 | 98 | #endif // RUNNER_WIN32_WINDOW_H_ 99 | -------------------------------------------------------------------------------- /flutter_picker.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /lib/flutter_picker.dart: -------------------------------------------------------------------------------- 1 | export 'picker.dart'; 2 | export 'picker_localizations.dart'; 3 | export 'picker_localizations_delegate.dart'; 4 | -------------------------------------------------------------------------------- /lib/picker_localizations.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | abstract class PickerLocalizationsBase { 4 | final Locale? locale; 5 | const PickerLocalizationsBase(this.locale); 6 | Object? getItem(String key); 7 | String? get cancelText => getItem('cancelText') as String; 8 | String? get confirmText => getItem('confirmText') as String; 9 | List? get ampm => getItem('ampm') as List; 10 | List? get months => getItem('months') as List; 11 | List? get monthsLong => getItem('monthsLong') as List; 12 | } 13 | 14 | /// localizations 15 | class PickerLocalizations extends PickerLocalizationsBase { 16 | static PickerLocalizations _static = PickerLocalizations(null); 17 | const PickerLocalizations(Locale? locale) : super(locale); 18 | 19 | @override 20 | Object? getItem(String key) { 21 | Map? localData; 22 | if (locale != null) { 23 | localData = localizedValues[locale!.languageCode]; 24 | } 25 | if (localData == null) return localizedValues['en']![key]; 26 | return localData[key]; 27 | } 28 | 29 | static PickerLocalizations of(BuildContext context) { 30 | return Localizations.of( 31 | context, PickerLocalizations) ?? 32 | _static; 33 | } 34 | 35 | /// 注册自定义语言 36 | /// 37 | /// Register custom language 38 | static registerCustomLanguage(String name, 39 | {String? cancelText, 40 | String? confirmText, 41 | List? ampm, 42 | List? months, 43 | List? monthsLong}) { 44 | if (name.isEmpty) return; 45 | if (ampm != null && ampm.length != 2) { 46 | throw Exception('ampm array length must be 2'); 47 | } 48 | if (months != null && months.length != 12) { 49 | throw Exception('months array length must be 12'); 50 | } 51 | if (monthsLong != null && monthsLong.length != 12) { 52 | throw Exception('monthsLong array length must be 12'); 53 | } 54 | if (!languages.contains(name)) { 55 | languages.add(name); 56 | } 57 | final _defaultValue = localizedValues['en']!; 58 | final data = { 59 | 'cancelText': cancelText ?? _defaultValue['cancelText'] as String, 60 | 'confirmText': cancelText ?? _defaultValue['confirmText'] as String, 61 | 'ampm': ampm ?? _defaultValue['ampm'] as List, 62 | }; 63 | if (months != null) { 64 | data['months'] = months; 65 | } 66 | if (monthsLong != null) { 67 | data['monthsLong'] = monthsLong; 68 | } 69 | localizedValues[name] = data; 70 | } 71 | 72 | /// Language Support 73 | static const List languages = [ 74 | 'en', 75 | 'ja', 76 | 'zh', 77 | 'ko', 78 | 'it', 79 | 'ar', 80 | 'fr', 81 | 'es', 82 | 'tr', 83 | 'ro' 84 | ]; 85 | 86 | /// Language Values 87 | static const Map> localizedValues = { 88 | 'en': { 89 | 'cancelText': 'Cancel', 90 | 'confirmText': 'Confirm', 91 | 'ampm': ['AM', 'PM'], 92 | }, 93 | 'ja': { 94 | 'cancelText': 'キャンセル', 95 | 'confirmText': '完了', 96 | 'ampm': ['午前', '午後'], 97 | }, 98 | 'zh': { 99 | 'cancelText': '取消', 100 | 'confirmText': '确定', 101 | 'ampm': ['上午', '下午'], 102 | }, 103 | 'ko': { 104 | 'cancelText': '취소', 105 | 'confirmText': '확인', 106 | 'ampm': ['오전', '오후'], 107 | }, 108 | 'it': { 109 | 'cancelText': 'Annulla', 110 | 'confirmText': 'Conferma', 111 | 'ampm': ['AM', 'PM'], 112 | }, 113 | 'ar': { 114 | 'cancelText': 'إلغاء الأمر', 115 | 'confirmText': 'تأكيد', 116 | 'ampm': ['صباحاً', 'مساءً'], 117 | }, 118 | 'fr': { 119 | 'cancelText': 'Annuler', 120 | 'confirmText': 'Confirmer', 121 | 'ampm': ['Matin', 'Après-midi'], 122 | }, 123 | 'es': { 124 | 'cancelText': 'Cancelar', 125 | 'confirmText': 'Confirmar', 126 | 'ampm': ['AM', 'PM'], 127 | }, 128 | 'tr': { 129 | 'cancelText': 'İptal', 130 | 'confirmText': 'Onay', 131 | 'ampm': ['ÖÖ', 'ÖS'], 132 | 'months': [ 133 | 'Oca', 134 | 'Şub', 135 | 'Mar', 136 | 'Nis', 137 | 'May', 138 | 'Haz', 139 | 'Tem', 140 | 'Ağu', 141 | 'Eyl', 142 | 'Eki', 143 | 'Kas', 144 | 'Ara' 145 | ], 146 | 'monthsLong': [ 147 | 'Ocak', 148 | 'Şubat', 149 | 'Mart', 150 | 'Nisan', 151 | 'Mayıs', 152 | 'Haziran', 153 | 'Temmuz', 154 | 'Ağustos', 155 | 'Eylül', 156 | 'Ekim', 157 | 'Kasım', 158 | 'Aralık' 159 | ], 160 | }, 161 | 'ro': { 162 | 'cancelText': 'Anulează', 163 | 'confirmText': 'Confirmă', 164 | 'ampm': ['AM', 'PM'], 165 | 'months': [ 166 | 'Ian', 167 | 'Feb', 168 | 'Mart', 169 | 'Apr', 170 | 'Mai', 171 | 'Iun', 172 | 'Iul', 173 | 'Aug', 174 | 'Sept', 175 | 'Oct', 176 | 'Nov', 177 | 'Dec', 178 | ], 179 | 'monthsLong': [ 180 | 'Ianuarie', 181 | 'Februarie', 182 | 'Martie', 183 | 'Aprilie', 184 | 'Mai', 185 | 'Iunie', 186 | 'Iulie', 187 | 'August', 188 | 'Septembrie', 189 | 'Octombrie', 190 | 'Noiembrie', 191 | 'Decembrie', 192 | ], 193 | } 194 | }; 195 | } 196 | -------------------------------------------------------------------------------- /lib/picker_localizations_delegate.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'dart:async'; 4 | import 'picker_localizations.dart'; 5 | 6 | /// picker localizations 7 | class PickerLocalizationsDelegate 8 | extends LocalizationsDelegate { 9 | const PickerLocalizationsDelegate(); 10 | 11 | static const PickerLocalizationsDelegate delegate = 12 | const PickerLocalizationsDelegate(); 13 | 14 | @override 15 | bool isSupported(Locale locale) => 16 | PickerLocalizations.languages.contains(locale.languageCode); 17 | 18 | @override 19 | Future load(Locale locale) { 20 | return SynchronousFuture( 21 | new PickerLocalizations(locale)); 22 | } 23 | 24 | @override 25 | bool shouldReload(PickerLocalizationsDelegate old) => false; 26 | } 27 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_picker 2 | description: Flutter plugin picker. Include NumberPicker, DateTimePicker, ArrayPicker, and default linkage Picker. Provide flexible parameters to meet various needs. 3 | version: 2.1.1 4 | homepage: https://github.com/yangyxd/flutter_picker 5 | 6 | environment: 7 | sdk: ">=2.12.0 <3.0.0" 8 | flutter: ">=1.17.0" 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | 14 | dev_dependencies: 15 | flutter_test: 16 | sdk: flutter 17 | 18 | flutter: 19 | color: theme!.accentColor 20 | -------------------------------------------------------------------------------- /raw/views.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangyxd/flutter_picker/c47b3d53e94cee651d82e6feac0fa3c3ec8d63bc/raw/views.gif -------------------------------------------------------------------------------- /test/flutter_picker_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_test/flutter_test.dart'; 2 | // import 'package:flutter_picker/flutter_picker.dart'; 3 | 4 | void main() { 5 | 6 | test('adds one to input values', () { 7 | final v = null as List; 8 | print(v); 9 | expect(v, null); 10 | // final calculator = Calculator(); 11 | // expect(calculator.addOne(2), 3); 12 | // expect(calculator.addOne(-7), -6); 13 | // expect(calculator.addOne(0), 1); 14 | // expect(() => calculator.addOne(null), throwsNoSuchMethodError); 15 | }); 16 | 17 | } 18 | --------------------------------------------------------------------------------