If you want only a date without a timestamp. You can use the intl package.
main() {
var now = new DateTime.now();
var formatter = new DateFormat('yyyy-MM-dd');
String formattedDate = formatter.format(now);
print(formattedDate);
}
This requires an intl package.
source
share