Reputation: 419
Is there a way of getting the first day of the week from device info or locale in Flutter? I use some libraries for which it has to be manually set, so I need to get it somehow. Or maybe, at least, these is even a library you might know which returns first day of the week by locale code?
Upvotes: 1
Views: 448
Reputation: 4838
You can use subtract
method to get first day of the week according to user's device locate
DateTime today = DateTime.now();
_firstDayOfTheweek = today.subtract(new Duration(days: today.weekday));
Or you can do that with material localization and get it from context
MaterialLocalizations.of(context).firstDayOfWeekIndex;
Upvotes: 1