Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FlutterLoader.loadEntrypoint" is deprecated. Use "FlutterLoader.load" instead

Tags:

flutter

When updating Flutter to the new version 3.22.0, I encountered a warning:

"The use of 'FlutterLoader.loadEntrypoint' is deprecated. Please use 'FlutterLoader.load' instead."

After making the change from 'loadEntrypoint' to 'load', I encountered another issue:

"FlutterLoader.load requires _flutter.buildConfig to be set"

Upon reviewing flutter.js, I realized that the 'load' function has more parameters than 'loadEntrypoint'

I would like to ask if anyone knows the solution to this problem, please provide suggestions.

like image 533
Mori Avatar asked Dec 12 '25 01:12

Mori


1 Answers

I've encountered this issue just today, spent a bit of time looking at the documentation and release notes and this is what i found: https://docs.flutter.dev/platform-integration/web/bootstrapping

They have improved web app initialization:

  1. They made a simpler callback for projects created from 3.22.0 and above. Just replace the content your index.html, your code should look like this:
    <body>
      <script src="flutter_bootstrap.js" async></script>
    </body>
  1. For more complex cases you can still use the old syntax with a couple of extra steps. For example here i'm setting a splash Logo image which gets removed when flutter loaded:
<body>
  <script>
    window.addEventListener('load', function(ev) {
      {{flutter_js}}
      {{flutter_build_config}}
      
      _flutter.loader.load({
        serviceWorker: {
          serviceWorkerVersion: {{flutter_service_worker_version}},
        },
        onEntrypointLoaded: function(engineInitializer) {
          engineInitializer.initializeEngine().then(function(appRunner) {
            if(document.getElementById('splash'))
              document.getElementById('splash').remove();
            appRunner.runApp();
          });
        }
      });
    });
  </script>

  <picture id="splash"   >
    <source srcset="splash/img/iso_gradient_vert-x3.png 1x" media="(prefers-color-scheme: light) or (prefers-color-scheme: no-preference)">
    <source srcset="splash/img/iso_gradient_vert-x3.png 1x" media="(prefers-color-scheme: dark)">
    <img class="center" src="splash/img/iso_gradient_vert-x3.png" width="500" height="500"  alt="LOGO"/>
  </picture>
</body>

Hope it helps!

like image 109
Edgerik Leguizamon Avatar answered Dec 15 '25 23:12

Edgerik Leguizamon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!