SliverChildListDelegate and children initState


It is required to implement lazy loading of content and components via API using SliverList on the page. I assumed that it is possible to load content through the API in children by accessing the API initState, but in this way, since SliverChildListDelegate removes a component when scrolling, the call initState and API access occurs every time.
So, the only correct way noat to do each API call is to load all the necessary information in the parent component and pass it to the children? However, this way the page will be drawn only when the last of its element will be loaded, and would like to load the components and their information without slowing down the rendering of already loaded content.

Steteless Parent

            delegate: SliverChildListDelegate([
              HomeSlider(), // every time calling initState when come and out of viewport
                height: 3000, // Space for test

Statefull child

  void initState() {


  Future<void> fetchSlides() async {
    final response = await Request().get('/sliders');

    setState(() {
      slides =['sliders'];


By making children widgets with AutomaticKeepAliveClientMixin, they don’t get rebuilt every time in sliver lists.

Try this in your child widgets:

class _SomeChildState extends State<SomeChild> with AutomaticKeepAliveClientMixin {

    bool get wantKeepAlive => true; // You can add custom logic based on whether you want to remove the child or not.

    Widget build(BuildContext context) {; // You need to call
        return ... // Your widget

Answered By – Afridi Kayal

Answer Checked By – Katrina (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *