Skip to content

Instantly share code, notes, and snippets.

@nbnD
Created July 15, 2022 10:43
Show Gist options
  • Save nbnD/44091498a1cd32e85a96d8abba5ec7dd to your computer and use it in GitHub Desktop.
Save nbnD/44091498a1cd32e85a96d8abba5ec7dd to your computer and use it in GitHub Desktop.
Date picker
if(pickedDate != null ){
print(pickedDate); //get the picked date in the format => 2022-07-04 00:00:00.000
String formattedDate = DateFormat('yyyy-MM-dd').format(pickedDate); // format date in required form here we use yyyy-MM-dd that means time is removed
print(formattedDate); //formatted date output using intl package => 2022-07-04
//You can format date as per your need
setState(() {
dateController.text = formattedDate; //set foratted date to TextField value.
});
}else{
print("Date is not selected");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment