Home > Blockchain >  Does google font package download the fonts on the device?
Does google font package download the fonts on the device?

Time:12-09

In my flutter Android app, on first launch, the app shows a default font and then a second later it changes to the fonts I used from google fonts flutter package. I guess my question is, does the font download as soon as the app launches for the first time ?, if so can the font be compiled with the app so it doesn't require to be downloaded on the device.

CodePudding user response:

Yes, google_fonts is fetching them over HTTP at runtime. It's really good for development purposes, but when you choose which font you want to stick with, do as they recommend, which is to download the font and put it on the assets folder, this way, the package won't download anything, rather take it from you assets folder.

For more info: read this.

The google_fonts package will automatically use matching font files in your pubspec.yaml's assets (rather than fetching them at runtime via HTTP). Once you've settled on the fonts you want to use:

Download the font files from https://fonts.google.com. You only need to download the weights and styles you are using for any given family. Move those fonts to a top-level app directory (e.g. google_fonts).

Ensure that you have listed the folder (e.g. google_fonts/) in your pubspec.yaml under assets.

Note: Since these files are listed as assets, there is no need to list them in the fonts section of the pubspec.yaml. This can be done because the files are consistently named from the Google Fonts API (so be sure not to rename them!)

  • Related