Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Animate to page not working on iOS #60

Open
Beto-Beto-Salamander opened this issue Oct 21, 2021 · 0 comments
Open

Animate to page not working on iOS #60

Beto-Beto-Salamander opened this issue Oct 21, 2021 · 0 comments

Comments

@Beto-Beto-Salamander
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant