How to format TimeOfDay to String in flutter
Doing a toString
to a TimeOfDay
object will return you the default implementation of toString
which as per documentation:
Returns a string representation of this object.
What are you looking for here is to format
it instead.
TimeOfDay _currentTime = TimeOfDay.now();Text("Current Time: ${_currentTime.format(context)}")
Please also take a look at the official documentation in order to have a better understanding of why toString
is not doing what you expect.
https://api.flutter.dev/flutter/material/TimeOfDay-class.html