flutteradditioncalculationtimeofday

flutter timeofday calculations


in my flutter app the user picks a time and I need to simply add some hours and minute to it to display the result. Is that easily possible? Unfortunately, there doesn't seem to be a function like TimeOfDay.add().

Any ideas?


Solution

  • You can Use Date Time for that: You can add Minutes or Hours as you like.

    TimeOfDay.fromDateTime(DateTime.now().add(Duration(hours: 2))); // result is 2hrs ahead of current time