I have a date string in flutter which i am trying to add week, month and year but not sure how to do it.
in android java, we can add weeks, month, year in the following way
Calendar cal = Calendar.getInstance();
cal.setTime('2019-09-04');
cal.add(Calendar.WEEK_OF_MONTH,1); // add one week
cal.add(Calendar.WEEK_OF_MONTH, 2 ); // add two weeks
cal.add(Calendar.MONTH, 1); // add # of month
cal.add(Calendar.MONTH, 3); // add 3 months
cal.add(Calendar.YEAR, 1); // add 1 year
however, i dont know how to add this in flutter. i know i can use duration but it only accept number of days cal.add(new Duration(days: 30)); if i use duration, then i need to figure out how many number of days in a month, week, or year and it is more math. with the above code in android java, adding weeks , months or year will be taken by android. is there a way for flutter to add weeks, months or year to a date?
for example: if i have 01/31/2019 and i want to add a month then new date should be 02/28/2019. if i want add a month to 02/28/2019 then output should be 03/31/2019
same goes for weeks and years. flutter should add a week to a date if specify or a year and so on. thanks in advance