title: Flutter Web: Prerender ListView
body: <p>I'm using Flutter Web and I want to prerender a ListView instead of building widgets as the user scrolls, you can see this behaviour on my test site: <a href="https://auties00.github.io" rel="nofollow noreferrer">https://auties00.github.io</a>
  This causes performance issues especially on mobile, please ignore the List as I'm testing out a few methodologies to scroll to an index of a ListView.
  Source Code:</p>
  <pre><code>class _HomePageState extends State&lt;HomePage&gt; {
    final ScrollController _controller = ScrollController();
    final List&lt;GlobalKey&gt; _keys = [];
  
    @override
    Widget build(BuildContext context) {
      reset();
      _keys.clear();
      var size = MediaQuery.of(context).size;
      ScreenUtil.init(context, width: size.width, height: size.height);
  
      return Scaffold(
        body: Container(
            child: NotificationListener&lt;OverscrollIndicatorNotification&gt;(
                onNotification: (e) {
                  e.disallowGlow();
                  return false;
                },
  
                child: _buildBody()
            )
        ),
      );
    }
  
    Widget _buildBody(){
      return LayoutBuilder(
        builder: (context, constraints) {
          _initWebListeners(constraints);
          return ListView.builder(
            controller: _controller,
            physics: const AlwaysScrollableScrollPhysics(),
            itemBuilder: (var context, var index) {
              switch (index) {
                case 0: return WebNavigationBar(
                    key: GlobalKey()..addKeyToList(_keys),
                    keys: _keys
                );
  
                case 1:return WebAnnouncement(
                  key: GlobalKey()..addKeyToList(_keys),
                );
  
                case 2: return WebPlayer(
                    key: GlobalKey()..addKeyToList(_keys),
                    link: 'https://i.imgur.com/VPTYKX2.mp4'
                );
  
                case 4: return WebIntroduction(
                  key: GlobalKey()..addKeyToList(_keys),
                );
  
                case 6: return WebFeatures(
                  key: GlobalKey()..addKeyToList(_keys),
                );
  
                case 8: return WebPricing(
                  key: GlobalKey()..addKeyToList(_keys),
                );
  
                case 9: return WebFooter(
                  key: GlobalKey()..addKeyToList(_keys),
                );
              }
  
              return WebDivider();
            },
            itemCount: 10
          );
        },
      );
    }
  }
  </code></pre>