A, effects,

time The date of Chinese time and Date English time and date

Second, the use of

Pub GitHub

DatePicker.showDateTimePicker(context, showTitleActions: true, onChanged: (date) {
    print('change $date');
}, onConfirm: (date) {
    print('confirm $date');
}, currentTime: DateTime(2008, 12, 31, 23, 12, 34), locale: 'zh');
Copy the code

If currentTime is not passed, the currentTime is used

Third, the principle of

1. This time and date selector is subjectflutter-cupertino-date-pickerInspired, the source code has been modified to make it more flexible, thanks to the author

2. This time selector, with two buttons on top and three column selectors on the bottom, has three scroll views

3. For decoupling, the UI part is only responsible for displaying the content and does not judge what content is displayed

The interface BasePickerModel is used to output content, and the factory method is used here. If you want to generate what kind of selector, you inherit BasePickerModel class and overload the corresponding method. Therefore, the different selectors in the above picture are actually only different factory models, but the UI part is the same content