Open mohadel92 opened 5 months ago
using a simple stateprovider the .nextPage(..) method or .previousPage(..) doesn't work
AutoDisposeStateProvider<PageController> _pageControllerProvider = StateProvider.autoDispose<PageController>( (StateProviderRef<PageController> ref) { return PageController( initialPage: 0, viewportFraction: 0.9, ); }); my code: PageView.builder( allowImplicitScrolling: true, controller: ref.watch(_pageControllerProvider), itemCount: response?.length ?? 0, itemBuilder: (BuildContext context, int index) { return Padding( padding: const EdgeInsets.all(8.0), child: MyWidget() ); }, ), press handler: Consumer(builder: (BuildContext context, WidgetRef ref, _) { return PrevNextRow( onNextPressed: () async { ref .read( _pageControllerProvider) .nextPage( duration: const Duration( milliseconds: 500, ), curve: Curves.decelerate); }, onPrevPressed: () async { ref .read( _pageControllerProvider) .previousPage( duration: const Duration( milliseconds: 500, ), curve: Curves.decelerate); }, ); })
Expected behavior PageController should move the list to the next item
Hi, mohadel92 In my opinion, Maybe you use StateProvider is wrong concept. Class is must to has immutable. PageController is not immutable class is cannot use in state.
This hope you help.
using a simple stateprovider the .nextPage(..) method or .previousPage(..) doesn't work
Expected behavior PageController should move the list to the next item