I am trying to display the current DateTime in a Text widget after tapping on a button. The following works, but I\'d like to change the format.
DateTime
Text
With this approach, there is no need to import any library.
DateTime now = DateTime.now(); String convertedDateTime = "${now.year.toString()}-${now.month.toString().padLeft(2,'0')}-${now.day.toString().padLeft(2,'0')} ${now.hour.toString()}-${now.minute.toString()}";