Home > Back-end >  How to assign a first date in datepicker in flutter
How to assign a first date in datepicker in flutter

Time:02-15

I am making a health tracking app I have used date_picker_timeline package And using datepicker() widget and using initial date property to the day's date time and it works perfectly but the problem is that it doesn't show days before today and so the app is meaningless since it can't show the progress

CodePudding user response:

you can set like below if you want to be able to select from last month

DatePicker( DateTime.now().subtract(Duration(days: 30)), height: height * 0.1, width: width * 0.19, controller: _controller, initialSelectedDate: DateTime.now(), locale: "en-US", onDateChange: (date) { setState(() { print("Data selecionada $date"); _selectedValue = date; }); }, ),

If you want to allow selection from previous year, you can subtract 365 days. I am affried it wont be possible to scroll unlimited past time if you don't know the range.

  • Related