title: How to split code in flutter web in release mode?
body: <p>I am working on a project for using Flutter web and js size is getting increasing as I add features which is normal. I was looking at deferred import for Flutter and tried I out where I am getting split files as</p>
  
  <p><a href="https://i.stack.imgur.com/O4VzO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/O4VzO.png" alt="List of files on build with size"></a></p>
  
  <p>I ran <code>flutter run -d chrome</code> which was working fine as I came to know deferred is ignored in debug build and when I ran with <code>http-server</code> npm package nothing is coming even looking at network request it was requesting part files but nothing is being displayed on screen and even no errors in console. I know Flutter Web recently move to beta so there might be optimisations like specially reducing size of main.dart.js but this should work according to doc.</p>
  
  <p><a href="https://i.stack.imgur.com/BerYI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BerYI.png" alt="Network request"></a></p>
  
  <h2>Code</h2>
  
  <h3>main.dart.js</h3>
  
  <pre class="lang-dart prettyprint-override"><code>import 'package:flutter/material.dart';
  import 'package:split_test/page1.dart' deferred as page1;
  
  void main() =&gt; runApp(MyApp());
  
  class MyApp extends StatelessWidget {
    const MyApp({Key key}) : super(key: key);
  
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        home: Scaffold(
          body: Container(
            child: page1.Page1(),
          ),
        ),
      );
    }
  }
  </code></pre>
  
  <h3>page1.dart</h3>
  
  <pre class="lang-dart prettyprint-override"><code>import 'package:flutter/material.dart';
  import 'package:split_test/page2.dart' deferred as pag2;
  
  class Page1 extends StatelessWidget {
    const Page1({Key key}) : super(key: key);
  
    @override
    Widget build(BuildContext context) {
      return Container(
        child: Center(
          child: Column(
            children: &lt;Widget&gt;[
              Text('Page1'),
              GestureDetector(
                onTap: () =&gt; Navigator.push(
                  context,
                  MaterialPageRoute(
                    builder: (context) =&gt; pag2.Page2(),
                  ),
                ),
                child: Text('Go to page 2'),
              )
            ],
          ),
        ),
      );
    }
  }
  </code></pre>
  
  <h3>page2.dart.js</h3>
  
  <pre class="lang-dart prettyprint-override"><code>import 'package:flutter/material.dart';
  
  class Page2 extends StatelessWidget {
    const Page2({Key key}) : super(key: key);
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        body: Container(
          child: Center(
            child: Column(
              children: &lt;Widget&gt;[
                Text('Page2'),
                GestureDetector(
                  onTap: () =&gt; Navigator.pop(context),
                  child: Text('&lt;- Back'),
                )
              ],
            ),
          ),
        ),
      );
    }
  }
  </code></pre>
  
  <p>Thank you for your help. I was looking at this <a href="https://github.com/flutter/flutter/issues/34205" rel="nofollow noreferrer">issue</a>.</p>