Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 10 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,21 @@
In the flutter date range picker, you can customize the month cells by using the `specialDates`, `blackoutDates`, and `showTrailingAndLeadingDates` properties.

## Step 1:
In initState(), set the default dates for special, blackout dates, and set the default color values for the weekend days, special dates, current date, blackout dates, leading and trailing dates.
Inside the state, set the default color values for the weekend days, special dates, current date, blackout dates, leading and trailing dates and initialize the special and blackout dates on initState().

```xml
DateRangePickerController _controller;
List<DateTime> _blackoutDates;
List<DateTime> _specialDates;
Color weekEndColor,
specialDatesColor,
todayColor,
leadingTrailingDatesColor,
blackoutDatesColor;

late List<DateTime> _blackoutDates;
late List<DateTime> _specialDates;
final Color weekEndColor = Color(0xFF0e9aa7),
specialDatesColor = Color(0xFFf6cd61),
todayColor = Color(0xFFff6f69),
leadingTrailingDatesColor = Color(0xFF88d8b0),
blackoutDatesColor = Colors.black;

@override
void initState() {
// TODO: implement initState
_controller = DateRangePickerController();
_blackoutDates = _getBlackoutDates();
_specialDates = _getSpecialDates();
weekEndColor = Color(0xFF0e9aa7);
leadingTrailingDatesColor = Color(0xFF88d8b0);
specialDatesColor = Color(0xFFf6cd61);
todayColor = Color(0xFFff6f69);
blackoutDatesColor = Colors.black;
super.initState();
}
```
Expand All @@ -43,6 +35,7 @@ body: Card(
specialDates: _specialDates,
showTrailingAndLeadingDates: true,
blackoutDates: _blackoutDates),
selectionColor: Color(0xFFf8dbdff),
monthCellStyle: DateRangePickerMonthCellStyle(
blackoutDateTextStyle: TextStyle(
color: blackoutDatesColor,
Expand All @@ -53,7 +46,6 @@ body: Card(
color: specialDatesColor),
specialDatesTextStyle: TextStyle(color: Colors.black),
cellDecoration: BoxDecoration(shape: BoxShape.circle),
selectionColor: Color(0xFFf8dbdff),
todayTextStyle: TextStyle(color: Colors.white),
todayCellDecoration:
BoxDecoration(shape: BoxShape.circle, color: todayColor),
Expand Down
24 changes: 8 additions & 16 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,18 @@ class MonthCellCustomization extends StatefulWidget {
}

class _MonthCellCustomizationState extends State<MonthCellCustomization> {
DateRangePickerController _controller;
List<DateTime> _blackoutDates;
List<DateTime> _specialDates;
Color weekEndColor,
specialDatesColor,
todayColor,
leadingTrailingDatesColor,
blackoutDatesColor;
late List<DateTime> _blackoutDates;
late List<DateTime> _specialDates;
final Color weekEndColor = Color(0xFF0e9aa7),
specialDatesColor = Color(0xFFf6cd61),
todayColor = Color(0xFFff6f69),
leadingTrailingDatesColor = Color(0xFF88d8b0),
blackoutDatesColor = Colors.black;

@override
void initState() {
// TODO: implement initState
_controller = DateRangePickerController();
_blackoutDates = _getBlackoutDates();
_specialDates = _getSpecialDates();
weekEndColor = Color(0xFF0e9aa7);
leadingTrailingDatesColor = Color(0xFF88d8b0);
specialDatesColor = Color(0xFFf6cd61);
todayColor = Color(0xFFff6f69);
blackoutDatesColor = Colors.black;
super.initState();
}

Expand All @@ -57,6 +49,7 @@ class _MonthCellCustomizationState extends State<MonthCellCustomization> {
specialDates: _specialDates,
showTrailingAndLeadingDates: true,
blackoutDates: _blackoutDates),
selectionColor: Color(0xFFf8dbdff),
monthCellStyle: DateRangePickerMonthCellStyle(
blackoutDateTextStyle: TextStyle(
color: blackoutDatesColor,
Expand All @@ -67,7 +60,6 @@ class _MonthCellCustomizationState extends State<MonthCellCustomization> {
color: specialDatesColor),
specialDatesTextStyle: TextStyle(color: Colors.black),
cellDecoration: BoxDecoration(shape: BoxShape.circle),
selectionColor: Color(0xFFf8dbdff),
todayTextStyle: TextStyle(color: Colors.white),
todayCellDecoration:
BoxDecoration(shape: BoxShape.circle, color: todayColor),
Expand Down
164 changes: 37 additions & 127 deletions pubspec.lock
Original file line number Diff line number Diff line change
@@ -1,69 +1,62 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
archive:
dependency: transitive
description:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.11"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.2"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
version: "2.5.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
charcode:
version: "2.1.0"
characters:
dependency: transitive
description:
name: charcode
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.2"
collection:
version: "1.1.0"
charcode:
dependency: transitive
description:
name: collection
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.11"
convert:
version: "1.2.0"
clock:
dependency: transitive
description:
name: convert
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
crypto:
version: "1.1.0"
collection:
dependency: transitive
description:
name: crypto
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
version: "1.15.0"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
version: "1.0.2"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -74,74 +67,34 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
image:
dependency: transitive
description:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
intl:
dependency: transitive
description:
name: intl
url: "https://pub.dartlang.org"
source: hosted
version: "0.16.1"
version: "0.17.0"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.6"
version: "0.12.10"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.8"
version: "1.3.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.4"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0+1"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
version: "1.8.0"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -153,112 +106,69 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.5"
version: "1.8.1"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.3"
version: "1.10.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.1.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
version: "1.1.0"
syncfusion_flutter_core:
dependency: transitive
description:
name: syncfusion_flutter_core
url: "https://pub.dartlang.org"
source: hosted
version: "18.1.36"
version: "19.1.54+1"
syncfusion_flutter_datepicker:
dependency: "direct main"
description:
name: syncfusion_flutter_datepicker
url: "https://pub.dartlang.org"
source: hosted
version: "18.1.36-beta"
version: "19.1.54-beta.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.2.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.11"
version: "0.2.19"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
url_launcher:
dependency: transitive
description:
name: url_launcher
url: "https://pub.dartlang.org"
source: hosted
version: "5.4.2"
url_launcher_macos:
dependency: transitive
description:
name: url_launcher_macos
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.1+4"
url_launcher_platform_interface:
dependency: transitive
description:
name: url_launcher_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.6"
url_launcher_web:
dependency: transitive
description:
name: url_launcher_web
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.1+1"
utf:
dependency: transitive
description:
name: utf
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.0+5"
version: "1.3.0"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "3.5.0"
version: "2.1.0"
sdks:
dart: ">=2.5.0 <3.0.0"
flutter: ">=1.12.8 <2.0.0"
dart: ">=2.12.0 <3.0.0"
Loading