|
|
@@ -8,8 +8,7 @@ class CustomPicker extends CommonPickerModel {
|
|
|
return '$value'.padLeft(length, "0");
|
|
|
}
|
|
|
|
|
|
- CustomPicker({DateTime currentTime, LocaleType locale})
|
|
|
- : super(locale: locale) {
|
|
|
+ CustomPicker({DateTime currentTime, LocaleType locale}) : super(locale: locale) {
|
|
|
this.currentTime = currentTime ?? DateTime.now();
|
|
|
this.setLeftIndex(this.currentTime.hour);
|
|
|
this.setMiddleIndex(this.currentTime.minute);
|
|
|
@@ -61,20 +60,10 @@ class CustomPicker extends CommonPickerModel {
|
|
|
@override
|
|
|
DateTime finalTime() {
|
|
|
return currentTime.isUtc
|
|
|
- ? DateTime.utc(
|
|
|
- currentTime.year,
|
|
|
- currentTime.month,
|
|
|
- currentTime.day,
|
|
|
- this.currentLeftIndex(),
|
|
|
- this.currentMiddleIndex(),
|
|
|
- this.currentRightIndex())
|
|
|
- : DateTime(
|
|
|
- currentTime.year,
|
|
|
- currentTime.month,
|
|
|
- currentTime.day,
|
|
|
- this.currentLeftIndex(),
|
|
|
- this.currentMiddleIndex(),
|
|
|
- this.currentRightIndex());
|
|
|
+ ? DateTime.utc(currentTime.year, currentTime.month, currentTime.day,
|
|
|
+ this.currentLeftIndex(), this.currentMiddleIndex(), this.currentRightIndex())
|
|
|
+ : DateTime(currentTime.year, currentTime.month, currentTime.day, this.currentLeftIndex(),
|
|
|
+ this.currentMiddleIndex(), this.currentRightIndex());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -112,14 +101,10 @@ class HomePage extends StatelessWidget {
|
|
|
headerColor: Colors.orange,
|
|
|
backgroundColor: Colors.blue,
|
|
|
itemStyle: TextStyle(
|
|
|
- color: Colors.white,
|
|
|
- fontWeight: FontWeight.bold,
|
|
|
- fontSize: 18),
|
|
|
- doneStyle:
|
|
|
- TextStyle(color: Colors.white, fontSize: 16)),
|
|
|
+ color: Colors.white, fontWeight: FontWeight.bold, fontSize: 18),
|
|
|
+ doneStyle: TextStyle(color: Colors.white, fontSize: 16)),
|
|
|
onChanged: (date) {
|
|
|
- print('change $date in time zone ' +
|
|
|
- date.timeZoneOffset.inHours.toString());
|
|
|
+ print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
|
|
|
}, onConfirm: (date) {
|
|
|
print('confirm $date');
|
|
|
}, currentTime: DateTime.now(), locale: LocaleType.en);
|
|
|
@@ -130,10 +115,8 @@ class HomePage extends StatelessWidget {
|
|
|
)),
|
|
|
FlatButton(
|
|
|
onPressed: () {
|
|
|
- DatePicker.showTimePicker(context, showTitleActions: true,
|
|
|
- onChanged: (date) {
|
|
|
- print('change $date in time zone ' +
|
|
|
- date.timeZoneOffset.inHours.toString());
|
|
|
+ DatePicker.showTimePicker(context, showTitleActions: true, onChanged: (date) {
|
|
|
+ print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
|
|
|
}, onConfirm: (date) {
|
|
|
print('confirm $date');
|
|
|
}, currentTime: DateTime.now());
|
|
|
@@ -142,14 +125,25 @@ class HomePage extends StatelessWidget {
|
|
|
'show time picker',
|
|
|
style: TextStyle(color: Colors.blue),
|
|
|
)),
|
|
|
+ FlatButton(
|
|
|
+ onPressed: () {
|
|
|
+ DatePicker.showTime12hPicker(context, showTitleActions: true, onChanged: (date) {
|
|
|
+ print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
|
|
|
+ }, onConfirm: (date) {
|
|
|
+ print('confirm $date');
|
|
|
+ }, currentTime: DateTime.now());
|
|
|
+ },
|
|
|
+ child: Text(
|
|
|
+ 'show 12H time picker with AM/PM',
|
|
|
+ style: TextStyle(color: Colors.blue),
|
|
|
+ )),
|
|
|
FlatButton(
|
|
|
onPressed: () {
|
|
|
DatePicker.showDateTimePicker(context,
|
|
|
showTitleActions: true,
|
|
|
minTime: DateTime(2020, 5, 5, 20, 50),
|
|
|
maxTime: DateTime(2020, 6, 7, 05, 09), onChanged: (date) {
|
|
|
- print('change $date in time zone ' +
|
|
|
- date.timeZoneOffset.inHours.toString());
|
|
|
+ print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
|
|
|
}, onConfirm: (date) {
|
|
|
print('confirm $date');
|
|
|
}, locale: LocaleType.zh);
|
|
|
@@ -160,10 +154,8 @@ class HomePage extends StatelessWidget {
|
|
|
)),
|
|
|
FlatButton(
|
|
|
onPressed: () {
|
|
|
- DatePicker.showDateTimePicker(context, showTitleActions: true,
|
|
|
- onChanged: (date) {
|
|
|
- print('change $date in time zone ' +
|
|
|
- date.timeZoneOffset.inHours.toString());
|
|
|
+ DatePicker.showDateTimePicker(context, showTitleActions: true, onChanged: (date) {
|
|
|
+ print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
|
|
|
}, onConfirm: (date) {
|
|
|
print('confirm $date');
|
|
|
}, currentTime: DateTime(2008, 12, 31, 23, 12, 34));
|
|
|
@@ -174,15 +166,11 @@ class HomePage extends StatelessWidget {
|
|
|
)),
|
|
|
FlatButton(
|
|
|
onPressed: () {
|
|
|
- DatePicker.showDateTimePicker(context, showTitleActions: true,
|
|
|
- onChanged: (date) {
|
|
|
- print('change $date in time zone ' +
|
|
|
- date.timeZoneOffset.inHours.toString());
|
|
|
+ DatePicker.showDateTimePicker(context, showTitleActions: true, onChanged: (date) {
|
|
|
+ print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
|
|
|
}, onConfirm: (date) {
|
|
|
print('confirm $date');
|
|
|
- },
|
|
|
- currentTime: DateTime(2008, 12, 31, 23, 12, 34),
|
|
|
- locale: LocaleType.nl);
|
|
|
+ }, currentTime: DateTime(2008, 12, 31, 23, 12, 34), locale: LocaleType.nl);
|
|
|
},
|
|
|
child: Text(
|
|
|
'show date time picker (Dutch)',
|
|
|
@@ -190,15 +178,11 @@ class HomePage extends StatelessWidget {
|
|
|
)),
|
|
|
FlatButton(
|
|
|
onPressed: () {
|
|
|
- DatePicker.showDateTimePicker(context, showTitleActions: true,
|
|
|
- onChanged: (date) {
|
|
|
- print('change $date in time zone ' +
|
|
|
- date.timeZoneOffset.inHours.toString());
|
|
|
+ DatePicker.showDateTimePicker(context, showTitleActions: true, onChanged: (date) {
|
|
|
+ print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
|
|
|
}, onConfirm: (date) {
|
|
|
print('confirm $date');
|
|
|
- },
|
|
|
- currentTime: DateTime(2008, 12, 31, 23, 12, 34),
|
|
|
- locale: LocaleType.ru);
|
|
|
+ }, currentTime: DateTime(2008, 12, 31, 23, 12, 34), locale: LocaleType.ru);
|
|
|
},
|
|
|
child: Text(
|
|
|
'show date time picker (Russian)',
|
|
|
@@ -206,15 +190,11 @@ class HomePage extends StatelessWidget {
|
|
|
)),
|
|
|
FlatButton(
|
|
|
onPressed: () {
|
|
|
- DatePicker.showDateTimePicker(context, showTitleActions: true,
|
|
|
- onChanged: (date) {
|
|
|
- print('change $date in time zone ' +
|
|
|
- date.timeZoneOffset.inHours.toString());
|
|
|
+ DatePicker.showDateTimePicker(context, showTitleActions: true, onChanged: (date) {
|
|
|
+ print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
|
|
|
}, onConfirm: (date) {
|
|
|
print('confirm $date');
|
|
|
- },
|
|
|
- currentTime: DateTime.utc(2019, 12, 31, 23, 12, 34),
|
|
|
- locale: LocaleType.de);
|
|
|
+ }, currentTime: DateTime.utc(2019, 12, 31, 23, 12, 34), locale: LocaleType.de);
|
|
|
},
|
|
|
child: Text(
|
|
|
'show date time picker in UTC (German)',
|
|
|
@@ -222,15 +202,11 @@ class HomePage extends StatelessWidget {
|
|
|
)),
|
|
|
FlatButton(
|
|
|
onPressed: () {
|
|
|
- DatePicker.showPicker(context, showTitleActions: true,
|
|
|
- onChanged: (date) {
|
|
|
- print('change $date in time zone ' +
|
|
|
- date.timeZoneOffset.inHours.toString());
|
|
|
+ DatePicker.showPicker(context, showTitleActions: true, onChanged: (date) {
|
|
|
+ print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
|
|
|
}, onConfirm: (date) {
|
|
|
print('confirm $date');
|
|
|
- },
|
|
|
- pickerModel: CustomPicker(currentTime: DateTime.now()),
|
|
|
- locale: LocaleType.en);
|
|
|
+ }, pickerModel: CustomPicker(currentTime: DateTime.now()), locale: LocaleType.en);
|
|
|
},
|
|
|
child: Text(
|
|
|
'show custom time picker,\nyou can custom picker model like this',
|