preload

Creator: coderz1093

Last updated:

0 purchases

preload Image
preload Images
Add to Cart

Description:

preload

Add preload to dev_dependencies in pubspec.yaml.
You should already have a dependency on build_runner.
name: my_pkg

dev_dependencies:
build_runner: ^1.0.0
preload: ^1.0.0
copied to clipboard


Update the html in your web directory.

Rename index.html to index.template.html.
Add a place-holder for the preload entries.

<html>
<head>
<!--PRELOAD-HERE-->
<script defer type="application/javascript" src="main.dart.js"></script>
</head>
</html>
copied to clipboard


Run a build.
> pub run build_runner build
copied to clipboard
You should now see index.html generated with preloads defined.
<html>
<head>
<link rel="preload" href="main.dart.js" as="script">
<link rel="preload" href="assets/font.ttf" as="font" crossorigin>
<link rel="preload" href="assets/image.jpg" as="fetch" crossorigin>
<link rel="preload" href="assets/json.json" as="fetch" crossorigin>
<link rel="preload" href="packages/pkg/assets/json.json" as="fetch" crossorigin>

<script defer type="application/javascript" src="main.dart.js"></script>
</head>
</html>
copied to clipboard


build.yaml configuration #
The builder also supports configuration values. Below are the supported keys
along with their defaults.
debug: false
exclude: []
include:
- 'web/**'
- 'lib/**'
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.