anicdh / date_range_picker Goto Github PK
View Code? Open in Web Editor NEWFlutter date range pickers use a dialog window to select a range of date on mobile.
License: MIT License
Flutter date range pickers use a dialog window to select a range of date on mobile.
License: MIT License
Hi,
This is my code
var picked = await DateRagePicker.showDatePicker(
context: context,
initialFirstDate: DateTime.fromMillisecondsSinceEpoch(
_flightSearch.itineraries[0].departureDate),
initialLastDate: (DateTime.fromMillisecondsSinceEpoch(
_flightSearch.itineraries[1].departureDate)),
firstDate: DateTime.now().add(Duration(days: -1)) ,
lastDate: tenYears,
);
when the picker is opened and the user selects the last year and the last date, MonthPickers " assert(!selectedFirstDate.isBefore(firstDate) &&
(selectedLastDate == null || !selectedLastDate.isAfter(lastDate)))" is fired.
Function showDatePicker crash with this error when you pick a range of Dates and tap on "OK" button.
type 'List' is not a subtype of type 'List' of 'result'.
flutter: When the exception was thrown, this was the stack:
flutter: #0 _ModalRoute&TransitionRoute&LocalHistoryRoute.didPop (package:flutter/src/widgets/routes.dart)
flutter: #1 NavigatorState.pop (package:flutter/src/widgets/navigator.dart:1824:15)
flutter: #2 Navigator.pop (package:flutter/src/widgets/navigator.dart:1183:34)
flutter: #3 _DatePickerDialogState._handleOk (package:date_range_picker/date_range_picker.dart:1114:15)
flutter: #4 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14)
flutter: #5 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:562:30)
flutter: #6 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
flutter: #7 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
flutter: #8 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:175:7)
flutter: #9 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:315:9)
flutter: #10 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73:12)
flutter: #11 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:11)
flutter: #12 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:180:19)
flutter: #13 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:158:22)
flutter: #14 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:138:7)
flutter: #15 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:101:7)
flutter: #16 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:85:7)
flutter: #17 _invoke1 (dart:ui/hooks.dart:168:13)
flutter: #18 _dispatchPointerDataPacket (dart:ui/hooks.dart:122:5)
I have provided a method to selectableDayPredicate
to disable certain dates. However, I am still able to select these disabled dates as long as the initial start and end date lie out side of this range.
For example, selectableDayPredicate
returns false for 2019-06-20, and is thus disabled on the date picker. If you select a range of 2019-06-01 to 2019-06-25, you are able to even though it includes a disabled date.
Any way around this?
Hi,
Thanks for library. Can you enforce that user MUST select range not one date ?
Or maybe allow from/to with empty other one ? Then accept null and one of initial values.
Thanks
Michal
When will Null-Safety support come?
In my case I need to give to user the possibility to select max 7 days span. At the moment the span selection is free. It will be a very good feature to add to this package, something like:
DateRagePicker.showDatePicker(
context: context,
…
maxSelectableSpan: 7
)
Expected a value of type 'List?', but got one of type 'List<DateTime?>' Im getting this issue anyone knows
Visually, I don't see the overflow, but I get this when clicking on a Date Range field, which pops up a DateRangePicker
:
I/flutter ( 6785): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter ( 6785): The following assertion was thrown during layout:
I/flutter ( 6785): A RenderFlex overflowed by 13 pixels on the bottom.
I/flutter ( 6785):
I/flutter ( 6785): The relevant error-causing widget was:
I/flutter ( 6785): Column
I/flutter ( 6785): file:///Users/anthony/flutter/.pub-cache/hosted/pub.dartlang.org/date_range_picker-1.0.6/lib/date_range_picker.dart:1180:24
I/flutter ( 6785):
I/flutter ( 6785): The overflowing RenderFlex has an orientation of Axis.vertical.
I/flutter ( 6785): The edge of the RenderFlex that is overflowing has been marked in the rendering with a yellow and
I/flutter ( 6785): black striped pattern. This is usually caused by the contents being too big for the RenderFlex.
I/flutter ( 6785): Consider applying a flex factor (e.g. using an Expanded widget) to force the children of the
I/flutter ( 6785): RenderFlex to fit within the available space instead of being sized to their natural size.
I/flutter ( 6785): This is considered an error condition because it indicates that there is content that cannot be
I/flutter ( 6785): seen. If the content is legitimately bigger than the available space, consider clipping it with a
I/flutter ( 6785): ClipRect widget before putting it in the flex, or using a scrollable container rather than a Flex,
I/flutter ( 6785): like a ListView.
I/flutter ( 6785): The specific RenderFlex in question is: RenderFlex#18147 relayoutBoundary=up7 OVERFLOWING:
I/flutter ( 6785): needs compositing
I/flutter ( 6785): creator: Column ← SizedBox ← LayoutBuilder ← OrientationBuilder ← DefaultTextStyle ←
I/flutter ( 6785): AnimatedDefaultTextStyle ← _InkFeatures-[GlobalKey#55cb6 ink renderer] ←
I/flutter ( 6785): NotificationListener<LayoutChangedNotification> ← CustomPaint ← _ShapeBorderPaint ← PhysicalShape
I/flutter ( 6785): ← _MaterialInterior ← ⋯
I/flutter ( 6785): parentData: <none> (can use size)
I/flutter ( 6785): constraints: BoxConstraints(w=312.7, 0.0<=h<=459.1)
I/flutter ( 6785): size: Size(312.7, 459.1)
I/flutter ( 6785): direction: vertical
I/flutter ( 6785): mainAxisAlignment: start
I/flutter ( 6785): mainAxisSize: min
I/flutter ( 6785): crossAxisAlignment: stretch
I/flutter ( 6785): verticalDirection: down
I/flutter ( 6785): ◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤
I/flutter ( 6785): ════════════════════════════════════════════════════════════════════════════════════════════════════
I am running the Android Emulator for a Pixel 3a:
I'm using Flutter version 1.12.13+hotfix.8 on stable channel.
The dialog won't show up and there's no error that I can track
I getting this error Unhandled Exception: 'package:date_range_picker/date_range_picker.dart': Failed assertion: line 1280 pos 10: '!initialLastDate.isAfter(lastDate)': initialDate must be on or before lastDate
and the dialog won't show up. Any help would appreciated. 🙏
This is my code :
Future<List<DateTime>> _showDateRangePicker() async {
final List<DateTime> pickedDateRange = await DateRangePicker.showDatePicker(
context: context,
initialFirstDate: new DateTime(2020, 1, 1),
initialLastDate: new DateTime(2020, 4, 1),
firstDate: new DateTime(2015),
lastDate: new DateTime(2020)
);
if(pickedDateRange == null && pickedDateRange.length < 2) {
return [];
}
return pickedDateRange;
}
Just like bootstrap daterangepicker. When user have to select a long range, like 5 years, use have to slide 60 times to back to first date, and then slide back 60 times again to choose second date.
It will be better if you provide a function allow select year, and month.
Thank you
I would like to change header background color/select date color and ok/cancel text color to a same color. So how to change calendar primary color?
Is it possible to add the feature to change the "Cancel" and "Ok" titles?
Thank you!
I've run into an issue where if the DateRangePicker
returns with only one date selected, the List<DateTime>
returned will be of length == 2
but only the first item will be a valid DateTime
object while the second item is null
, which is very misleading if I'm using the length of the List<DateTime>
to verify that the user has selected a date range rather than a single date.
When the Input Method still not yet fallen down, It will make the lower half of the picker overflows.
Text Direction RTL doesn't work as Expected, the start date and end date doesn't show with correct direction.
I'm new in flutter
Could you please help me in understanding the change in font-size and color of "Cancel" and "Ok" button
Thanks for the library,
Is there a way to Extract First Date and Second Date and Store them in two variables of type string? @anicdh
Hello,
When I fill up locale variable with a location different to Locale('en') I've run into an issue:
I/flutter ( 5182): When the exception was thrown, this was the stack:
I/flutter ( 5182): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:50:5)
I/flutter ( 5182): #1 _DatePickerDialogState.didChangeDependencies
package:date_range_picker/date_range_picker.dart:1033
Localizations variable in date_range_picker.dart file is null.
If I change Locale('fr') to Locale('en') localizations variable is not null and all run properly.
Code:
final List picked = await DateRangePicker.showDatePicker(
context: context,
initialFirstDate: DateTime.now(),
initialLastDate: (DateTime.now()).add(Duration(days: 2)),
firstDate: (DateTime.now()).subtract(Duration(days: 1)),
lastDate: (DateTime.now()).add(Duration(days: 365)),
locale: Locale('fr')
);
Any way around this?
Thanks.
I want to launch the calendar without a second date pre-selected, is it possible?
Thanks
I have a err when run on flutter 2.6.0-11.0.pre • channel dev, please help me fix this, thanks
Great work THANKS!
How to change picker color in an easy way ?
Thanks for this great date picker widget! Can you please add a license? Currently the LICENSE
file is empty. Thanks.
ButtonBar.bar constructor used in _DatePickerDialogState.buld code is marked as deprecated.
Deprecation note says "This feature was deprecated after v1.9.1." and suggests to "Use ButtonBarTheme instead.", see flutter/flutter#37544 for details.
Not sure that's a reason for concern, but nonetheless
The selected date drops when switching a year through the year picker. I want to select for example June 5th 2015 to June 5th 2019 without having to scroll through dates manually. Is it possible to add such a feature in? Thanks
whenever i am selecting last index of list in year list : for instance i selected 2022 from list of calendar then crash the calendar and show error below
═══════ Exception caught by widgets library ═══════════════════════════════════════════════════════
'package:flutter_calendar/calendar_lib.dart': Failed assertion: line 608 pos 16: '!selectedFirstDate.isBefore(firstDate) &&
(selectedLastDate == null || !selectedLastDate.isAfter(lastDate))': is not true.
Please could you update this package.
Thanks in advance
Just fyi, we've created a form field widget that wraps the new date range widget.
not able to migrate null safety because daterange picker dependency doest not have sound null safety version
When I try to run my app in chrome, I keep getting this error:
../../../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/date_range_picker-1.0.6/lib/date_range_picker.dart:1152:44: Error: Method not found: 'ButtonTheme.bar'. final Widget actions = new ButtonTheme.bar(
I just updated flutter to the last version of and as posted in this post in StackOverflow, ButtonTheme.bar is deprecated. This results in not being able to run the app in web. I don't use "directly" ButtonTheme, but the package flutter_form_builder does. Someone already posted the issue in flutter_form_builder.
Maybe a solution would be to modify date_range_picker yourself to replace the ButtonTheme with ButtonBarTheme...
Hello guys, can any one tell how to detect sliding date on UI ? I got stuck some days, I can not find that code.
Hi! Thank you for your Time. How I can set it in different language? (for ex. ru-RU).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.