I am trying to change the font of the title in my Flutter for Web Application how can i do it? I found out that the pubsec.yaml is completely different than the mobile version here is the file:
name: projectbaseclient
description: An app built using Flutter for web
environment:
# You must be using Flutter >=1.5.0 or Dart >=2.3.0
sdk: '>=2.3.0 <3.0.0'
dependencies:
flutter_web: any
flutter_web_ui: any
dev_dependencies:
build_runner: ^1.5.0
build_web_compilers: ^2.1.0
pedantic: ^1.7.0
dependency_overrides:
flutter_web:
git:
url: https://github.com/flutter/flutter_web
path: packages/flutter_web
flutter_web_ui:
git:
url: https://github.com/flutter/flutter_web
path: packages/flutter_web_ui
This is the FontManifest.json:
[
{
"family": "Poppins",
"fonts": [
{
"asset": "fonts/Poppins-Regular.ttf"
}
]
},
{
"family": "KronaOne",
"fonts": [
{
"asset": "fonts/KronaOne-Regular.ttf"
}
]
},
{
"family": "Ubuntu",
"fonts": [
{
"asset": "fonts/Ubuntu-Regular.ttf"
}
]
}
]
I have already created a folder assets/fonts and added the fonts in the folder also i created the FontManifest.json and put it in the assets folder but it the code is not working it gives me error when i change the fontFamily parameter in the Text object.
how can i use the fonts to the Flutter for Web project?
Spatz
Check if assets
folder is located in web
folder. Next, compare FontManifest.json
content with the example below:
[
{
"family": "Rubik",
"fonts": [
{
"asset": "fonts/Rubik-Regular.ttf"
},
{
"asset": "fonts/Rubik-Medium.ttf",
"weight": 500
}
]
}
]
来源:https://stackoverflow.com/questions/57023412/how-to-change-flutter-for-web-font