├── .gitignore ├── .metadata ├── CHANGELOG.md ├── LICENSE ├── README.md ├── doc └── images │ └── date_time_picker.gif ├── example ├── .gitignore ├── .metadata ├── README.md ├── android │ ├── .gitignore │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── kotlin │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── example │ │ │ │ │ └── MainActivity.kt │ │ │ └── res │ │ │ │ ├── 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 │ │ │ │ └── styles.xml │ │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── settings.gradle ├── ios │ ├── .gitignore │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ └── Release.xcconfig │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ │ └── WorkspaceSettings.xcsettings │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ └── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ ├── Icon-App-20x20@1x.png │ │ │ ├── Icon-App-20x20@2x.png │ │ │ ├── Icon-App-20x20@3x.png │ │ │ ├── Icon-App-29x29@1x.png │ │ │ ├── Icon-App-29x29@2x.png │ │ │ ├── Icon-App-29x29@3x.png │ │ │ ├── Icon-App-40x40@1x.png │ │ │ ├── Icon-App-40x40@2x.png │ │ │ ├── Icon-App-40x40@3x.png │ │ │ ├── Icon-App-60x60@2x.png │ │ │ ├── Icon-App-60x60@3x.png │ │ │ ├── Icon-App-76x76@1x.png │ │ │ ├── Icon-App-76x76@2x.png │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ └── LaunchImage.imageset │ │ │ ├── Contents.json │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ └── README.md │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── Runner-Bridging-Header.h ├── lib │ └── main.dart └── pubspec.yaml ├── lib └── date_time_picker.dart ├── pubspec.yaml └── test └── date_time_picker_test.dart /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | .vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | .dart_tool/ 26 | .flutter-plugins 27 | .flutter-plugins-dependencies 28 | .packages 29 | .pub-cache/ 30 | .pub/ 31 | build/ 32 | pubspec.lock 33 | 34 | # Android related 35 | **/android/**/gradle-wrapper.jar 36 | **/android/.gradle 37 | **/android/captures/ 38 | **/android/gradlew 39 | **/android/gradlew.bat 40 | **/android/local.properties 41 | **/android/**/GeneratedPluginRegistrant.java 42 | 43 | # iOS/XCode related 44 | **/ios/**/*.mode1v3 45 | **/ios/**/*.mode2v3 46 | **/ios/**/*.moved-aside 47 | **/ios/**/*.pbxuser 48 | **/ios/**/*.perspectivev3 49 | **/ios/**/*sync/ 50 | **/ios/**/.sconsign.dblite 51 | **/ios/**/.tags* 52 | **/ios/**/.vagrant/ 53 | **/ios/**/DerivedData/ 54 | **/ios/**/Icon? 55 | **/ios/**/Pods/ 56 | **/ios/**/.symlinks/ 57 | **/ios/**/profile 58 | **/ios/**/xcuserdata 59 | **/ios/.generated/ 60 | **/ios/Flutter/App.framework 61 | **/ios/Flutter/Flutter.framework 62 | **/ios/Flutter/Flutter.podspec 63 | **/ios/Flutter/Generated.xcconfig 64 | **/ios/Flutter/app.flx 65 | **/ios/Flutter/app.zip 66 | **/ios/Flutter/flutter_assets/ 67 | **/ios/Flutter/flutter_export_environment.sh 68 | **/ios/ServiceDefinitions.json 69 | **/ios/Runner/GeneratedPluginRegistrant.* 70 | 71 | # Exceptions to above rules. 72 | !**/ios/**/default.mode1v3 73 | !**/ios/**/default.mode2v3 74 | !**/ios/**/default.pbxuser 75 | !**/ios/**/default.perspectivev3 76 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 77 | -------------------------------------------------------------------------------- /.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: 8af6b2f038c1172e61d418869363a28dffec3cb4 8 | channel: stable 9 | 10 | project_type: package 11 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 2.1.0 - 2021-07-08 2 | 3 | * Fixed 12h display format. 4 | * Fixed field cleaning. 5 | * Added a new parameter (timePickerEntryModeInput) to set timepicker mode, dial or input. 6 | 7 | ## 2.0.0 - 2021-03-09 8 | 9 | * Migrate to null safety. 10 | * Update SDK constraints to >=2.12.0 <3.0.0 based on beta release guidelines. 11 | * Updata intl version dependency. 12 | * Add 2 optional params, initialDate and initialTime to set date picker and time picker to show date and time diferent of now, when initialValue is empty. 13 | 14 | ## 1.1.1 - 2020-12-29 15 | 16 | * Removing flutter_localizations dependency. 17 | 18 | ## 1.1.0 - 2020-11-12 19 | 20 | * Improved use of the local parameter to define DateTimePicker directly. 21 | 22 | ## 1.0.2 - 2020-09-21 23 | 24 | * Fix issue #4 - fixed the time display when period is 12h. Now it can differ correctly when time is AM or PM and show this information. 25 | 26 | ## 1.0.1 - 2020-08-18 27 | 28 | * Fix issue #2 - just reference in README.md. 29 | * Fix issue #3 - filling the time field when press Ok button on time picker dialog without select a specific time, getting the current time showed. 30 | * Fix problems when initialValue is empty. 31 | 32 | ## 1.0.0 - 2020-07-22 33 | 34 | * Initial Open Source release. 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014-2020, Humberto Lourenço . 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the 14 | distribution. 15 | 16 | * Neither the name of Humberto Lourenço nor the names of his 17 | contributors may be used to endorse or promote products derived 18 | from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 30 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # date_time_picker 2 | 3 | [![pub package](https://img.shields.io/pub/v/date_time_picker.svg)](https://pub.dartlang.org/packages/date_time_picker) 4 | 5 | Buy Me A Beer 6 | 7 | A Flutter widget to show a text form field to display a date or clock dialog.\ 8 | This widget extend TextField and has a similar behavior as TextFormField 9 | 10 | ## Usage 11 | 12 | In the `pubspec.yaml` of your flutter project, add the following dependency: 13 | 14 | ```yaml 15 | dependencies: 16 | ... 17 | date_time_picker: "^2.1.0" 18 | ``` 19 | 20 | In your library add the following import: 21 | 22 | ```dart 23 | import 'package:date_time_picker/date_time_picker.dart'; 24 | ``` 25 | 26 | For help getting started with Flutter, view the online [documentation](https://flutter.io/). 27 | 28 | ## Example 29 | 30 | There are four presentations for DateTimePicker and can be defined in the type parameter: 31 | * `DateTimePickerType.date` will present a text field with the action tap showing a datePicker dialog box; 32 | * `DateTimePickerType.time` will present a text field with the action tap showing a timePicker dialog box; 33 | * `DateTimePickerType.dateTime` will present a text field with the action tap showing a datePicker dialog box then a timePicker dialog box; 34 | * `DateTimePickerType.dateTimeSeparated` will display two text fields side by side, the first for date and the second for time. Each displaying their respective dialog box, datePicker and timePicker in the tap action; 35 | 36 | ``` dart 37 | DateTimePicker( 38 | type: date, // options: [date | time | dateTime | dateTimeSeparated], default is date 39 | ... 40 | ) 41 | ``` 42 | 43 | initialValue or controller.text can be `null`, `empty` or a `DateTime string` otherwise it will throw an error. 44 | 45 | ``` dart 46 | DateTimePicker( 47 | initialValue: '', 48 | firstDate: DateTime(2000), 49 | lastDate: DateTime(2100), 50 | dateLabelText: 'Date', 51 | onChanged: (val) => print(val), 52 | validator: (val) { 53 | print(val); 54 | return null; 55 | }, 56 | onSaved: (val) => print(val), 57 | ); 58 | ``` 59 | 60 | More complete example: 61 | 62 | 63 | ``` dart 64 | DateTimePicker( 65 | type: DateTimePickerType.dateTimeSeparate, 66 | dateMask: 'd MMM, yyyy', 67 | initialValue: DateTime.now().toString(), 68 | firstDate: DateTime(2000), 69 | lastDate: DateTime(2100), 70 | icon: Icon(Icons.event), 71 | dateLabelText: 'Date', 72 | timeLabelText: "Hour", 73 | selectableDayPredicate: (date) { 74 | // Disable weekend days to select from the calendar 75 | if (date.weekday == 6 || date.weekday == 7) { 76 | return false; 77 | } 78 | 79 | return true; 80 | }, 81 | onChanged: (val) => print(val), 82 | validator: (val) { 83 | print(val); 84 | return null; 85 | }, 86 | onSaved: (val) => print(val), 87 | ); 88 | ``` 89 | 90 | The result of val in `onChanged`, `validator` and `onSaved` will be a DateTime String or just a Time String: 91 | * ex.: [2020-07-20 14:30] or [15:30] DateTimePickerType.time; 92 | * month, day, hour and minute will be 2 digits and time always be in 24 hours mode; 93 | * but the presentation in text field can be formated by the dateMask parameter. 94 | 95 | 96 | ## Preview 97 | ![Overview](https://raw.githubusercontent.com/m3uzz/date_time_picker/master/doc/images/date_time_picker.gif) -------------------------------------------------------------------------------- /doc/images/date_time_picker.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m3uzz/date_time_picker/824b4a14bc72ae3a1e1cba09aaa6f43e915d1d15/doc/images/date_time_picker.gif -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | .vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | .dart_tool/ 26 | .flutter-plugins 27 | .flutter-plugins-dependencies 28 | .packages 29 | .pub-cache/ 30 | .pub/ 31 | build/ 32 | pubspec.lock 33 | 34 | 35 | # Web related 36 | lib/generated_plugin_registrant.dart 37 | 38 | # Symbolication related 39 | app.*.symbols 40 | 41 | # Obfuscation related 42 | app.*.map.json 43 | 44 | # Exceptions to above rules. 45 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 46 | -------------------------------------------------------------------------------- /example/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: 8af6b2f038c1172e61d418869363a28dffec3cb4 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # example 2 | 3 | A new Flutter project. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) 13 | 14 | For help getting started with Flutter, view our 15 | [online documentation](https://flutter.dev/docs), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /example/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | -------------------------------------------------------------------------------- /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 28 30 | 31 | sourceSets { 32 | main.java.srcDirs += 'src/main/kotlin' 33 | } 34 | 35 | lintOptions { 36 | disable 'InvalidPackage' 37 | } 38 | 39 | defaultConfig { 40 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 41 | applicationId "com.example.example" 42 | minSdkVersion 16 43 | targetSdkVersion 28 44 | versionCode flutterVersionCode.toInteger() 45 | versionName flutterVersionName 46 | } 47 | 48 | buildTypes { 49 | release { 50 | // TODO: Add your own signing config for the release build. 51 | // Signing with the debug keys for now, so `flutter run --release` works. 52 | signingConfig signingConfigs.debug 53 | } 54 | } 55 | } 56 | 57 | flutter { 58 | source '../..' 59 | } 60 | 61 | dependencies { 62 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 63 | } 64 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 8 | 12 | 19 | 23 | 27 | 32 | 36 | 37 | 38 | 39 | 40 | 41 | 43 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /example/android/app/src/main/kotlin/com/example/example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.example 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/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/m3uzz/date_time_picker/824b4a14bc72ae3a1e1cba09aaa6f43e915d1d15/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/m3uzz/date_time_picker/824b4a14bc72ae3a1e1cba09aaa6f43e915d1d15/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/m3uzz/date_time_picker/824b4a14bc72ae3a1e1cba09aaa6f43e915d1d15/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/m3uzz/date_time_picker/824b4a14bc72ae3a1e1cba09aaa6f43e915d1d15/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/m3uzz/date_time_picker/824b4a14bc72ae3a1e1cba09aaa6f43e915d1d15/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /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 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.3.50' 3 | repositories { 4 | google() 5 | jcenter() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.5.0' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | jcenter() 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.enableR8=true 3 | android.useAndroidX=true 4 | android.enableJetifier=true 5 | -------------------------------------------------------------------------------- /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-5.6.2-all.zip 7 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | include ':app' 6 | 7 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 8 | def properties = new Properties() 9 | 10 | assert localPropertiesFile.exists() 11 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 12 | 13 | def flutterSdkPath = properties.getProperty("flutter.sdk") 14 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 15 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 16 | -------------------------------------------------------------------------------- /example/ios/.gitignore: -------------------------------------------------------------------------------- 1 | *.mode1v3 2 | *.mode2v3 3 | *.moved-aside 4 | *.pbxuser 5 | *.perspectivev3 6 | **/*sync/ 7 | .sconsign.dblite 8 | .tags* 9 | **/.vagrant/ 10 | **/DerivedData/ 11 | Icon? 12 | **/Pods/ 13 | **/.symlinks/ 14 | profile 15 | xcuserdata 16 | **/.generated/ 17 | Flutter/App.framework 18 | Flutter/Flutter.framework 19 | Flutter/Flutter.podspec 20 | Flutter/Generated.xcconfig 21 | Flutter/app.flx 22 | Flutter/app.zip 23 | Flutter/flutter_assets/ 24 | Flutter/flutter_export_environment.sh 25 | ServiceDefinitions.json 26 | Runner/GeneratedPluginRegistrant.* 27 | 28 | # Exceptions to above rules. 29 | !default.mode1v3 30 | !default.mode2v3 31 | !default.pbxuser 32 | !default.perspectivev3 33 | -------------------------------------------------------------------------------- /example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 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 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 12 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 13 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 14 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 15 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXCopyFilesBuildPhase section */ 19 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = { 20 | isa = PBXCopyFilesBuildPhase; 21 | buildActionMask = 2147483647; 22 | dstPath = ""; 23 | dstSubfolderSpec = 10; 24 | files = ( 25 | ); 26 | name = "Embed Frameworks"; 27 | runOnlyForDeploymentPostprocessing = 0; 28 | }; 29 | /* End PBXCopyFilesBuildPhase section */ 30 | 31 | /* Begin PBXFileReference section */ 32 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 33 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 34 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 35 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 36 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 37 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 38 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 39 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 40 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 41 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 42 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 43 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 44 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 45 | /* End PBXFileReference section */ 46 | 47 | /* Begin PBXFrameworksBuildPhase section */ 48 | 97C146EB1CF9000F007C117D /* Frameworks */ = { 49 | isa = PBXFrameworksBuildPhase; 50 | buildActionMask = 2147483647; 51 | files = ( 52 | ); 53 | runOnlyForDeploymentPostprocessing = 0; 54 | }; 55 | /* End PBXFrameworksBuildPhase section */ 56 | 57 | /* Begin PBXGroup section */ 58 | 9740EEB11CF90186004384FC /* Flutter */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 62 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 63 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 64 | 9740EEB31CF90195004384FC /* Generated.xcconfig */, 65 | ); 66 | name = Flutter; 67 | sourceTree = ""; 68 | }; 69 | 97C146E51CF9000F007C117D = { 70 | isa = PBXGroup; 71 | children = ( 72 | 9740EEB11CF90186004384FC /* Flutter */, 73 | 97C146F01CF9000F007C117D /* Runner */, 74 | 97C146EF1CF9000F007C117D /* Products */, 75 | ); 76 | sourceTree = ""; 77 | }; 78 | 97C146EF1CF9000F007C117D /* Products */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | 97C146EE1CF9000F007C117D /* Runner.app */, 82 | ); 83 | name = Products; 84 | sourceTree = ""; 85 | }; 86 | 97C146F01CF9000F007C117D /* Runner */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | 97C146FA1CF9000F007C117D /* Main.storyboard */, 90 | 97C146FD1CF9000F007C117D /* Assets.xcassets */, 91 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 92 | 97C147021CF9000F007C117D /* Info.plist */, 93 | 97C146F11CF9000F007C117D /* Supporting Files */, 94 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 95 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 96 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, 97 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, 98 | ); 99 | path = Runner; 100 | sourceTree = ""; 101 | }; 102 | 97C146F11CF9000F007C117D /* Supporting Files */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | ); 106 | name = "Supporting Files"; 107 | sourceTree = ""; 108 | }; 109 | /* End PBXGroup section */ 110 | 111 | /* Begin PBXNativeTarget section */ 112 | 97C146ED1CF9000F007C117D /* Runner */ = { 113 | isa = PBXNativeTarget; 114 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; 115 | buildPhases = ( 116 | 9740EEB61CF901F6004384FC /* Run Script */, 117 | 97C146EA1CF9000F007C117D /* Sources */, 118 | 97C146EB1CF9000F007C117D /* Frameworks */, 119 | 97C146EC1CF9000F007C117D /* Resources */, 120 | 9705A1C41CF9048500538489 /* Embed Frameworks */, 121 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 122 | ); 123 | buildRules = ( 124 | ); 125 | dependencies = ( 126 | ); 127 | name = Runner; 128 | productName = Runner; 129 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */; 130 | productType = "com.apple.product-type.application"; 131 | }; 132 | /* End PBXNativeTarget section */ 133 | 134 | /* Begin PBXProject section */ 135 | 97C146E61CF9000F007C117D /* Project object */ = { 136 | isa = PBXProject; 137 | attributes = { 138 | LastUpgradeCheck = 1020; 139 | ORGANIZATIONNAME = ""; 140 | TargetAttributes = { 141 | 97C146ED1CF9000F007C117D = { 142 | CreatedOnToolsVersion = 7.3.1; 143 | LastSwiftMigration = 1100; 144 | }; 145 | }; 146 | }; 147 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; 148 | compatibilityVersion = "Xcode 9.3"; 149 | developmentRegion = en; 150 | hasScannedForEncodings = 0; 151 | knownRegions = ( 152 | en, 153 | Base, 154 | ); 155 | mainGroup = 97C146E51CF9000F007C117D; 156 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */; 157 | projectDirPath = ""; 158 | projectRoot = ""; 159 | targets = ( 160 | 97C146ED1CF9000F007C117D /* Runner */, 161 | ); 162 | }; 163 | /* End PBXProject section */ 164 | 165 | /* Begin PBXResourcesBuildPhase section */ 166 | 97C146EC1CF9000F007C117D /* Resources */ = { 167 | isa = PBXResourcesBuildPhase; 168 | buildActionMask = 2147483647; 169 | files = ( 170 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 171 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 172 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 173 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 174 | ); 175 | runOnlyForDeploymentPostprocessing = 0; 176 | }; 177 | /* End PBXResourcesBuildPhase section */ 178 | 179 | /* Begin PBXShellScriptBuildPhase section */ 180 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 181 | isa = PBXShellScriptBuildPhase; 182 | buildActionMask = 2147483647; 183 | files = ( 184 | ); 185 | inputPaths = ( 186 | ); 187 | name = "Thin Binary"; 188 | outputPaths = ( 189 | ); 190 | runOnlyForDeploymentPostprocessing = 0; 191 | shellPath = /bin/sh; 192 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; 193 | }; 194 | 9740EEB61CF901F6004384FC /* Run Script */ = { 195 | isa = PBXShellScriptBuildPhase; 196 | buildActionMask = 2147483647; 197 | files = ( 198 | ); 199 | inputPaths = ( 200 | ); 201 | name = "Run Script"; 202 | outputPaths = ( 203 | ); 204 | runOnlyForDeploymentPostprocessing = 0; 205 | shellPath = /bin/sh; 206 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 207 | }; 208 | /* End PBXShellScriptBuildPhase section */ 209 | 210 | /* Begin PBXSourcesBuildPhase section */ 211 | 97C146EA1CF9000F007C117D /* Sources */ = { 212 | isa = PBXSourcesBuildPhase; 213 | buildActionMask = 2147483647; 214 | files = ( 215 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, 216 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 217 | ); 218 | runOnlyForDeploymentPostprocessing = 0; 219 | }; 220 | /* End PBXSourcesBuildPhase section */ 221 | 222 | /* Begin PBXVariantGroup section */ 223 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = { 224 | isa = PBXVariantGroup; 225 | children = ( 226 | 97C146FB1CF9000F007C117D /* Base */, 227 | ); 228 | name = Main.storyboard; 229 | sourceTree = ""; 230 | }; 231 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { 232 | isa = PBXVariantGroup; 233 | children = ( 234 | 97C147001CF9000F007C117D /* Base */, 235 | ); 236 | name = LaunchScreen.storyboard; 237 | sourceTree = ""; 238 | }; 239 | /* End PBXVariantGroup section */ 240 | 241 | /* Begin XCBuildConfiguration section */ 242 | 249021D3217E4FDB00AE95B9 /* Profile */ = { 243 | isa = XCBuildConfiguration; 244 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 245 | buildSettings = { 246 | ALWAYS_SEARCH_USER_PATHS = NO; 247 | CLANG_ANALYZER_NONNULL = YES; 248 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 249 | CLANG_CXX_LIBRARY = "libc++"; 250 | CLANG_ENABLE_MODULES = YES; 251 | CLANG_ENABLE_OBJC_ARC = YES; 252 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 253 | CLANG_WARN_BOOL_CONVERSION = YES; 254 | CLANG_WARN_COMMA = YES; 255 | CLANG_WARN_CONSTANT_CONVERSION = YES; 256 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 257 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 258 | CLANG_WARN_EMPTY_BODY = YES; 259 | CLANG_WARN_ENUM_CONVERSION = YES; 260 | CLANG_WARN_INFINITE_RECURSION = YES; 261 | CLANG_WARN_INT_CONVERSION = YES; 262 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 263 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 264 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 265 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 266 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 267 | CLANG_WARN_STRICT_PROTOTYPES = YES; 268 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 269 | CLANG_WARN_UNREACHABLE_CODE = YES; 270 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 271 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 272 | COPY_PHASE_STRIP = NO; 273 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 274 | ENABLE_NS_ASSERTIONS = NO; 275 | ENABLE_STRICT_OBJC_MSGSEND = YES; 276 | GCC_C_LANGUAGE_STANDARD = gnu99; 277 | GCC_NO_COMMON_BLOCKS = YES; 278 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 279 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 280 | GCC_WARN_UNDECLARED_SELECTOR = YES; 281 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 282 | GCC_WARN_UNUSED_FUNCTION = YES; 283 | GCC_WARN_UNUSED_VARIABLE = YES; 284 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 285 | MTL_ENABLE_DEBUG_INFO = NO; 286 | SDKROOT = iphoneos; 287 | SUPPORTED_PLATFORMS = iphoneos; 288 | TARGETED_DEVICE_FAMILY = "1,2"; 289 | VALIDATE_PRODUCT = YES; 290 | }; 291 | name = Profile; 292 | }; 293 | 249021D4217E4FDB00AE95B9 /* Profile */ = { 294 | isa = XCBuildConfiguration; 295 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 296 | buildSettings = { 297 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 298 | CLANG_ENABLE_MODULES = YES; 299 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 300 | ENABLE_BITCODE = NO; 301 | FRAMEWORK_SEARCH_PATHS = ( 302 | "$(inherited)", 303 | "$(PROJECT_DIR)/Flutter", 304 | ); 305 | INFOPLIST_FILE = Runner/Info.plist; 306 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 307 | LIBRARY_SEARCH_PATHS = ( 308 | "$(inherited)", 309 | "$(PROJECT_DIR)/Flutter", 310 | ); 311 | PRODUCT_BUNDLE_IDENTIFIER = com.example.example; 312 | PRODUCT_NAME = "$(TARGET_NAME)"; 313 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 314 | SWIFT_VERSION = 5.0; 315 | VERSIONING_SYSTEM = "apple-generic"; 316 | }; 317 | name = Profile; 318 | }; 319 | 97C147031CF9000F007C117D /* Debug */ = { 320 | isa = XCBuildConfiguration; 321 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 322 | buildSettings = { 323 | ALWAYS_SEARCH_USER_PATHS = NO; 324 | CLANG_ANALYZER_NONNULL = YES; 325 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 326 | CLANG_CXX_LIBRARY = "libc++"; 327 | CLANG_ENABLE_MODULES = YES; 328 | CLANG_ENABLE_OBJC_ARC = YES; 329 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 330 | CLANG_WARN_BOOL_CONVERSION = YES; 331 | CLANG_WARN_COMMA = YES; 332 | CLANG_WARN_CONSTANT_CONVERSION = YES; 333 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = 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_IMPLICIT_RETAIN_SELF = YES; 341 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 342 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 343 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 344 | CLANG_WARN_STRICT_PROTOTYPES = YES; 345 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 346 | CLANG_WARN_UNREACHABLE_CODE = YES; 347 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 348 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 349 | COPY_PHASE_STRIP = NO; 350 | DEBUG_INFORMATION_FORMAT = dwarf; 351 | ENABLE_STRICT_OBJC_MSGSEND = YES; 352 | ENABLE_TESTABILITY = YES; 353 | GCC_C_LANGUAGE_STANDARD = gnu99; 354 | GCC_DYNAMIC_NO_PIC = NO; 355 | GCC_NO_COMMON_BLOCKS = YES; 356 | GCC_OPTIMIZATION_LEVEL = 0; 357 | GCC_PREPROCESSOR_DEFINITIONS = ( 358 | "DEBUG=1", 359 | "$(inherited)", 360 | ); 361 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 362 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 363 | GCC_WARN_UNDECLARED_SELECTOR = YES; 364 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 365 | GCC_WARN_UNUSED_FUNCTION = YES; 366 | GCC_WARN_UNUSED_VARIABLE = YES; 367 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 368 | MTL_ENABLE_DEBUG_INFO = YES; 369 | ONLY_ACTIVE_ARCH = YES; 370 | SDKROOT = iphoneos; 371 | TARGETED_DEVICE_FAMILY = "1,2"; 372 | }; 373 | name = Debug; 374 | }; 375 | 97C147041CF9000F007C117D /* Release */ = { 376 | isa = XCBuildConfiguration; 377 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 378 | buildSettings = { 379 | ALWAYS_SEARCH_USER_PATHS = NO; 380 | CLANG_ANALYZER_NONNULL = YES; 381 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 382 | CLANG_CXX_LIBRARY = "libc++"; 383 | CLANG_ENABLE_MODULES = YES; 384 | CLANG_ENABLE_OBJC_ARC = YES; 385 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 386 | CLANG_WARN_BOOL_CONVERSION = YES; 387 | CLANG_WARN_COMMA = YES; 388 | CLANG_WARN_CONSTANT_CONVERSION = YES; 389 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 390 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 391 | CLANG_WARN_EMPTY_BODY = YES; 392 | CLANG_WARN_ENUM_CONVERSION = YES; 393 | CLANG_WARN_INFINITE_RECURSION = YES; 394 | CLANG_WARN_INT_CONVERSION = YES; 395 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 396 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 397 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 398 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 399 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 400 | CLANG_WARN_STRICT_PROTOTYPES = YES; 401 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 402 | CLANG_WARN_UNREACHABLE_CODE = YES; 403 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 404 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 405 | COPY_PHASE_STRIP = NO; 406 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 407 | ENABLE_NS_ASSERTIONS = NO; 408 | ENABLE_STRICT_OBJC_MSGSEND = YES; 409 | GCC_C_LANGUAGE_STANDARD = gnu99; 410 | GCC_NO_COMMON_BLOCKS = YES; 411 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 412 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 413 | GCC_WARN_UNDECLARED_SELECTOR = YES; 414 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 415 | GCC_WARN_UNUSED_FUNCTION = YES; 416 | GCC_WARN_UNUSED_VARIABLE = YES; 417 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 418 | MTL_ENABLE_DEBUG_INFO = NO; 419 | SDKROOT = iphoneos; 420 | SUPPORTED_PLATFORMS = iphoneos; 421 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 422 | TARGETED_DEVICE_FAMILY = "1,2"; 423 | VALIDATE_PRODUCT = YES; 424 | }; 425 | name = Release; 426 | }; 427 | 97C147061CF9000F007C117D /* Debug */ = { 428 | isa = XCBuildConfiguration; 429 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 430 | buildSettings = { 431 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 432 | CLANG_ENABLE_MODULES = YES; 433 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 434 | ENABLE_BITCODE = NO; 435 | FRAMEWORK_SEARCH_PATHS = ( 436 | "$(inherited)", 437 | "$(PROJECT_DIR)/Flutter", 438 | ); 439 | INFOPLIST_FILE = Runner/Info.plist; 440 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 441 | LIBRARY_SEARCH_PATHS = ( 442 | "$(inherited)", 443 | "$(PROJECT_DIR)/Flutter", 444 | ); 445 | PRODUCT_BUNDLE_IDENTIFIER = com.example.example; 446 | PRODUCT_NAME = "$(TARGET_NAME)"; 447 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 448 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 449 | SWIFT_VERSION = 5.0; 450 | VERSIONING_SYSTEM = "apple-generic"; 451 | }; 452 | name = Debug; 453 | }; 454 | 97C147071CF9000F007C117D /* Release */ = { 455 | isa = XCBuildConfiguration; 456 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 457 | buildSettings = { 458 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 459 | CLANG_ENABLE_MODULES = YES; 460 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 461 | ENABLE_BITCODE = NO; 462 | FRAMEWORK_SEARCH_PATHS = ( 463 | "$(inherited)", 464 | "$(PROJECT_DIR)/Flutter", 465 | ); 466 | INFOPLIST_FILE = Runner/Info.plist; 467 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 468 | LIBRARY_SEARCH_PATHS = ( 469 | "$(inherited)", 470 | "$(PROJECT_DIR)/Flutter", 471 | ); 472 | PRODUCT_BUNDLE_IDENTIFIER = com.example.example; 473 | PRODUCT_NAME = "$(TARGET_NAME)"; 474 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 475 | SWIFT_VERSION = 5.0; 476 | VERSIONING_SYSTEM = "apple-generic"; 477 | }; 478 | name = Release; 479 | }; 480 | /* End XCBuildConfiguration section */ 481 | 482 | /* Begin XCConfigurationList section */ 483 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 484 | isa = XCConfigurationList; 485 | buildConfigurations = ( 486 | 97C147031CF9000F007C117D /* Debug */, 487 | 97C147041CF9000F007C117D /* Release */, 488 | 249021D3217E4FDB00AE95B9 /* Profile */, 489 | ); 490 | defaultConfigurationIsVisible = 0; 491 | defaultConfigurationName = Release; 492 | }; 493 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 494 | isa = XCConfigurationList; 495 | buildConfigurations = ( 496 | 97C147061CF9000F007C117D /* Debug */, 497 | 97C147071CF9000F007C117D /* Release */, 498 | 249021D4217E4FDB00AE95B9 /* Profile */, 499 | ); 500 | defaultConfigurationIsVisible = 0; 501 | defaultConfigurationName = Release; 502 | }; 503 | /* End XCConfigurationList section */ 504 | }; 505 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 506 | } 507 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m3uzz/date_time_picker/824b4a14bc72ae3a1e1cba09aaa6f43e915d1d15/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/m3uzz/date_time_picker/824b4a14bc72ae3a1e1cba09aaa6f43e915d1d15/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/m3uzz/date_time_picker/824b4a14bc72ae3a1e1cba09aaa6f43e915d1d15/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/m3uzz/date_time_picker/824b4a14bc72ae3a1e1cba09aaa6f43e915d1d15/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/m3uzz/date_time_picker/824b4a14bc72ae3a1e1cba09aaa6f43e915d1d15/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/m3uzz/date_time_picker/824b4a14bc72ae3a1e1cba09aaa6f43e915d1d15/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/m3uzz/date_time_picker/824b4a14bc72ae3a1e1cba09aaa6f43e915d1d15/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/m3uzz/date_time_picker/824b4a14bc72ae3a1e1cba09aaa6f43e915d1d15/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/m3uzz/date_time_picker/824b4a14bc72ae3a1e1cba09aaa6f43e915d1d15/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/m3uzz/date_time_picker/824b4a14bc72ae3a1e1cba09aaa6f43e915d1d15/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/m3uzz/date_time_picker/824b4a14bc72ae3a1e1cba09aaa6f43e915d1d15/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/m3uzz/date_time_picker/824b4a14bc72ae3a1e1cba09aaa6f43e915d1d15/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/m3uzz/date_time_picker/824b4a14bc72ae3a1e1cba09aaa6f43e915d1d15/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/m3uzz/date_time_picker/824b4a14bc72ae3a1e1cba09aaa6f43e915d1d15/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/m3uzz/date_time_picker/824b4a14bc72ae3a1e1cba09aaa6f43e915d1d15/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/m3uzz/date_time_picker/824b4a14bc72ae3a1e1cba09aaa6f43e915d1d15/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m3uzz/date_time_picker/824b4a14bc72ae3a1e1cba09aaa6f43e915d1d15/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m3uzz/date_time_picker/824b4a14bc72ae3a1e1cba09aaa6f43e915d1d15/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | 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/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:date_time_picker/date_time_picker.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_localizations/flutter_localizations.dart'; 4 | import 'package:intl/intl.dart'; 5 | 6 | void main() => runApp(MyApp()); 7 | 8 | class MyApp extends StatelessWidget { 9 | @override 10 | Widget build(BuildContext context) { 11 | return MaterialApp( 12 | title: 'Flutter DateTimePicker Demo', 13 | home: MyHomePage(), 14 | localizationsDelegates: [ 15 | GlobalWidgetsLocalizations.delegate, 16 | GlobalMaterialLocalizations.delegate, 17 | GlobalCupertinoLocalizations.delegate, 18 | ], 19 | supportedLocales: [Locale('en', 'US')], //, Locale('pt', 'BR')], 20 | ); 21 | } 22 | } 23 | 24 | class MyHomePage extends StatefulWidget { 25 | MyHomePage({Key? key}) : super(key: key); 26 | 27 | @override 28 | _MyHomePageState createState() => _MyHomePageState(); 29 | } 30 | 31 | class _MyHomePageState extends State { 32 | GlobalKey _oFormKey = GlobalKey(); 33 | late TextEditingController _controller1; 34 | late TextEditingController _controller2; 35 | late TextEditingController _controller3; 36 | late TextEditingController _controller4; 37 | 38 | //String _initialValue = ''; 39 | String _valueChanged1 = ''; 40 | String _valueToValidate1 = ''; 41 | String _valueSaved1 = ''; 42 | String _valueChanged2 = ''; 43 | String _valueToValidate2 = ''; 44 | String _valueSaved2 = ''; 45 | String _valueChanged3 = ''; 46 | String _valueToValidate3 = ''; 47 | String _valueSaved3 = ''; 48 | String _valueChanged4 = ''; 49 | String _valueToValidate4 = ''; 50 | String _valueSaved4 = ''; 51 | 52 | @override 53 | void initState() { 54 | super.initState(); 55 | Intl.defaultLocale = 'pt_BR'; 56 | //_initialValue = DateTime.now().toString(); 57 | _controller1 = TextEditingController(text: DateTime.now().toString()); 58 | _controller2 = TextEditingController(text: DateTime.now().toString()); 59 | _controller3 = TextEditingController(text: DateTime.now().toString()); 60 | 61 | String lsHour = TimeOfDay.now().hour.toString().padLeft(2, '0'); 62 | String lsMinute = TimeOfDay.now().minute.toString().padLeft(2, '0'); 63 | _controller4 = TextEditingController(text: '$lsHour:$lsMinute'); 64 | 65 | _getValue(); 66 | } 67 | 68 | /// This implementation is just to simulate a load data behavior 69 | /// from a data base sqlite or from a API 70 | Future _getValue() async { 71 | await Future.delayed(const Duration(seconds: 3), () { 72 | setState(() { 73 | //_initialValue = '2000-10-22 14:30'; 74 | _controller1.text = '2000-09-20 14:30'; 75 | _controller2.text = '2001-10-21 15:31'; 76 | _controller3.text = '2002-11-22'; 77 | _controller4.text = '17:01'; 78 | }); 79 | }); 80 | } 81 | 82 | @override 83 | Widget build(BuildContext context) { 84 | return Scaffold( 85 | appBar: AppBar( 86 | title: Text('Flutter DateTimePicker Demo'), 87 | ), 88 | body: SingleChildScrollView( 89 | padding: EdgeInsets.only(left: 20, right: 20, top: 10), 90 | child: Form( 91 | key: _oFormKey, 92 | child: Column( 93 | children: [ 94 | DateTimePicker( 95 | type: DateTimePickerType.dateTimeSeparate, 96 | dateMask: 'd MMM, yyyy', 97 | controller: _controller1, 98 | //initialValue: _initialValue, 99 | firstDate: DateTime(2000), 100 | lastDate: DateTime(2100), 101 | icon: Icon(Icons.event), 102 | dateLabelText: 'Date', 103 | timeLabelText: "Hour", 104 | //use24HourFormat: false, 105 | //locale: Locale('pt', 'BR'), 106 | selectableDayPredicate: (date) { 107 | if (date.weekday == 6 || date.weekday == 7) { 108 | return false; 109 | } 110 | return true; 111 | }, 112 | onChanged: (val) => setState(() => _valueChanged1 = val), 113 | validator: (val) { 114 | setState(() => _valueToValidate1 = val ?? ''); 115 | return null; 116 | }, 117 | onSaved: (val) => setState(() => _valueSaved1 = val ?? ''), 118 | ), 119 | DateTimePicker( 120 | type: DateTimePickerType.dateTime, 121 | dateMask: 'd MMMM, yyyy - hh:mm a', 122 | controller: _controller2, 123 | //initialValue: _initialValue, 124 | firstDate: DateTime(2000), 125 | lastDate: DateTime(2100), 126 | //icon: Icon(Icons.event), 127 | dateLabelText: 'Date Time', 128 | use24HourFormat: false, 129 | locale: Locale('en', 'US'), 130 | onChanged: (val) => setState(() => _valueChanged2 = val), 131 | validator: (val) { 132 | setState(() => _valueToValidate2 = val ?? ''); 133 | return null; 134 | }, 135 | onSaved: (val) => setState(() => _valueSaved2 = val ?? ''), 136 | ), 137 | DateTimePicker( 138 | type: DateTimePickerType.date, 139 | //dateMask: 'yyyy/MM/dd', 140 | controller: _controller3, 141 | //initialValue: _initialValue, 142 | firstDate: DateTime(2000), 143 | lastDate: DateTime(2100), 144 | icon: Icon(Icons.event), 145 | dateLabelText: 'Date', 146 | locale: Locale('pt', 'BR'), 147 | onChanged: (val) => setState(() => _valueChanged3 = val), 148 | validator: (val) { 149 | setState(() => _valueToValidate3 = val ?? ''); 150 | return null; 151 | }, 152 | onSaved: (val) => setState(() => _valueSaved3 = val ?? ''), 153 | ), 154 | DateTimePicker( 155 | type: DateTimePickerType.time, 156 | //timePickerEntryModeInput: true, 157 | //controller: _controller4, 158 | initialValue: '', //_initialValue, 159 | icon: Icon(Icons.access_time), 160 | timeLabelText: "Time", 161 | use24HourFormat: false, 162 | locale: Locale('pt', 'BR'), 163 | onChanged: (val) => setState(() => _valueChanged4 = val), 164 | validator: (val) { 165 | setState(() => _valueToValidate4 = val ?? ''); 166 | return null; 167 | }, 168 | onSaved: (val) => setState(() => _valueSaved4 = val ?? ''), 169 | ), 170 | SizedBox(height: 20), 171 | Text( 172 | 'DateTimePicker data value onChanged:', 173 | style: TextStyle(fontWeight: FontWeight.bold), 174 | ), 175 | SizedBox(height: 10), 176 | SelectableText(_valueChanged1), 177 | SelectableText(_valueChanged2), 178 | SelectableText(_valueChanged3), 179 | SelectableText(_valueChanged4), 180 | SizedBox(height: 10), 181 | ElevatedButton( 182 | onPressed: () { 183 | final loForm = _oFormKey.currentState; 184 | 185 | if (loForm?.validate() == true) { 186 | loForm?.save(); 187 | } 188 | }, 189 | child: Text('Submit'), 190 | ), 191 | SizedBox(height: 30), 192 | Text( 193 | 'DateTimePicker data value validator:', 194 | style: TextStyle(fontWeight: FontWeight.bold), 195 | ), 196 | SizedBox(height: 10), 197 | SelectableText(_valueToValidate1), 198 | SelectableText(_valueToValidate2), 199 | SelectableText(_valueToValidate3), 200 | SelectableText(_valueToValidate4), 201 | SizedBox(height: 10), 202 | Text( 203 | 'DateTimePicker data value onSaved:', 204 | style: TextStyle(fontWeight: FontWeight.bold), 205 | ), 206 | SizedBox(height: 10), 207 | SelectableText(_valueSaved1), 208 | SelectableText(_valueSaved2), 209 | SelectableText(_valueSaved3), 210 | SelectableText(_valueSaved4), 211 | SizedBox(height: 20), 212 | ElevatedButton( 213 | onPressed: () { 214 | final loForm = _oFormKey.currentState; 215 | loForm?.reset(); 216 | 217 | setState(() { 218 | _valueChanged1 = ''; 219 | _valueChanged2 = ''; 220 | _valueChanged3 = ''; 221 | _valueChanged4 = ''; 222 | _valueToValidate1 = ''; 223 | _valueToValidate2 = ''; 224 | _valueToValidate3 = ''; 225 | _valueToValidate4 = ''; 226 | _valueSaved1 = ''; 227 | _valueSaved2 = ''; 228 | _valueSaved3 = ''; 229 | _valueSaved4 = ''; 230 | }); 231 | 232 | _controller1.clear(); 233 | _controller2.clear(); 234 | _controller3.clear(); 235 | _controller4.clear(); 236 | }, 237 | child: Text('Reset'), 238 | ), 239 | ], 240 | ), 241 | ), 242 | ), 243 | ); 244 | } 245 | } 246 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: example 2 | description: A new Flutter project. 3 | 4 | # The following line prevents the package from being accidentally published to 5 | # pub.dev using `pub publish`. This is preferred for private packages. 6 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev 7 | 8 | # The following defines the version and build number for your application. 9 | # A version number is three numbers separated by dots, like 1.2.43 10 | # followed by an optional build number separated by a +. 11 | # Both the version and the builder number may be overridden in flutter 12 | # build by specifying --build-name and --build-number, respectively. 13 | # In Android, build-name is used as versionName while build-number used as versionCode. 14 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 15 | # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. 16 | # Read more about iOS versioning at 17 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 18 | version: 1.0.0+1 19 | 20 | environment: 21 | sdk: ">=2.12.0 <3.0.0" 22 | 23 | dependencies: 24 | flutter: 25 | sdk: flutter 26 | flutter_localizations: 27 | sdk: flutter 28 | 29 | intl: ^0.17.0 30 | 31 | date_time_picker: #^2.1.0 32 | path: ../ 33 | 34 | # The following adds the Cupertino Icons font to your application. 35 | # Use with the CupertinoIcons class for iOS style icons. 36 | cupertino_icons: ^0.1.3 37 | 38 | dev_dependencies: 39 | flutter_test: 40 | sdk: flutter 41 | 42 | # For information on the generic Dart part of this file, see the 43 | # following page: https://dart.dev/tools/pub/pubspec 44 | 45 | # The following section is specific to Flutter. 46 | flutter: 47 | 48 | # The following line ensures that the Material Icons font is 49 | # included with your application, so that you can use the icons in 50 | # the material Icons class. 51 | uses-material-design: true 52 | 53 | # To add assets to your application, add an assets section, like this: 54 | # assets: 55 | # - images/a_dot_burr.jpeg 56 | # - images/a_dot_ham.jpeg 57 | 58 | # An image asset can refer to one or more resolution-specific "variants", see 59 | # https://flutter.dev/assets-and-images/#resolution-aware. 60 | 61 | # For details regarding adding assets from package dependencies, see 62 | # https://flutter.dev/assets-and-images/#from-packages 63 | 64 | # To add custom fonts to your application, add a fonts section here, 65 | # in this "flutter" section. Each entry in this list should have a 66 | # "family" key with the font family name, and a "fonts" key with a 67 | # list giving the asset and other descriptors for the font. For 68 | # example: 69 | # fonts: 70 | # - family: Schyler 71 | # fonts: 72 | # - asset: fonts/Schyler-Regular.ttf 73 | # - asset: fonts/Schyler-Italic.ttf 74 | # style: italic 75 | # - family: Trajan Pro 76 | # fonts: 77 | # - asset: fonts/TrajanPro.ttf 78 | # - asset: fonts/TrajanPro_Bold.ttf 79 | # weight: 700 80 | # 81 | # For details regarding fonts from package dependencies, 82 | # see https://flutter.dev/custom-fonts/#from-packages 83 | -------------------------------------------------------------------------------- /lib/date_time_picker.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The m3uzz Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | library date_time_picker; 6 | 7 | import 'package:flutter/material.dart'; 8 | import 'package:flutter/services.dart'; 9 | import 'package:intl/intl.dart'; 10 | 11 | enum DateTimePickerType { date, time, dateTime, dateTimeSeparate } 12 | 13 | /// A [DateTimePicker] that contains a [TextField]. 14 | /// 15 | /// This is a convenience widget that wraps a [TextField] widget in a 16 | /// [DateTimePicker]. 17 | /// 18 | /// A [Form] ancestor is not required. The [Form] simply makes it easier to 19 | /// save, reset, or validate multiple fields at once. To use without a [Form], 20 | /// pass a [GlobalKey] to the constructor and use [GlobalKey.currentState] to 21 | /// save or reset the form field. 22 | /// 23 | /// When a [controller] is specified, its [TextEditingController.text] 24 | /// defines the [initialValue]. If this [FormField] is part of a scrolling 25 | /// container that lazily constructs its children, like a [ListView] or a 26 | /// [CustomScrollView], then a [controller] should be specified. 27 | /// The controller's lifetime should be managed by a stateful widget ancestor 28 | /// of the scrolling container. 29 | /// 30 | /// If a [controller] is not specified, [initialValue] can be used to give 31 | /// the automatically generated controller an initial value. 32 | /// 33 | /// Remember to [dispose] of the [TextEditingController] when it is no longer needed. 34 | /// This will ensure we discard any resources used by the object. 35 | /// 36 | /// For a documentation about the various parameters, see [TextField]. 37 | /// 38 | /// {@tool snippet} 39 | /// 40 | /// Creates a [DateTimePicker] with an [InputDecoration] and validator function. 41 | /// 42 | /// ![ If the user enters valid text, the TextField appears normally without any 43 | /// warnings to the user](https://flutter.github.io/assets-for-api-docs/assets/material/text_form_field.png) 44 | /// 45 | /// ![ If the user enters invalid text, the error message returned from the 46 | /// validator function is displayed in dark red underneath the input] 47 | /// (https://flutter.github.io/assets-for-api-docs/assets/material/text_form_field_error.png) 48 | /// 49 | /// ```dart 50 | /// DateTimePicker( 51 | /// decoration: const InputDecoration( 52 | /// icon: Icon(Icons.person), 53 | /// hintText: 'What do people call you?', 54 | /// labelText: 'Name *', 55 | /// ), 56 | /// onSaved: (String value) { 57 | /// // This optional block of code can be used to run 58 | /// // code when the user saves the form. 59 | /// }, 60 | /// validator: (String value) { 61 | /// return value.contains('@') ? 'Do not use the @ char.' : null; 62 | /// }, 63 | /// ) 64 | /// ``` 65 | /// {@end-tool} 66 | /// 67 | /// {@tool dartpad --template=stateful_widget_material} 68 | /// This example shows how to move the focus to the next field when the user 69 | /// presses the ENTER key. 70 | /// 71 | /// ```dart imports 72 | /// import 'package:flutter/services.dart'; 73 | /// ``` 74 | /// 75 | /// ```dart 76 | /// Widget build(BuildContext context) { 77 | /// return Material( 78 | /// child: Center( 79 | /// child: Shortcuts( 80 | /// shortcuts: { 81 | /// // Pressing enter on the field will now move to the next field. 82 | /// LogicalKeySet(LogicalKeyboardKey.enter): 83 | /// Intent(NextFocusAction.key), 84 | /// }, 85 | /// child: FocusTraversalGroup( 86 | /// child: Form( 87 | /// autovalidate: true, 88 | /// onChanged: () { 89 | /// Form.of(primaryFocus.context).save(); 90 | /// }, 91 | /// child: Wrap( 92 | /// children: List.generate(5, (int index) { 93 | /// return Padding( 94 | /// padding: const EdgeInsets.all(8.0), 95 | /// child: ConstrainedBox( 96 | /// constraints: BoxConstraints.tight(Size(200, 50)), 97 | /// child: DateTimePicker( 98 | /// initialValue: DateTime.now().toString(), 99 | /// firstDate: DateTime(2000), 100 | /// lastDate: DateTime(2100), 101 | /// onSaved: (String value) { 102 | /// print('Value for field $index saved as "$value"'); 103 | /// }, 104 | /// ), 105 | /// ), 106 | /// ); 107 | /// }), 108 | /// ), 109 | /// ), 110 | /// ), 111 | /// ), 112 | /// ), 113 | /// ); 114 | /// } 115 | /// ``` 116 | /// {@end-tool} 117 | /// 118 | /// See also: 119 | /// 120 | /// * 121 | /// * [TextField], which is the underlying text field without the [Form] 122 | /// integration. 123 | /// * [InputDecorator], which shows the labels and other visual elements that 124 | /// surround the actual text editing widget. 125 | /// * Learn how to use a [TextEditingController] in one of our 126 | /// [cookbook recipe]s.(https://flutter.dev/docs/cookbook/forms/text-field-changes#2-use-a-texteditingcontroller) 127 | class DateTimePicker extends FormField { 128 | /// Creates a [DateTimePicker] that contains a [TextField]. 129 | /// 130 | /// When a [controller] is specified, [initialValue] must be null (the 131 | /// default). If [controller] is null, then a [TextEditingController] 132 | /// will be constructed automatically and its `text` will be initialized 133 | /// to [initialValue] or the empty string. 134 | /// 135 | /// For documentation about the various parameters, see the [TextField] class 136 | /// and [new TextField], the constructor. 137 | DateTimePicker({ 138 | Key? key, 139 | this.type = DateTimePickerType.date, 140 | this.controller, 141 | this.firstDate, 142 | this.lastDate, 143 | this.initialDate, 144 | this.initialTime, 145 | this.dateMask, 146 | this.icon, 147 | this.dateLabelText, 148 | this.timeLabelText, 149 | this.dateHintText, 150 | this.timeHintText, 151 | this.calendarTitle, 152 | this.cancelText, 153 | this.confirmText, 154 | this.fieldLabelText, 155 | this.fieldHintText, 156 | this.errorFormatText, 157 | this.errorInvalidText, 158 | this.initialEntryMode, 159 | this.initialDatePickerMode, 160 | this.selectableDayPredicate, 161 | this.textDirection, 162 | this.locale, 163 | this.useRootNavigator = false, 164 | this.routeSettings, 165 | this.use24HourFormat = true, 166 | this.timeFieldWidth, 167 | this.timePickerEntryModeInput = false, 168 | String? initialValue, 169 | FocusNode? focusNode, 170 | InputDecoration? decoration, 171 | //TextInputType keyboardType, 172 | TextCapitalization textCapitalization = TextCapitalization.none, 173 | TextInputAction? textInputAction, 174 | TextStyle? style, 175 | StrutStyle? strutStyle, 176 | TextAlign textAlign = TextAlign.start, 177 | TextAlignVertical? textAlignVertical, 178 | bool autofocus = false, 179 | bool readOnly = false, 180 | ToolbarOptions? toolbarOptions, 181 | bool showCursor = false, 182 | bool obscureText = false, 183 | bool autocorrect = true, 184 | SmartDashesType? smartDashesType, 185 | SmartQuotesType? smartQuotesType, 186 | bool enableSuggestions = true, 187 | bool autovalidate = false, 188 | MaxLengthEnforcement? maxLengthEnforcement, 189 | int maxLines = 1, 190 | int? minLines, 191 | bool expands = false, 192 | int? maxLength, 193 | this.onChanged, 194 | VoidCallback? onEditingComplete, 195 | ValueChanged? onFieldSubmitted, 196 | FormFieldSetter? onSaved, 197 | FormFieldValidator? validator, 198 | List? inputFormatters, 199 | bool enabled = true, 200 | double cursorWidth = 2.0, 201 | Radius? cursorRadius, 202 | Color? cursorColor, 203 | Brightness? keyboardAppearance, 204 | EdgeInsets scrollPadding = const EdgeInsets.all(20.0), 205 | bool enableInteractiveSelection = true, 206 | InputCounterWidgetBuilder? buildCounter, 207 | ScrollPhysics? scrollPhysics, 208 | }) : assert(initialValue == null || controller == null), 209 | assert(type == DateTimePickerType.time || firstDate != null), 210 | assert(type == DateTimePickerType.time || lastDate != null), 211 | assert(maxLines > 0), 212 | assert(minLines == null || minLines > 0), 213 | assert( 214 | (minLines == null) || (maxLines >= minLines), 215 | "minLines can't be greater than maxLines", 216 | ), 217 | assert( 218 | !expands || (minLines == null), 219 | 'minLines and maxLines must be null when expands is true.', 220 | ), 221 | assert( 222 | !obscureText || maxLines == 1, 223 | 'Obscured fields cannot be multiline.', 224 | ), 225 | assert(maxLength == null || maxLength > 0), 226 | super( 227 | key: key, 228 | initialValue: 229 | controller != null ? controller.text : (initialValue ?? ''), 230 | onSaved: onSaved, 231 | validator: validator, 232 | autovalidateMode: autovalidate 233 | ? AutovalidateMode.always 234 | : AutovalidateMode.disabled, 235 | enabled: enabled, 236 | builder: (FormFieldState field) { 237 | final state = field as _DateTimePickerState; 238 | 239 | void onChangedHandler(String value) { 240 | if (onChanged != null) { 241 | onChanged(value); 242 | } 243 | field.didChange(value); 244 | } 245 | 246 | Widget buildField(DateTimePickerType peType) { 247 | GestureTapCallback lfOnTap; 248 | TextEditingController loCtrl; 249 | InputDecoration loDecoration; 250 | 251 | switch (peType) { 252 | case DateTimePickerType.time: 253 | lfOnTap = state._showTimePickerDialog; 254 | loCtrl = state._timeLabelController; 255 | loDecoration = InputDecoration( 256 | labelText: timeLabelText, 257 | icon: icon, 258 | hintText: timeHintText, 259 | ); 260 | 261 | if (type == DateTimePickerType.dateTimeSeparate) { 262 | loDecoration = InputDecoration( 263 | labelText: timeLabelText, 264 | hintText: timeHintText, 265 | ); 266 | } 267 | break; 268 | case DateTimePickerType.dateTime: 269 | lfOnTap = state._showDateTimePickerDialog; 270 | loCtrl = state._dateLabelController; 271 | loDecoration = InputDecoration( 272 | labelText: dateLabelText, 273 | icon: icon, 274 | hintText: dateHintText, 275 | ); 276 | break; 277 | default: 278 | lfOnTap = state._showDatePickerDialog; 279 | loCtrl = state._dateLabelController; 280 | loDecoration = InputDecoration( 281 | labelText: dateLabelText, 282 | icon: icon, 283 | hintText: dateHintText, 284 | ); 285 | } 286 | 287 | loDecoration = decoration ?? loDecoration 288 | ..applyDefaults( 289 | Theme.of(field.context).inputDecorationTheme, 290 | ); 291 | 292 | return TextField( 293 | readOnly: true, 294 | onTap: readOnly ? null : lfOnTap, 295 | controller: loCtrl, 296 | decoration: loDecoration.copyWith( 297 | errorText: field.errorText, 298 | ), 299 | focusNode: focusNode, 300 | keyboardType: TextInputType.datetime, 301 | textInputAction: textInputAction, 302 | style: style, 303 | strutStyle: strutStyle, 304 | textAlign: textAlign, 305 | textAlignVertical: textAlignVertical, 306 | //textDirection: textDirection, 307 | textCapitalization: textCapitalization, 308 | autofocus: autofocus, 309 | toolbarOptions: toolbarOptions, 310 | showCursor: showCursor, 311 | obscureText: obscureText, 312 | autocorrect: autocorrect, 313 | smartDashesType: smartDashesType ?? 314 | (obscureText 315 | ? SmartDashesType.disabled 316 | : SmartDashesType.enabled), 317 | smartQuotesType: smartQuotesType ?? 318 | (obscureText 319 | ? SmartQuotesType.disabled 320 | : SmartQuotesType.enabled), 321 | enableSuggestions: enableSuggestions, 322 | maxLengthEnforcement: maxLengthEnforcement, 323 | maxLines: maxLines, 324 | minLines: minLines, 325 | expands: expands, 326 | maxLength: maxLength, 327 | onChanged: onChangedHandler, 328 | onEditingComplete: onEditingComplete, 329 | onSubmitted: onFieldSubmitted, 330 | inputFormatters: inputFormatters, 331 | enabled: enabled, 332 | cursorWidth: cursorWidth, 333 | cursorRadius: cursorRadius, 334 | cursorColor: cursorColor, 335 | scrollPadding: scrollPadding, 336 | scrollPhysics: scrollPhysics, 337 | keyboardAppearance: keyboardAppearance, 338 | enableInteractiveSelection: enableInteractiveSelection, 339 | buildCounter: buildCounter, 340 | ); 341 | } 342 | 343 | switch (type) { 344 | case DateTimePickerType.time: 345 | return buildField(DateTimePickerType.time); 346 | case DateTimePickerType.dateTime: 347 | return buildField(DateTimePickerType.dateTime); 348 | case DateTimePickerType.dateTimeSeparate: 349 | return Row(children: [ 350 | Expanded(child: buildField(DateTimePickerType.date)), 351 | const SizedBox(width: 15), 352 | SizedBox( 353 | width: timeFieldWidth ?? 100, 354 | child: buildField(DateTimePickerType.time), 355 | ) 356 | ]); 357 | default: 358 | return buildField(DateTimePickerType.date); 359 | } 360 | }, 361 | ); 362 | 363 | /// The DateTimePicker type: 364 | /// [date], [time], [dateTime] or [dateTimeSeparate]. 365 | final DateTimePickerType type; 366 | 367 | /// Controls the text being edited. 368 | /// 369 | /// If null, this widget will create its own [TextEditingController] and 370 | /// initialize its [TextEditingController.text] with [initialValue]. 371 | /// The value need to be a DateTime String or null 372 | final TextEditingController? controller; 373 | 374 | /// The earliest allowable [DateTime] that the user can select. 375 | final DateTime? firstDate; 376 | 377 | /// The latest allowable [DateTime] that the user can select. 378 | final DateTime? lastDate; 379 | 380 | /// The initial date to be used for the date picker if initialValue is null or empty 381 | final DateTime? initialDate; 382 | 383 | /// The initial time to be used for the time picker if initialValue is null or empty 384 | final TimeOfDay? initialTime; 385 | 386 | /// For forms that match one of our predefined skeletons, we look up the 387 | /// corresponding pattern in [locale] (or in the default locale if none is 388 | /// specified) and use the resulting full format string. This is the 389 | /// preferred usage, but if [newPattern] does not match one of the skeletons, 390 | /// then it is used as a format directly, but will not be adapted to suit the 391 | /// locale. 392 | final String? dateMask; 393 | 394 | /// An icon to show before the input field and outside of the decoration's 395 | /// container. 396 | /// 397 | /// The size and color of the icon is configured automatically using an 398 | /// [IconTheme] and therefore does not need to be explicitly given in the 399 | /// icon widget. 400 | /// 401 | /// The trailing edge of the icon is padded by 16dps. 402 | /// 403 | /// The decoration's container is the area which is filled if [filled] is 404 | /// true and bordered per the [border]. It's the area adjacent to 405 | /// [decoration.icon] and above the widgets that contain [helperText], 406 | /// [errorText], and [counterText]. 407 | /// 408 | /// See [Icon], [ImageIcon]. 409 | final Widget? icon; 410 | 411 | /// Text that describes the date input field. 412 | /// 413 | /// When the date input field is empty and unfocused, the label is displayed on 414 | /// top of the input field (i.e., at the same location on the screen where 415 | /// text may be entered in the input field). When the input field receives 416 | /// focus (or if the field is non-empty), the label moves above (i.e., 417 | /// vertically adjacent to) the input field. 418 | final String? dateLabelText; 419 | 420 | /// Text that describes the time input field. 421 | /// 422 | /// When the time input field is empty and unfocused, the label is displayed on 423 | /// top of the input field (i.e., at the same location on the screen where 424 | /// text may be entered in the input field). When the input field receives 425 | /// focus (or if the field is non-empty), the label moves above (i.e., 426 | /// vertically adjacent to) the input field. 427 | final String? timeLabelText; 428 | 429 | /// Text that suggests what sort of date input the field accepts. 430 | /// 431 | /// Displayed on top of the date input [child] (i.e., at the same location on the 432 | /// screen where text may be entered in the input [child]) when the input 433 | /// [isEmpty] and either (a) [labelText] is null or (b) the input has the focus. 434 | final String? dateHintText; 435 | 436 | /// Text that suggests what sort of time input the field accepts. 437 | /// 438 | /// Displayed on top of the time input [child] (i.e., at the same location on the 439 | /// screen where text may be entered in the input [child]) when the input 440 | /// [isEmpty] and either (a) [labelText] is null or (b) the input has the focus. 441 | final String? timeHintText; 442 | 443 | /// Optional strings for the [cancelText] to override the default text. 444 | final String? calendarTitle; 445 | 446 | /// Optional strings for the [cancelText] to override the default text. 447 | final String? cancelText; 448 | 449 | /// Optional strings for the [confirmText] to override the default text. 450 | final String? confirmText; 451 | 452 | /// Optional strings for the [fieldLabelText] to override the default text. 453 | final String? fieldLabelText; 454 | 455 | /// Optional strings for the [fieldHintText] to override the default text. 456 | final String? fieldHintText; 457 | 458 | /// Optional strings for the [errorFormatText] to override the default text. 459 | final String? errorFormatText; 460 | 461 | /// Optional strings for the [errorInvalidText] to override the default text. 462 | final String? errorInvalidText; 463 | 464 | /// An optional [textDirection] argument can be used to set the text direction 465 | /// ([TextDirection.ltr] or [TextDirection.rtl]) for the date picker. It 466 | /// defaults to the ambient text direction provided by [Directionality]. If both 467 | /// [locale] and [textDirection] are non-null, [textDirection] overrides the 468 | /// direction chosen for the [locale]. 469 | final TextDirection? textDirection; 470 | 471 | /// An optional [locale] argument can be used to set the locale for the date 472 | /// picker. It defaults to the ambient locale provided by [Localizations]. 473 | final Locale? locale; 474 | 475 | /// The [context], [useRootNavigator] and [routeSettings] arguments are passed to 476 | /// [showDialog], the documentation for which discusses how it is used. [context] 477 | /// and [useRootNavigator] must be non-null. 478 | final bool useRootNavigator; 479 | 480 | /// Creates data used to construct routes. 481 | final RouteSettings? routeSettings; 482 | 483 | /// An optional [initialEntryMode] argument can be used to display the date 484 | /// picker in the [DatePickerEntryMode.calendar] (a calendar month grid) 485 | /// or [DatePickerEntryMode.input] (a text input field) mode. 486 | /// It defaults to [DatePickerEntryMode.calendar] and must be non-null. 487 | final DatePickerEntryMode? initialEntryMode; 488 | 489 | /// An optional [initialDatePickerMode] argument can be used to have the 490 | /// calendar date picker initially appear in the [DatePickerMode.year] or 491 | /// [DatePickerMode.day] mode. It defaults to [DatePickerMode.day], and 492 | /// must be non-null. 493 | final DatePickerMode? initialDatePickerMode; 494 | 495 | /// An optional [selectableDayPredicate] function can be passed in to only allow 496 | /// certain days for selection. If provided, only the days that 497 | /// [selectableDayPredicate] returns true for will be selectable. For example, 498 | /// this can be used to only allow weekdays for selection. If provided, it must 499 | /// return true for [initialDate]. 500 | final bool Function(DateTime)? selectableDayPredicate; 501 | 502 | /// Show a dialog with time unconditionally displayed in 24 hour format. 503 | final bool use24HourFormat; 504 | 505 | /// The width for time text field when DateTimePickerType is dateTimeSeparated. 506 | final double? timeFieldWidth; 507 | 508 | final bool timePickerEntryModeInput; 509 | 510 | final ValueChanged? onChanged; 511 | 512 | @override 513 | _DateTimePickerState createState() => _DateTimePickerState(); 514 | } 515 | 516 | class _DateTimePickerState extends FormFieldState { 517 | TextEditingController? _stateController; 518 | final TextEditingController _dateLabelController = TextEditingController(); 519 | final TextEditingController _timeLabelController = TextEditingController(); 520 | DateTime _dDate = DateTime.now(); 521 | TimeOfDay _tTime = TimeOfDay.now(); 522 | String _sValue = ''; 523 | String _sDate = ''; 524 | String _sTime = ''; 525 | String _sPeriod = ''; 526 | 527 | @override 528 | DateTimePicker get widget => super.widget as DateTimePicker; 529 | 530 | TextEditingController? get _effectiveController => 531 | widget.controller ?? _stateController; 532 | 533 | @override 534 | void initState() { 535 | super.initState(); 536 | 537 | if (widget.controller == null) { 538 | _stateController = TextEditingController(text: widget.initialValue); 539 | } else { 540 | widget.controller?.addListener(_handleControllerChanged); 541 | } 542 | 543 | initValues(); 544 | } 545 | 546 | void initValues() { 547 | _dDate = widget.initialDate ?? DateTime.now(); 548 | _tTime = widget.initialTime ?? TimeOfDay.now(); 549 | 550 | final lsValue = _effectiveController?.text.trim(); 551 | final languageCode = widget.locale?.languageCode; 552 | 553 | if (lsValue != null && lsValue != '' && lsValue != 'null') { 554 | if (widget.type != DateTimePickerType.time) { 555 | _dDate = DateTime.tryParse(lsValue) ?? DateTime.now(); 556 | _tTime = TimeOfDay.fromDateTime(_dDate); 557 | _sDate = DateFormat('yyyy-MM-dd', languageCode).format(_dDate); 558 | _sTime = DateFormat('HH:mm', languageCode).format(_dDate); 559 | 560 | if (!widget.use24HourFormat) { 561 | _sTime = DateFormat('hh:mm a', languageCode).format(_dDate); 562 | } 563 | 564 | _timeLabelController.text = _sTime; 565 | _dateLabelController.text = _sDate; 566 | 567 | if (widget.dateMask != null && widget.dateMask != '') { 568 | _dateLabelController.text = 569 | DateFormat(widget.dateMask, languageCode).format(_dDate); 570 | } else { 571 | String lsMask = 'MMM d, yyyy'; 572 | 573 | if (widget.type == DateTimePickerType.dateTime && _sTime != '') { 574 | lsMask = 'MMM d, yyyy - HH:mm'; 575 | 576 | if (!widget.use24HourFormat) { 577 | lsMask = 'MMM d, yyyy - hh:mm a'; 578 | } 579 | } 580 | 581 | _dateLabelController.text = 582 | DateFormat(lsMask, languageCode).format(_dDate); 583 | } 584 | } else { 585 | final llTime = lsValue.split(':'); 586 | _tTime = 587 | TimeOfDay(hour: int.parse(llTime[0]), minute: int.parse(llTime[1])); 588 | _sTime = lsValue; 589 | 590 | if (!widget.use24HourFormat) { 591 | _sPeriod = _tTime.period.index == 0 ? ' AM' : ' PM'; 592 | } 593 | 594 | _timeLabelController.text = _sTime + _sPeriod; 595 | } 596 | } 597 | } 598 | 599 | @override 600 | void didUpdateWidget(DateTimePicker oldWidget) { 601 | super.didUpdateWidget(oldWidget); 602 | final languageCode = widget.locale?.languageCode; 603 | 604 | if (widget.controller != oldWidget.controller) { 605 | oldWidget.controller?.removeListener(_handleControllerChanged); 606 | widget.controller?.addListener(_handleControllerChanged); 607 | 608 | if (oldWidget.controller != null && widget.controller == null) { 609 | _stateController = 610 | TextEditingController.fromValue(oldWidget.controller?.value); 611 | } 612 | 613 | if (widget.controller != null) { 614 | setValue(widget.controller?.text); 615 | 616 | if (oldWidget.controller == null) { 617 | _stateController = null; 618 | } 619 | } 620 | } 621 | 622 | if (_effectiveController?.text != null && 623 | _effectiveController?.text != '') { 624 | final lsValue = _effectiveController?.text.trim(); 625 | 626 | if (lsValue != null && lsValue != '' && lsValue != 'null') { 627 | if (widget.type != DateTimePickerType.time) { 628 | final lsOldDate = _sDate; 629 | final lsOldTime = _sTime; 630 | _dDate = DateTime.tryParse(lsValue) ?? DateTime.now(); 631 | 632 | _sDate = DateFormat('yyyy-MM-dd', languageCode).format(_dDate); 633 | 634 | if (lsOldTime != '') { 635 | _tTime = TimeOfDay.fromDateTime(_dDate); 636 | _sTime = DateFormat('HH:mm', languageCode).format(_dDate); 637 | 638 | if (!widget.use24HourFormat) { 639 | _sTime = DateFormat('hh:mm a', languageCode).format(_dDate); 640 | } 641 | } 642 | 643 | _dateLabelController.text = lsOldDate != '' ? _sDate : ''; 644 | _timeLabelController.text = lsOldTime != '' ? _sTime : ''; 645 | 646 | if (widget.dateMask != null && widget.dateMask != '') { 647 | _dateLabelController.text = 648 | DateFormat(widget.dateMask, languageCode).format(_dDate); 649 | } else { 650 | String lsMask = 'MMM d, yyyy'; 651 | 652 | if (widget.type == DateTimePickerType.dateTime && _sTime != '') { 653 | lsMask = 'MMM d, yyyy - HH:mm'; 654 | 655 | if (!widget.use24HourFormat) { 656 | lsMask = 'MMM d, yyyy - hh:mm a'; 657 | } 658 | } 659 | 660 | _dateLabelController.text = 661 | DateFormat(lsMask, languageCode).format(_dDate); 662 | } 663 | } else { 664 | final llTime = lsValue.split(':'); 665 | _tTime = TimeOfDay( 666 | hour: int.parse(llTime[0]), minute: int.parse(llTime[1])); 667 | _sTime = lsValue; 668 | _timeLabelController.text = _sTime + _sPeriod; 669 | } 670 | } 671 | } else { 672 | _dateLabelController.clear(); 673 | _timeLabelController.clear(); 674 | 675 | initValues(); 676 | } 677 | } 678 | 679 | @override 680 | void dispose() { 681 | widget.controller?.removeListener(_handleControllerChanged); 682 | 683 | super.dispose(); 684 | } 685 | 686 | @override 687 | void reset() { 688 | super.reset(); 689 | 690 | setState(() { 691 | _effectiveController?.text = widget.initialValue ?? ''; 692 | }); 693 | } 694 | 695 | void _handleControllerChanged() { 696 | if (_effectiveController?.text != value) { 697 | didChange(_effectiveController?.text); 698 | } 699 | } 700 | 701 | void onChangedHandler(String value) { 702 | widget.onChanged?.call(value); 703 | 704 | didChange(value); 705 | } 706 | 707 | Future _showDatePickerDialog() async { 708 | final ldDatePicked = await showDatePicker( 709 | context: context, 710 | initialDate: _dDate, 711 | firstDate: widget.firstDate ?? DateTime.now(), 712 | lastDate: widget.lastDate ?? DateTime.now(), 713 | helpText: widget.calendarTitle, 714 | cancelText: widget.cancelText, 715 | confirmText: widget.confirmText, 716 | initialDatePickerMode: widget.initialDatePickerMode ?? DatePickerMode.day, 717 | initialEntryMode: widget.initialEntryMode ?? DatePickerEntryMode.calendar, 718 | selectableDayPredicate: widget.selectableDayPredicate, 719 | fieldLabelText: widget.fieldLabelText, 720 | fieldHintText: widget.fieldHintText, 721 | errorFormatText: widget.errorFormatText, 722 | errorInvalidText: widget.errorInvalidText, 723 | //textDirection: widget.textDirection, 724 | locale: widget.locale, 725 | useRootNavigator: widget.useRootNavigator, 726 | routeSettings: widget.routeSettings, 727 | ); 728 | 729 | final languageCode = widget.locale?.languageCode; 730 | if (ldDatePicked != null) { 731 | _sDate = DateFormat('yyyy-MM-dd', languageCode).format(ldDatePicked); 732 | _dDate = ldDatePicked; 733 | final lsOldValue = _sValue; 734 | _sValue = _sDate; 735 | String lsFormatedDate; 736 | 737 | if (widget.dateMask != null && widget.dateMask != '') { 738 | lsFormatedDate = DateFormat(widget.dateMask, languageCode) 739 | .format(DateTime.tryParse(_sDate)!); 740 | } else { 741 | lsFormatedDate = DateFormat('MMM dd, yyyy', languageCode) 742 | .format(DateTime.tryParse(_sDate)!); 743 | } 744 | 745 | if (widget.type == DateTimePickerType.dateTimeSeparate && _sTime != '') { 746 | _sValue = '$_sDate $_sTime'; 747 | } 748 | 749 | _sValue = _sValue.trim(); 750 | _dateLabelController.text = lsFormatedDate; 751 | _effectiveController?.text = _sValue; 752 | 753 | if (_sValue != lsOldValue) { 754 | onChangedHandler(_sValue); 755 | } 756 | } 757 | } 758 | 759 | void set12HourTimeValues(final TimeOfDay ptTimePicked) { 760 | final ldNow = DateTime.now(); 761 | final ldTime = DateTime(ldNow.year, ldNow.month, ldNow.day, 762 | ptTimePicked.hour, ptTimePicked.minute); 763 | final lsHour = DateFormat("hh", widget.locale.toString()).format(ldTime); 764 | final lsMinute = DateFormat("mm", widget.locale.toString()).format(ldTime); 765 | 766 | _sTime = '$lsHour:$lsMinute'; 767 | _sPeriod = ptTimePicked.period.index == 0 ? ' AM' : ' PM'; 768 | } 769 | 770 | Future _showTimePickerDialog() async { 771 | final ltTimePicked = await showTimePicker( 772 | context: context, 773 | initialTime: _tTime, 774 | initialEntryMode: widget.timePickerEntryModeInput 775 | ? TimePickerEntryMode.input 776 | : TimePickerEntryMode.dial, 777 | useRootNavigator: widget.useRootNavigator, 778 | routeSettings: widget.routeSettings, 779 | builder: (BuildContext context, Widget? child) { 780 | return MediaQuery( 781 | data: MediaQuery.of(context) 782 | .copyWith(alwaysUse24HourFormat: widget.use24HourFormat), 783 | child: child ?? const SizedBox(), 784 | ); 785 | }, 786 | ); 787 | 788 | if (ltTimePicked != null) { 789 | var lsHour = ltTimePicked.hour.toString().padLeft(2, '0'); 790 | var lsMinute = ltTimePicked.minute.toString().padLeft(2, '0'); 791 | 792 | if (ltTimePicked.period.index == 0 && lsHour == '12') { 793 | lsHour = '00'; 794 | } 795 | 796 | if (!widget.use24HourFormat) { 797 | set12HourTimeValues(ltTimePicked); 798 | } else { 799 | _sTime = '$lsHour:$lsMinute'; 800 | } 801 | 802 | _tTime = ltTimePicked; 803 | 804 | _timeLabelController.text = _sTime; 805 | final lsOldValue = _sValue; 806 | _sValue = _sTime; 807 | 808 | if (widget.type == DateTimePickerType.dateTimeSeparate && _sDate != '') { 809 | _sValue = '$_sDate $_sTime'; 810 | } 811 | 812 | _sValue = _sValue.trim(); 813 | _effectiveController?.text = _sValue; 814 | 815 | if (_sValue != lsOldValue) { 816 | onChangedHandler(_sValue); 817 | } 818 | } 819 | } 820 | 821 | Future _showDateTimePickerDialog() async { 822 | String lsFormatedDate; 823 | 824 | final ldDatePicked = await showDatePicker( 825 | context: context, 826 | initialDate: _dDate, 827 | firstDate: widget.firstDate ?? DateTime.now(), 828 | lastDate: widget.lastDate ?? DateTime.now(), 829 | helpText: widget.calendarTitle, 830 | cancelText: widget.cancelText, 831 | confirmText: widget.confirmText, 832 | initialDatePickerMode: widget.initialDatePickerMode ?? DatePickerMode.day, 833 | initialEntryMode: widget.initialEntryMode ?? DatePickerEntryMode.calendar, 834 | selectableDayPredicate: widget.selectableDayPredicate, 835 | fieldLabelText: widget.fieldLabelText, 836 | fieldHintText: widget.fieldHintText, 837 | errorFormatText: widget.errorFormatText, 838 | errorInvalidText: widget.errorInvalidText, 839 | //textDirection: widget.textDirection, 840 | locale: widget.locale, 841 | useRootNavigator: widget.useRootNavigator, 842 | routeSettings: widget.routeSettings, 843 | ); 844 | 845 | final languageCode = widget.locale?.languageCode; 846 | if (ldDatePicked != null) { 847 | _sDate = DateFormat('yyyy-MM-dd', languageCode).format(ldDatePicked); 848 | _dDate = ldDatePicked; 849 | 850 | final ltTimePicked = await showTimePicker( 851 | context: context, 852 | initialTime: _tTime, 853 | initialEntryMode: widget.timePickerEntryModeInput 854 | ? TimePickerEntryMode.input 855 | : TimePickerEntryMode.dial, 856 | useRootNavigator: widget.useRootNavigator, 857 | routeSettings: widget.routeSettings, 858 | builder: (BuildContext context, Widget? child) { 859 | return MediaQuery( 860 | data: MediaQuery.of(context) 861 | .copyWith(alwaysUse24HourFormat: widget.use24HourFormat), 862 | child: child ?? const SizedBox(), 863 | ); 864 | }, 865 | ); 866 | 867 | if (ltTimePicked != null) { 868 | var lsHour = ltTimePicked.hour.toString().padLeft(2, '0'); 869 | var lsMinute = ltTimePicked.minute.toString().padLeft(2, '0'); 870 | 871 | if (ltTimePicked.period.index == 0 && lsHour == '12') { 872 | lsHour = '00'; 873 | } 874 | 875 | if (!widget.use24HourFormat) { 876 | set12HourTimeValues(ltTimePicked); 877 | } else { 878 | _sTime = '$lsHour:$lsMinute'; 879 | } 880 | 881 | _tTime = ltTimePicked; 882 | } else { 883 | var lsHour = _tTime.hour.toString().padLeft(2, '0'); 884 | final lsMinute = _tTime.minute.toString().padLeft(2, '0'); 885 | 886 | if (_tTime.period.index == 0 && lsHour == '12') { 887 | lsHour = '00'; 888 | } 889 | 890 | if (!widget.use24HourFormat) { 891 | _sPeriod = _tTime.period.index == 0 ? ' AM' : ' PM'; 892 | } 893 | 894 | _sTime = '$lsHour:$lsMinute'; 895 | } 896 | 897 | final lsOldValue = _sValue; 898 | _sValue = '$_sDate $_sTime'; 899 | _sValue = _sValue.trim(); 900 | 901 | if (widget.dateMask != null && widget.dateMask != '') { 902 | lsFormatedDate = DateFormat(widget.dateMask, languageCode) 903 | .format(DateTime.tryParse(_sValue)!); 904 | } else { 905 | final lsMask = _sTime != '' ? 'MMM dd, yyyy - HH:mm' : 'MMM dd, yyyy'; 906 | lsFormatedDate = DateFormat(lsMask, languageCode) 907 | .format(DateTime.tryParse(_sValue)!); 908 | } 909 | 910 | _dateLabelController.text = lsFormatedDate; 911 | _effectiveController?.text = _sValue; 912 | 913 | if (_sValue != lsOldValue) { 914 | onChangedHandler(_sValue); 915 | } 916 | } 917 | } 918 | } 919 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: date_time_picker 2 | description: A Flutter widget to display a date time form field to show a date or clock dialog. 3 | version: 2.1.0 4 | homepage: https://github.com/m3uzz/date_time_picker 5 | 6 | environment: 7 | sdk: ">=2.12.0 <3.0.0" 8 | 9 | dependencies: 10 | flutter: 11 | sdk: flutter 12 | 13 | intl: ^0.17.0 14 | 15 | dev_dependencies: 16 | flutter_test: 17 | sdk: flutter 18 | 19 | # For information on the generic Dart part of this file, see the 20 | # following page: https://dart.dev/tools/pub/pubspec 21 | 22 | # The following section is specific to Flutter. 23 | flutter: 24 | -------------------------------------------------------------------------------- /test/date_time_picker_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:date_time_picker/date_time_picker.dart'; 4 | 5 | void main() { 6 | testWidgets('Testing instantiate DateTimePicker', 7 | (WidgetTester tester) async { 8 | var myWidget = MyWidget(); 9 | await tester.pumpWidget(myWidget); 10 | 11 | expect( 12 | find.text('Jul 23, 2020'), 13 | findsOneWidget, 14 | reason: 'DateTimePicker initial display date not found!', 15 | ); 16 | 17 | var dateTimePicker = find.byType(DateTimePicker); 18 | expect( 19 | dateTimePicker, 20 | findsOneWidget, 21 | reason: 'DateTimePicker not found!', 22 | ); 23 | 24 | await tester.tap(dateTimePicker); 25 | await tester.pumpWidget(myWidget); 26 | 27 | var day = find.text('25'); 28 | expect( 29 | day, 30 | findsOneWidget, 31 | reason: 'DateTimePicker day 25 not found!', 32 | ); 33 | var okBtn = find.text('OK'); 34 | expect( 35 | okBtn, 36 | findsOneWidget, 37 | reason: 'DateTimePicker OK button not found!', 38 | ); 39 | 40 | await tester.tap(day); 41 | await tester.tap(okBtn); 42 | 43 | expect( 44 | find.text('Jul 25, 2020'), 45 | findsOneWidget, 46 | reason: 'DateTimePicker new date selected not found on text field!', 47 | ); 48 | 49 | await tester.pumpWidget(myWidget); 50 | expect( 51 | find.text('2020-07-25'), 52 | findsOneWidget, 53 | reason: 'DateTimePicker new date value not found!', 54 | ); 55 | }); 56 | } 57 | 58 | class MyWidget extends StatefulWidget { 59 | MyWidget({Key? key}) : super(key: key); 60 | 61 | @override 62 | _MyWidgetState createState() => _MyWidgetState(); 63 | } 64 | 65 | class _MyWidgetState extends State { 66 | String _value = ''; 67 | 68 | @override 69 | Widget build(BuildContext context) { 70 | return MaterialApp( 71 | home: Scaffold( 72 | body: Column( 73 | children: [ 74 | DateTimePicker( 75 | initialValue: '2020-07-23', 76 | firstDate: DateTime(2000), 77 | lastDate: DateTime(2100), 78 | onChanged: (val) => setState(() => _value = val), 79 | ), 80 | Text(_value), 81 | ], 82 | ), 83 | ), 84 | ); 85 | } 86 | } 87 | --------------------------------------------------------------------------------