Flutter Web not displaying Material Design Icons
5,627
Solution 1
From flutter_web repository:
Note: a reference to MaterialIcons
is intentionally omitted because the corresponding font is not included in this source.
If you add MaterialIcons-Extended.ttf
to this directory, you can update FontManifest.json
as follows:
[
{
"family": "MaterialIcons",
"fonts": [
{
"asset": "MaterialIcons-Extended.ttf"
}
]
},
{
"family": "GoogleSans",
"fonts": [
{
"asset": "GoogleSans-Regular.ttf"
}
]
},
{
"family": "GalleryIcons",
"fonts": [
{
"asset": "GalleryIcons.ttf"
}
]
}
]
Solution/Workaround
Download MaterialIcons-Regular.ttf
here, put it inside your assets
folder and update your FontManifest.json
accordingly.
Solution 2
According to this
you can directly add Material icons to FontManifest.json
as shown below.
[
{
"family": "MaterialIcons",
"fonts": [
{
"asset": "https://fonts.gstatic.com/s/materialicons/v42/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.woff2"
}
]
}
]
Author by
JideGuru
Software Engineer focused on Flutter and Javascript. https://github.com/JideGuru
Updated on December 11, 2022Comments
-
JideGuru over 1 year
I started
Flutter web
and i wanted to add Material icons to my Flutter web app but its displaying boxes instead.Any help is appreciated. Thanks
-
JideGuru almost 5 yearsyour JSON code says
MaterialIcons-Extended.ttf
but you gave link toMaterialIcons-Regular.ttf
. please edit -
Zerocchi almost 5 years@JideGuru the JSON is from repo, and below is my alternative solution since I can't find
MaterialIcons-Extended.ttf
. Will update once I get the actual font. -
Spyryto almost 5 yearsPutting
"asset": "MaterialIcons-Regular.ttf"
into the JSON file works for me. -
Mirko Raimo about 4 yearsIf you prefer to have the file for the font and not the web reference, you can open the link (that is the one posted in the answer above) in the browser, download the file and change the extension to .ttf . In my project, it works also in this way. In this case, in your FontManfest.json you can use the same references as the answer, but writing the asset property like this: "asset": "fonts/MaterialIcons-Extended.ttf"
-
M Karimi over 2 years@Zerocchi I can't update FontManifest.json file, because I deploy web flutter directly via azure pipeline. So you have any solutions else?