1

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?

tmaihoff
  • 2,867
  • 1
  • 18
  • 40

1 Answers1

6

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
anmol.majhail
  • 48,256
  • 14
  • 136
  • 105