DatePickerTimelineFlutter
DatePickerTimelineFlutter copied to clipboard
Animate to page not working on iOS
Describe the bug Animate to page not working, it just scroll to the given date
To Reproduce Here is the code
class ScheduleScreen extends StatefulWidget {
const ScheduleScreen({Key? key}) : super(key: key);
@override
_ScheduleScreenState createState() => _ScheduleScreenState();
}
class _ScheduleScreenState extends State<ScheduleScreen> {
DateTime _selectedDate = DateTime.now();
final DatePickerController _controller = DatePickerController();
@override
void initState() {
super.initState();
WidgetsBinding.instance!.addPostFrameCallback((timeStamp) {
_controller.animateToDate(_selectedDate);
});
}
@override
Widget build(BuildContext context) {
final _theme = Theme.of(context);
SizeConfiguration().init(context);
return Scaffold(
body: CustomScrollView(
slivers: [
CustomSliverAppBar(
title:
"${DateFormat().add_MMMM().format(_selectedDate)} ${DateFormat().add_y().format(_selectedDate)}",
children: [
Padding(
padding: EdgeInsets.only(
right: paddingX(5),
top: paddingX(2),
bottom: paddingX(2),
),
child: ButtonPrimary(
paddingVertical: 1.5,
buttonColor: _theme.primaryColor,
buttonTextColor: AppColors.white,
buttonText: "Today",
onPressed: () {
_controller.animateToDate(DateTime.now());
setState(() {
_selectedDate = DateTime.now();
});
},
),
),
],
),
SliverGap(
height: paddingX(1),
),
SliverToBoxAdapter(
child: DatePicker(
DateTime.now().subtract(const Duration(days: 365)),
controller: _controller,
initialSelectedDate: DateTime.now(),
selectionColor: _theme.primaryColor,
onDateChange: (date) {
setState(() {
_selectedDate = date;
});
},
),
),
SliverGap(
height: paddingX(1),
),
],
),
);
}
}
Expected behavior 21 October should be active date
Recording https://user-images.githubusercontent.com/77736118/138221572-91e3c9c0-19f3-434e-8358-ac71675ce777.mov
Smartphone (please complete the following information):
- Device: iPhone SE 1st Gen
- OS: iOS 15