Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dart: how do I get first day of week for current locale?

Tags:

dart

It can be done in Java by

com.ibm.icu.util.Calendar.getInstance(Locale alocale).getFirstDayOfWeek()

Is there an equivalent way to get it in Dart?

like image 900
Bob Wang Avatar asked Aug 07 '17 17:08

Bob Wang


2 Answers

This thing worked for me

DateTime today = DateTime.now();             
_firstDayOfTheweek = today.subtract(new Duration(days: today.weekday));
like image 160
Aravind N Avatar answered Oct 14 '22 01:10

Aravind N


With Flutter you can use just:

MaterialLocalizations.of(context).firstDayOfWeekIndex;

like image 33
intra Avatar answered Oct 14 '22 02:10

intra