I'm using carousel_slider to change between my screen pages as a carousel, but when I click a button to change to another screen I use the method animateToPage
from a CarouselController
to change to the new screen -> controller.animateToPage(pageIndex)
void handleButtonClick() {
if (pageIndex != 1 && pageIndex != 2) {
goToLogin!.call();
} else {
controller.animateToPage(pageIndex);
}
}
Every time I run the app it works perfectly, but if a try a hot restart or a hot reload I get the following error when clicking the button
E/flutter ( 5497): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Null check operator used on a null value E/flutter ( 5497): #0 CarouselControllerImpl.animateToPage (package:carousel_slider/carousel_controller.dart:106:41) E/flutter ( 5497): #1 PresentationButton.handleButtonClick....
Does someone know how to solve this problem?