From f54fb909b233ec2eab3186fddf3dbbe4041f344c Mon Sep 17 00:00:00 2001 From: SebastienBtr Date: Fri, 3 Jan 2020 18:45:53 +0100 Subject: [PATCH 1/2] Use DateFormat to get the weekday labels By using DateFormat the labels will change according to the device language --- lib/default_weekday_labels_row.dart | 59 +++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 8 deletions(-) diff --git a/lib/default_weekday_labels_row.dart b/lib/default_weekday_labels_row.dart index 21590e3..e442614 100644 --- a/lib/default_weekday_labels_row.dart +++ b/lib/default_weekday_labels_row.dart @@ -1,18 +1,61 @@ import 'package:flutter/widgets.dart'; class CalendarroWeekdayLabelsView extends StatelessWidget { + final DateTime monday = DateTime(2020, 01, 06); + final DateTime tuesday = DateTime(2020, 01, 07); + final DateTime wednesday = DateTime(2020, 01, 08); + final DateTime thursday = DateTime(2020, 01, 09); + final DateTime friday = DateTime(2020, 01, 10); + final DateTime saturday = DateTime(2020, 01, 11); + final DateTime sunday = DateTime(2020, 01, 12); + @override Widget build(BuildContext context) { return Row( children: [ - Expanded(child: Text("Mon", textAlign: TextAlign.center)), - Expanded(child: Text("Tue", textAlign: TextAlign.center)), - Expanded(child: Text("Wed", textAlign: TextAlign.center)), - Expanded(child: Text("Thu", textAlign: TextAlign.center)), - Expanded(child: Text("Fri", textAlign: TextAlign.center)), - Expanded(child: Text("Sat", textAlign: TextAlign.center)), - Expanded(child: Text("Sun", textAlign: TextAlign.center)), + Expanded( + child: Text( + DateFormat('E').format(monday), + textAlign: TextAlign.center, + ), + ), + Expanded( + child: Text( + DateFormat('E').format(tuesday), + textAlign: TextAlign.center, + ), + ), + Expanded( + child: Text( + DateFormat('E').format(wednesday), + textAlign: TextAlign.center, + ), + ), + Expanded( + child: Text( + DateFormat('E').format(thursday), + textAlign: TextAlign.center, + ), + ), + Expanded( + child: Text( + DateFormat('E').format(friday), + textAlign: TextAlign.center, + ), + ), + Expanded( + child: Text( + DateFormat('E').format(saturday), + textAlign: TextAlign.center, + ), + ), + Expanded( + child: Text( + DateFormat('E').format(sunday), + textAlign: TextAlign.center, + ), + ), ], ); } -} \ No newline at end of file +} From 6e14c1e6005a9125a749592defbd8ab42c7279cc Mon Sep 17 00:00:00 2001 From: SebastienBtr Date: Fri, 3 Jan 2020 18:48:39 +0100 Subject: [PATCH 2/2] Add import --- lib/default_weekday_labels_row.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/default_weekday_labels_row.dart b/lib/default_weekday_labels_row.dart index e442614..efd34f1 100644 --- a/lib/default_weekday_labels_row.dart +++ b/lib/default_weekday_labels_row.dart @@ -1,4 +1,5 @@ import 'package:flutter/widgets.dart'; +import 'package:intl/intl.dart'; class CalendarroWeekdayLabelsView extends StatelessWidget { final DateTime monday = DateTime(2020, 01, 06);