Skip to content

Commit 3ada194

Browse files
erickzanardoScarlett Elizaalestiagowolfenrain
authored
doc: adding readme content (#3)
* doc: adding readme content * Apply suggestions from code review Co-authored-by: Scarlett Eliza <[email protected]> Co-authored-by: Alejandro Santiago <[email protected]> * PR suggestions * Update README.md Co-authored-by: Jochum van der Ploeg <[email protected]> * Update README.md Co-authored-by: Jochum van der Ploeg <[email protected]> * Update README.md Co-authored-by: Scarlett Eliza <[email protected]> * Update README.md Co-authored-by: Scarlett Eliza <[email protected]> * Update README.md Co-authored-by: Alejandro Santiago <[email protected]> * pr suggestion * Apply suggestions from code review Co-authored-by: Alejandro Santiago <[email protected]> * pr suggestion * adding a FAQ * Apply suggestions from code review Co-authored-by: Alejandro Santiago <[email protected]> * Update README.md * Update README.md * Update README.md Co-authored-by: Alejandro Santiago <[email protected]> * Update README.md Co-authored-by: Alejandro Santiago <[email protected]> --------- Co-authored-by: Scarlett Eliza <[email protected]> Co-authored-by: Alejandro Santiago <[email protected]> Co-authored-by: Jochum van der Ploeg <[email protected]>
1 parent 61718f5 commit 3ada194

File tree

1 file changed

+45
-10
lines changed

1 file changed

+45
-10
lines changed

README.md

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,55 @@
22

33
[![Powered by Mason](https://img.shields.io/endpoint?url=https%3A%2F%2Ftinyurl.com%2Fmason-badge)](https://github.com/felangel/mason)
44

5-
A brick that creates a smart web entrypoint for Flutter that pre loads its assets before starting the app
5+
A brick that creates a smart web entrypoint for Flutter and preloads any type of asset before starting an app.
66

77
_Generated by [mason][1] 🧱_
88

9-
## Getting Started 🚀
9+
## Flutter Web Preloader
1010

11-
This is a starting point for a new brick.
12-
A few resources to get you started if this is your first brick template:
11+
This brick will override the default `web/index.html` that is created with a web Flutter project.
12+
13+
The `index.html` file generated by this brick will add additional JavaScript code
14+
in order to preload assets used by the Flutter app. Ensuring that when the app is
15+
presented to the user, the assets are already cached by the browser. Doing so prevents
16+
the application from loading piece by piece.
17+
18+
While the assets are being preloaded, a progress bar will be presented
19+
to the user.
20+
21+
## Variables
22+
23+
| Name | Description | Default value |
24+
| ------|------------------|-------------- |
25+
|`project_title`| The title of the project | value on the `pubspec.yaml`|
26+
| `project_description`| The project description |`name` attribute in the `pubspec.yaml`|
27+
| `batch_size`| How match assets will be loaded at the same time | `20`|
28+
| `canvaskit`| If the app uses `canvaskit` mode or not |`true`|
29+
30+
## FAQ
31+
32+
### Can I customize the progress bar?
33+
34+
Yes, the progress bar can be customized. The generated `web/index.html` has a content division element (`div`) with an identifier of `progress-indicator`. This element can be styled using Cascading Style Sheets (CSS).
35+
For example, we can change the `background-color` to red by doing:
36+
37+
```html
38+
<div id="progress-bar" style="border: 1px solid blue; width: 250px; height: 50px;">
39+
<div id="progress-indicator" style="background-color: red; height: 100%; width: 0%;"></div>
40+
</div>
41+
```
42+
43+
### What would be the optimal `batch_size`?
44+
45+
The `batch_size` depends on the number and average size of your assets.
46+
47+
The `batch_size` can be increased when the average size of the assets is small, since the requests will finish sooner. However, keep in mind that a large `batch_size` may trigger too many requests at the same time and it may cause unexpected issues in the browser.
48+
On the other hand, the `batch_size` should be decreased when the size of the assets are large.
49+
50+
The default `batch_size` is `20`, this should be a good number for most projects. It is not too high to cause unexpected browser issues, but also not low enough to cause the loading to take too much time.
51+
52+
In any case, we advise on testing when changing this value to make sure that it
53+
won't break your app.
1354

14-
- [Official Mason Documentation][2]
15-
- [Code generation with Mason Blog][3]
16-
- [Very Good Livestream: Felix Angelov Demos Mason][4]
1755

1856
[1]: https://github.com/felangel/mason
19-
[2]: https://github.com/felangel/mason/tree/master/packages/mason_cli#readme
20-
[3]: https://verygood.ventures/blog/code-generation-with-mason
21-
[4]: https://youtu.be/G4PTjA6tpTU

0 commit comments

Comments
 (0)