-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
The CalendarDatePicker marks the current day (the value of CalendarDatePicker.currentDate) with a BoxDecoration, but unfortunately does so only when that date is selectable, i.e. (1) lies between the startDate and endDate and (2) satisfies the selectableDatePredicate.
There is no reason why it should do so (nor is this documented behavior). It is perfectly normal e.g. that the currentDate is a Sunday, but selection is restricted to week days; in that case, currentDate should appear both as disabled and decorated as being current. Or that selection is possible starting the day after current.
Steps to Reproduce
Execute flutter run on the code sample
Expected results:
currentDate should be displayed as disabled (not selectable because outside of the calendar range) and still be marked with a BoxDecoration as the current day (as it is displayed when inside the calendar range).
Actual results:
currentDate is not decorated as such.
Code sample
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: MyWidget(),
),
),
);
}
}
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return CalendarDatePicker(
firstDate: DateTime(2020, 1, 3),
lastDate: DateTime(2020, 1, 31),
currentDate: DateTime(2020, 1, 2), // not between first and last
initialDate: DateTime(2020, 1, 5),
onDateChanged: (_) {}
);
}
}Logs