skip to Main Content

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.

2

Answers


  1. 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!

    Login or Signup to reply.
  2. I think the best way to handle this issue is to upgrade an older flutter project as mentioned in the Flutter documentation.

    What I did was remove the files from /web directory, then run the following command: flutter create . --platforms=web

    Reference:
    https://docs.flutter.dev/platform-integration/web/bootstrapping

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search