text stringlengths 1 372 |
|---|
see upgrading an older project. |
the loadEntrypoint function calls the onEntrypointLoaded callback |
once the service worker is initialized, and the main.dart.js entrypoint |
has been downloaded and run by the browser. flutter also calls |
onEntrypointLoaded on every hot restart during development. |
the onEntrypointLoaded callback receives an engine initializer object as |
its only parameter. use the engine initializer to set the run-time |
configuration, and start the flutter web engine. |
the initializeEngine() function returns a promise |
that resolves with an app runner object. the app runner has a |
single method, runApp(), that runs the flutter app. |
<topic_end> |
<topic_start> |
customizing web app initialization |
in this section, |
learn how to customize each stage of your app’s initialization. |
<topic_end> |
<topic_start> |
loading the entrypoint |
the loadEntrypoint method accepts these parameters: |
the serviceWorker JavaScript object accepts the following properties: |
<topic_end> |
<topic_start> |
initializing the engine |
as of flutter 3.7.0, you can use the initializeEngine method to |
configure several run-time options of the flutter web engine through a |
plain JavaScript object. |
you can add any of the following optional parameters: |
info note |
some of the parameters described above might have been overridden |
in previous releases by using properties in the window object. |
that approach is still supported, but displays a deprecation |
notice in the JS console, as of flutter 3.7.0. |
<topic_end> |
<topic_start> |
engine configuration example |
the initializeEngine method lets you pass any of the configuration |
parameters described above to your flutter app. |
consider the following example. |
your flutter app should target an HTML element with id="flutter_app" and |
use the canvaskit renderer. the resulting JavaScript code would resemble |
the following: |
for a more detailed explanation of each parameter, take a look at the |
“runtime parameters” documentation section of the configuration.dart |
file of the web engine. |
<topic_end> |
<topic_start> |
skipping this step |
instead of calling initializeEngine() on the engine initializer (and then |
runApp() on the application runner), you can call autoStart() to |
initialize the engine with its default configuration, and then start the app |
immediately after the initialization is complete: |
<topic_end> |
<topic_start> |
example: display a progress indicator |
to give the user of your application feedback |
during the initialization process, |
use the hooks provided for each stage to update the DOM: |
for a more practical example using CSS animations, |
see the initialization code for the flutter gallery. |
<topic_end> |
<topic_start> |
upgrading an older project |
if your project was created in flutter 2.10 or earlier, |
you can create a new index.html file |
with the latest initialization template by running |
flutter create as follows. |
first, remove the files from your /web directory. |
then, from your project directory, run the following: |
<topic_end> |
<topic_start> |
displaying images on the web |
the web supports the standard image widget to display images. |
however, because web browsers are built to run untrusted code safely, |
there are certain limitations in what you can do with images compared |
to mobile and desktop platforms. this page explains these limitations |
and offers ways to work around them. |
<topic_end> |
<topic_start> |
background |
this section summarizes the technologies available |
across flutter and the web, |
on which the solutions below are based on. |
<topic_end> |
<topic_start> |
images in flutter |
flutter offers the image widget as well as the low-level |
dart:ui/Image class for rendering images. |
the image widget has enough functionality for most use-cases. |
the dart:ui/Image class can be used in |
advanced situations where fine-grained control |
of the image is needed. |
<topic_end> |
<topic_start> |
images on the web |
the web offers several methods for displaying images. |
below are some of the common ones: |
each option has its own benefits and drawbacks. |
for example, the built-in elements fit nicely among |
other HTML elements, and they automatically take |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.