Flutter PageView next page not preloded its taking second to load data but data prefetched

67 views Asked by At

I am encountering an issue with Flutter's PageView where the next page data is not preloaded despite implementing prefetching mechanisms. The data is prefetched, but there is a noticeable delay (around a second) when navigating to the next page.

Here's a simplified snippet of my code:

 Positioned(
               
                child: Container(
                  height: MediaQuery.of(context).size.height - 140,
                  child: BlocBuilder<MocktestBloc, MocktestState>(
                    builder: (context, state) {
                      if (state is MocktestLoadedState) {
                        // ToDo: Data fetching
                        questionDataz = state.mockTestModel.questions ?? [];
                         return Column(
                          crossAxisAlignment: CrossAxisAlignment.stretch,
                          children: [
                            Expanded(
                              child: PageView.builder(
                                controller: controller ?? PageController(),
                                itemCount: questionDataz.length,
                                itemBuilder: (context, index) {
                                  final questionData = questionDataz[index];
                                  return Container(
                                    child: Column(
                                      children: [
                                        
                                        Text(
                                          "Question :",
                                          style: TextStyle(
                                              fontWeight: FontWeight.bold),
                                        ),
                                        TeXView(
                                          child: TeXViewDocument(
                                              questionData!.question!,
                                          
                                          ),
                                        ),
                                       
                                      ],
                                    ),
                                  );
                                },
                                onPageChanged: (index) {
                                   
                                },
                              ),
                            ),
                             
                          ],
                        );
                      } else {
                       
                      }
                    },
                  ),
                ),
              ),

Despite prefetching data, there's a noticeable delay when navigating between pages. I have ensured that data is indeed prefetched, but rendering the next page takes an additional second. I would appreciate any insights into optimizing the performance of the PageView and ensuring that the next page data is seamlessly loaded without delays.

0

There are 0 answers