[FIXED] How to add time and duration in flutter?

Issue

I have a start time and time duration. Eg: start time is 10:00pm and duration is 120minutes. I want the output like 12:00pm.Add the duration with the time.

Solution

If your 10:00pm’s DataType is DateTime then use this code.

  DateTime time = DateTime.now(); // Here you can get your current local time
    time.add(Duration(minutes: 120));
    print(time);

Answered By – Abir Ahsan

Answer Checked By – David Marino (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published