preface

Returning to the novel reader after a half-week hiatus, the biggest problem during this period of time, besides fishing, is to realize the idea before:

According to the previous idea, the plan is to use a large ListView, with three small listViews, respectively representing the previous chapter, the current chapter, the next chapter; By supporting nested sliding, chapter switching can be implemented seamlessly, and there is no need to do what the previous chapter, the next chapter switch management, the thing to do is one, the large ListView and the small ListView respectively construct corresponding items, and that’s it; It is a beautiful thing to think about, according to the implementation of this scheme, I wonder who will say that logic can not understand

So we added a nested sliding function to the ListView; However, there is a problem in the simulation page-turning, because the simulation page-turning will perform a save and restore operation on the canvas to crop the canvas. If context.paintChild is used to draw the small ListView itself instead of its Item between the save and restore operations (that is, when the large ListView takes over the gesture time and draws its own corresponding ListView to animate the page turn between sections), You get a heartwarming error:

Object has been disposed.

As a result, after several days of tracking analysis and debugging, I finally understood the cause of the problem and made a temporary solution. The parts that still need to be optimized are recorded here;

The reason is simple, as you can see in the picture below:

So after determining the cause, what you need to do is very clear, deal with the problem of RepaintBoundary in ListView;

Analysis of the

A second look at the various ListView widgets confirms that the widget that adds RepaintBondary is: GlowingOverscrollIndicator and ViewPort, the next thing to do is how to reasonable to eliminate RepaintBoundary from it;

If nesting mode is detected, then do not add the OverScrollIndicator. ViewPort also uses a custom ViewPort that has been specially removed from isRepaintBoundary. There should be a more reasonable way, such as a custom RepaintBoundary, by the same way as the custom GestureRecognizer to make it dynamic return need to intercept Repaint;

conclusion

Context. ClipPathAndPaint also uses canvas.restore, but it does not return an error.

Back to the subject, final effect :(webp yyds, no more gifs)

Notice that when turning the page on the third page, the section index changes in the lower left corner, which is indeed the switching of sections;