Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

editable: false not working as expected #16

Closed
chadidi opened this issue Dec 7, 2018 · 1 comment
Closed

editable: false not working as expected #16

chadidi opened this issue Dec 7, 2018 · 1 comment

Comments

@chadidi
Copy link

chadidi commented Dec 7, 2018

I've created two fields (code bellow) and I set editable to false the first field is working as expected while the second one after I click on the clear(X) button becoms editable and dosn't trigger datetime picker any more!

Padding(
    padding: EdgeInsets.all(8.0),
    child: DateTimePickerFormField(
    editable: false,
    firstDate: DateTime(DateTime.now().year, DateTime.now().month,
        DateTime.now().day - 1),
    lastDate: DateTime(DateTime.now().year, DateTime.now().month,
        DateTime.now().day + 2),
    format: dateFormat,
    style: TextStyle(
        fontFamily: "WorkSansSemiBold",
        fontSize: 16.0,
        color: Colors.black),
    decoration: InputDecoration(
        prefixIcon: Icon(Icons.timer),
        labelText: 'Start Time',
        hintStyle: TextStyle(
            fontFamily: "WorkSansSemiBold", fontSize: 17.0),
        border: OutlineInputBorder(
            borderSide: BorderSide(color: Colors.black))),
    onChanged: (dt) => setState(() => startAt = dt),
    ),
),
Padding(
    padding: EdgeInsets.all(8.0),
    child: DateTimePickerFormField(
    editable: false,
    initialValue: DateTime(
        DateTime.now().year,
        DateTime.now().month,
        DateTime.now().day,
        DateTime.now().hour,
        DateTime.now().minute + 5),
    firstDate: DateTime(
        DateTime.now().year,
        DateTime.now().month,
        DateTime.now().day,
        DateTime.now().hour,
        DateTime.now().minute + 5),
    lastDate: DateTime(DateTime.now().year, DateTime.now().month,
        DateTime.now().day + 2),
    format: dateFormat,
    style: TextStyle(
        fontFamily: "WorkSansSemiBold",
        fontSize: 16.0,
        color: Colors.black),
    decoration: InputDecoration(
        prefixIcon: Icon(Icons.timer),
        labelText: 'End Time',
        hintStyle: TextStyle(
            fontFamily: "WorkSansSemiBold", fontSize: 17.0),
        border: OutlineInputBorder(
            borderSide: BorderSide(color: Colors.black))),
    onChanged: (dt) => setState(() => endAt = dt),
    ),
),
@chadidi
Copy link
Author

chadidi commented Dec 7, 2018

@jifalops I did this change (code below) and it works as expected, I think the problem happened because of adding time to firstDate

DateTime.now().hour,
DateTime.now().minute + 5
Padding(
    padding: EdgeInsets.all(8.0),
    child: DateTimePickerFormField(
    editable: false,
    initialValue: DateTime(
        DateTime.now().year,
        DateTime.now().month,
        DateTime.now().day,
        DateTime.now().hour,
        DateTime.now().minute + 5),
    firstDate: DateTime(DateTime.now().year, DateTime.now().month,
        DateTime.now().day),
    lastDate: DateTime(DateTime.now().year, DateTime.now().month,
        DateTime.now().day + 1),
    format: dateFormat,
    style: TextStyle(
        fontFamily: "WorkSansSemiBold",
        fontSize: 16.0,
        color: Colors.black),
    decoration: InputDecoration(
        prefixIcon: Icon(Icons.timer),
        labelText: 'Start Time',
        hintStyle: TextStyle(
            fontFamily: "WorkSansSemiBold", fontSize: 17.0),
        border: OutlineInputBorder(
            borderSide: BorderSide(color: Colors.black))),
    onChanged: (dt) => setState(() => startAt = dt),
    ),
),
Padding(
    padding: EdgeInsets.all(8.0),
    child: DateTimePickerFormField(
    editable: false,
    initialValue: DateTime(
        DateTime.now().year,
        DateTime.now().month,
        DateTime.now().day,
        DateTime.now().hour,
        DateTime.now().minute + 35),
    firstDate: DateTime(DateTime.now().year, DateTime.now().month,
        DateTime.now().day),
    lastDate: DateTime(DateTime.now().year, DateTime.now().month,
        DateTime.now().day + 1),
    format: dateFormat,
    style: TextStyle(
        fontFamily: "WorkSansSemiBold",
        fontSize: 16.0,
        color: Colors.black),
    decoration: InputDecoration(
        prefixIcon: Icon(Icons.timer),
        labelText: 'End Time',
        hintStyle: TextStyle(
            fontFamily: "WorkSansSemiBold", fontSize: 17.0),
        border: OutlineInputBorder(
            borderSide: BorderSide(color: Colors.black))),
    onChanged: (dt) => setState(() => endAt = dt),
    ),
),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants