How to create a timeline in flutter?
115
You can create a list of DateTime objects and then add the diary dates to that list. It would be something like this:
List<DateTime> diaryDates = [];
//use split to remove the timestamps
diaryDates.add(date.toLocal().split('')[0]);
Author by
Dalon
Updated on December 31, 2022Comments
-
Dalon 10 months
I have a weight diary where the user can daily add his weight. So now i want to show it in a line chart but i need to create a list with the dates. Is there a way to create something like this? For example the first date should be the 6th april. How to create a list where every date is listed in the right format?
-
Dalon over 2 yearsIs there a code to create automatically a list from for example the 6th april till now?
-
Damian A. over 2 yearsYou would need to store two different DateTime objects, one for today and one for the start date. Then you would need to use the difference method to calculate the number of days between the two dates. With that, you could then use a for-loop to add the days to the diaryDates list. Check the DateTime docs for more info.