M
Size: a a a
M
🅵
🅵
🅵
VS
🅵
M
🅵
d9
Exception: Unhandled error 'package:flutter/src/widgets/page_view.dart': Failed assertion: line 184 pos 7: 'positions.length == 1': The page property cannot be read when multiple PageViews are attached to the same PageController. occurred in bloc Instance of 'TrainingBloc'.
Есть один контроллер и один PageViewlf
Exception: Unhandled error 'package:flutter/src/widgets/page_view.dart': Failed assertion: line 184 pos 7: 'positions.length == 1': The page property cannot be read when multiple PageViews are attached to the same PageController. occurred in bloc Instance of 'TrainingBloc'.
Есть один контроллер и один PageViewVS
SV
class TrainingBloc extends Bloc<TrainingEvent, TrainingState> {
@override
TrainingState get initialState => TrainingInitialState();
PageController pageController = PageController();
не в методе, потом передается к page view через конструкторclass TrainingPageView extends StatefulWidget {
final List<Flashcard> flashcards;
final ValueListenable<Flashcard> currentFlashcardListenable;
final PageController controller;
TrainingPageView(
{Key key,
@required this.flashcards,
@required this.currentFlashcardListenable,
@required this.controller})
: super(key: key);
И так выглядит build@override
Widget build(BuildContext context) {
return PageView.builder(
itemCount: flashcards.length,
physics: NeverScrollableScrollPhysics(),
controller: controller,
onPageChanged: (int index) {
Flashcard currentFlashcard = flashcards[index];
context.bloc<TrainingBloc>().add(SetCurrentFlashcard(
currentFlashcard, index == flashcards.length - 1,
index: index));
},
itemBuilder: (BuildContext context, int index) {
return TrainingView(
currentFlashcardListenable: currentFlashcardListenable,
);
},
);
}
В блоке все действия с ним это pageController.nextPage(
duration: Duration(milliseconds: kNextPageAnimDur),
curve: Curves.easeOutCubic);
ND
lf
ND
lf
lf
SV
SV
EE