body: Center(
child: SizedBox(
width: 400,
height: 400,
child: Center(
child: Row(
children: [
Image.asset('images/solider.png'),
const Text('Hello',style:TextStyle(fontFamily: 'IndieFlower'),)
],
)
)
),
),
fontfamily is not affected
import 'package:flutter/material.dart';
I only include this
2
Answers
To use this font family you have to add the font ttf file as an asset.
as if IndieFlower is a Google font. so, in this case,
you can add a Google font package in pubspec.yaml instead of adding font ttf as an asset.
add this package like :
then where you want to use this font, import the library there like this:-
then use googlefont.fontname instead of TextStyle like this:
you will find all the text style properties inside of the () brackets.
GoogleFonts.indieFlower(TextStyle property here)
final code. will. be like this:
Please let me know if you still getting any problem .
if solved mark it as solved.
Be careful: don’t forget to add packages on pubspec.yaml file .
google font package link:
Download your customized font (ttf) and put it in asset folder or your preferred folder like assets/fonts/IndieFlower.ttf
2.Then you have to add font family in your pubspec.yaml folder
flutter:
fonts:
fonts:
hit get pub
Now you are ready to use this font family in your text style
or you can simply insert Google font plugin for fonts.
in terminal flutter pub add google_fonts paste dis.
Then use this import ‘package:google_fonts/google_fonts.dart’;
Text(
‘This is Google Fonts’,
style: GoogleFonts.lato(),
),