yangyxd / flutter_picker

Flutter picker plugin
MIT License
691 stars 260 forks source link

Default value for DateTime Picker #31

Open net23 opened 5 years ago

net23 commented 5 years ago

Can I set the default time for the DateTime Picker? I have tried selecteds, but the picker always uses the current time:


  showPickerDateTime(BuildContext context) {
    Picker(
        hideHeader: true,
        adapter: DateTimePickerAdapter(
            type: PickerDateTimeType.kHMS,
        ),
        title: Text("Select run time"),
        cancelText: "Cancel",
        confirmText: "Select",
        selecteds: [0, 0, 0, 1, 0, 10, 0, 0],
        onConfirm: (Picker picker, List value) {
          print(picker.adapter.text);
        },
        onSelect: (Picker picker, int index, List<int> selecteds) {}
    ).showDialog(context);
  }
phamminhtuan commented 5 years ago

showPickerDate(BuildContext context) { Picker( hideHeader: true, adapter: DateTimePickerAdapter(value: _date), title: Text("Select Data"), onConfirm: (Picker picker, List value) { _date = (picker.adapter as DateTimePickerAdapter).value; textController.text = DateFormat.yMd().format(_date); }).showDialog(context); }

you can change the value in DateTimePickerAdapter