Skip to content
Open
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
30 changes: 11 additions & 19 deletions lib/date_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class DatePicker {
/// backgroundColor: [Color] background color of the dialog
/// itemTextStyle: [TextStyle] item TextStyle of the picker
/// titleText: [String] text of the dialog's title
/// titleTextStyle: [TextStyle] item TextStyle of the dialog's title
/// confirmText: [String] text of the dialog's confirm button
/// cancelText: [String] text of the dialog's cancel button
static Future<DateTime?> showSimpleDatePicker(
Expand All @@ -100,6 +101,7 @@ class DatePicker {
Color? textColor,
TextStyle? itemTextStyle,
String? titleText,
TextStyle? titleTextStyle,
String? confirmText,
String? cancelText,
bool looping: false,
Expand Down Expand Up @@ -136,18 +138,16 @@ class DatePicker {
initialDate = DateTime.now();
}

if (backgroundColor == null)
backgroundColor = DateTimePickerTheme.Default.backgroundColor;
if (backgroundColor == null) backgroundColor = DateTimePickerTheme.Default.backgroundColor;
// if (itemTextStyle == null)
// itemTextStyle = DateTimePickerTheme.Default.itemTextStyle;

if (textColor == null)
textColor = DateTimePickerTheme.Default.itemTextStyle.color;
if (textColor == null) textColor = DateTimePickerTheme.Default.itemTextStyle.color;

var datePickerDialog = AlertDialog(
title: Text(
titleText ?? "Select Date",
style: TextStyle(color: textColor),
style: titleTextStyle ?? TextStyle(color: textColor),
),
contentPadding: EdgeInsets.symmetric(vertical: 0, horizontal: 14),
backgroundColor: backgroundColor,
Expand All @@ -170,13 +170,9 @@ class DatePicker {
looping: looping,
),
),
actions:
reverse ? listButtonActions.reversed.toList() : listButtonActions,
actions: reverse ? listButtonActions.reversed.toList() : listButtonActions,
);
return showDialog(
useRootNavigator: false,
context: context,
builder: (context) => datePickerDialog);
return showDialog(useRootNavigator: false, context: context, builder: (context) => datePickerDialog);
}
}

Expand Down Expand Up @@ -225,14 +221,12 @@ class _DatePickerRoute<T> extends PopupRoute<T> {
@override
AnimationController createAnimationController() {
assert(_animationController == null);
_animationController =
BottomSheet.createAnimationController(navigator!.overlay!);
_animationController = BottomSheet.createAnimationController(navigator!.overlay!);
return _animationController!;
}

@override
Widget buildPage(BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation) {
Widget buildPage(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
double height = pickerTheme!.pickerHeight;
if (pickerTheme!.title != null || pickerTheme!.showTitle) {
height += pickerTheme!.titleHeight;
Expand All @@ -255,8 +249,7 @@ class _DatePickerComponent extends StatelessWidget {
final _DatePickerRoute route;
final double _pickerHeight;

_DatePickerComponent({required this.route, required pickerHeight})
: this._pickerHeight = pickerHeight;
_DatePickerComponent({required this.route, required pickerHeight}) : this._pickerHeight = pickerHeight;

@override
Widget build(BuildContext context) {
Expand All @@ -277,8 +270,7 @@ class _DatePickerComponent extends StatelessWidget {
builder: (BuildContext context, Widget? child) {
return ClipRect(
child: CustomSingleChildLayout(
delegate: _BottomPickerLayout(route.animation!.value,
contentHeight: _pickerHeight),
delegate: _BottomPickerLayout(route.animation!.value, contentHeight: _pickerHeight),
child: pickerWidget,
),
);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 1.0.3
homepage: https://github.com/kfiross/flutter_holo_date_picker

environment:
sdk: '>=2.12.0 <3.0.0'
sdk: ">=2.12.0 <3.0.0"

dependencies:
flutter:
Expand Down