I am using the flutter showDatePicker
widget https://api.flutter.dev/flutter/material/showDatePicker.html
When the date picker popup loads by default the start of the week is Sunday, I would like to change this to Monday.
Any suggestions on how I can achieve this?
Future<void> _selectDate(BuildContext context) async {
final DateTime picked = await showDatePicker(
context: context,
initialDate: _selectedDate,
firstDate: firstDate,
lastDate: lastDate,
locale: const Locale('en', 'GB'),
);
if (picked != null && picked != _selectedDate) {
// update the calendar slider with new date
setState(() {
_selectedDate = picked.add(Duration(hours: 1));
});
}
Add a locale
that uses Monday as the first day of the week, for example:
Future<DateTime> selectedDate = showDatePicker(
context: context,
locale: const Locale('en', 'GB'),
// etc
You have to add the localization library too, as described here, adding this to your MaterialApp
:
localizationsDelegates: GlobalMaterialLocalizations.delegates,
supportedLocales: [
const Locale('en', 'US'),
const Locale('en', 'GB'),
],
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With