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
10 changes: 5 additions & 5 deletions example/ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=/Users/vivek/development/flutter"
export "FLUTTER_APPLICATION_PATH=/Users/vivek/StudioProjects/DatePickerTimelineFlutter/example"
export "FLUTTER_TARGET=lib/main.dart"
export "FLUTTER_ROOT=D:\flutter"
export "FLUTTER_APPLICATION_PATH=D:\gcloud_projects\flutterapp\datetime\DatePickerTimelineFlutter\example"
export "FLUTTER_TARGET=lib\main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build/ios"
export "SYMROOT=${SOURCE_ROOT}/../build\ios"
export "OTHER_LDFLAGS=$(inherited) -framework Flutter"
export "FLUTTER_FRAMEWORK_DIR=/Users/vivek/development/flutter/bin/cache/artifacts/engine/ios"
export "FLUTTER_FRAMEWORK_DIR=D:\flutter\bin\cache\artifacts\engine\ios"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "DART_OBFUSCATION=false"
Expand Down
51 changes: 44 additions & 7 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class _MyHomePageState extends State<MyHomePage> {

DateTime _selectedValue = DateTime.now();


@override
void initState() {
super.initState();
Expand All @@ -38,12 +37,12 @@ class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
floatingActionButton: FloatingActionButton(
child: Icon(Icons.replay),
onPressed: () {
_controller.animateToSelection();
},
),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.replay),
onPressed: () {
_controller.animateToSelection();
},
),
appBar: AppBar(
title: Text(widget.title),
),
Expand Down Expand Up @@ -83,6 +82,44 @@ class _MyHomePageState extends State<MyHomePage> {
},
),
),
Padding(
padding: const EdgeInsets.all(40.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
RaisedButton(
color: Colors.lightBlueAccent,
onPressed: () {
//Make sure within valid date range of DatePicker.
//Skipping the check here as its example
DateTime _currentDate = _controller.getCurrentDate();
_controller.setCurrentDate(
_currentDate.add(Duration(days: 1)));
_controller.animateToSelection();
},
child: Text(
"Set Next day",
style: TextStyle(fontSize: 15),
),
),
RaisedButton(
color: Colors.lightBlueAccent,
onPressed: () {
//Make sure within valid date range of DatePicker.
//Skipping the check here as its example
DateTime _currentDate = _controller.getCurrentDate();
_controller.setCurrentDate(
_currentDate.subtract(Duration(days: 1)));
_controller.animateToSelection();
},
child: Text(
"Set Previous day",
style: TextStyle(fontSize: 15),
),
),
],
),
)
],
),
));
Expand Down
40 changes: 20 additions & 20 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,42 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.2"
version: "2.5.0-nullsafety.1"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.1.0-nullsafety.1"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
version: "1.1.0-nullsafety.3"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.3"
version: "1.2.0-nullsafety.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
version: "1.1.0-nullsafety.1"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.13"
version: "1.15.0-nullsafety.3"
cupertino_icons:
dependency: "direct main"
description:
Expand All @@ -56,14 +56,14 @@ packages:
path: ".."
relative: true
source: path
version: "1.2.0"
version: "1.2.1"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.2.0-nullsafety.1"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -87,21 +87,21 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.8"
version: "0.12.10-nullsafety.1"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.8"
version: "1.3.0-nullsafety.3"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.8.0-nullsafety.1"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -113,55 +113,55 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.8.0-nullsafety.2"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.5"
version: "1.10.0-nullsafety.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.1.0-nullsafety.1"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
version: "1.1.0-nullsafety.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.2.0-nullsafety.1"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.17"
version: "0.2.19-nullsafety.2"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.0-nullsafety.3"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
version: "2.1.0-nullsafety.3"
sdks:
dart: ">=2.9.0-14.0.dev <3.0.0"
dart: ">=2.10.0-110 <2.11.0"
42 changes: 35 additions & 7 deletions lib/date_picker_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ class _DatePickerState extends State<DatePicker> {
}
}

void setCurrentDate(DateTime date) {
setState(() {
_currentDate = date;
});
}

@override
Widget build(BuildContext context) {
return Container(
Expand Down Expand Up @@ -191,13 +197,19 @@ class _DatePickerState extends State<DatePicker> {
date: date,
monthTextStyle: isDeactivated
? deactivatedMonthStyle
: isSelected ? selectedMonthStyle : widget.monthTextStyle,
: isSelected
? selectedMonthStyle
: widget.monthTextStyle,
dateTextStyle: isDeactivated
? deactivatedDateStyle
: isSelected ? selectedDateStyle : widget.dateTextStyle,
: isSelected
? selectedDateStyle
: widget.dateTextStyle,
dayTextStyle: isDeactivated
? deactivatedDayStyle
: isSelected ? selectedDayStyle : widget.dayTextStyle,
: isSelected
? selectedDayStyle
: widget.dayTextStyle,
width: widget.width,
locale: widget.locale,
selectionColor:
Expand All @@ -207,12 +219,10 @@ class _DatePickerState extends State<DatePicker> {
if (isDeactivated) return;

// A date is selected
if (widget.onDateChange != null ) {
if (widget.onDateChange != null) {
widget.onDateChange(selectedDate);
setCurrentDate(selectedDate);
}
setState(() {
_currentDate = selectedDate;
});
},
);
},
Expand All @@ -236,6 +246,24 @@ class DatePickerController {
_datePickerState = state;
}

void setCurrentDate(DateTime date) {
assert(_datePickerState != null,
'DatePickerController is not attached to any DatePicker View.');

//Allows external widgets to set date of DatePicker.
//Propersolution would be to implement standard state management.
_datePickerState.setCurrentDate(date);
}

DateTime getCurrentDate() {
assert(_datePickerState != null,
'DatePickerController is not attached to any DatePicker View.');

//Allows external widgets to get date of DatePicker
//More propersolution would be to implement standard state management.
return _datePickerState._currentDate;
}

void jumpToSelection() {
assert(_datePickerState != null,
'DatePickerController is not attached to any DatePicker View.');
Expand Down
Loading