Want to get last midnight in Dart? This should do the same
1 2 | final now = DateTime.now(); final lastMidnight = new DateTime(now.year, now.month, now.day); |
You can use this way to get different times of this day
1 2 3 | final tomorrowNoon = new DateTime(now.year, now.month, now.day + 1, 12); final yesterdaySixThirty = new DateTime(now.year, now.month, now.day - 1, 6, 30); |
Depending on what you want can absolute values be more safe because adding/subtracting Duration can result in surprises because of leap years and daylight saving time.
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.