so, I'm using android studio, and in my pubspec, I've added say poppins-regular, poppins-bold, poppin-italics, poppins-semiBold, all under the same family:poppins and in different parts of my code, I need to use them separately, how do I use a particular one instead of just mentioning the family and it decides which one to use for me
void main() {
runApp(
MaterialApp(
home: Scaffold(
body: Column(
children: const [
Text(
'How\'s it work',
style: TextStyle(
fontFamily: 'Poppins',
fontSize: 40,
),
),
Text(
'Just sample code',
style: TextStyle(
fontFamily: 'Poppins',
fontSize: 40,
),
),
],
),
),
),
);
}
say in the first text I want it to be poppins-semibold and in the second Poppins-italics how do I specify that
CodePudding user response:
TextStyle
has several properties that you can use. In your case, semibold means FontWeight being 600 and italic is simply italic.
void main() {
runApp(
MaterialApp(
home: Scaffold(
body: Column(
children: const [
Text(
'Semibold',
style: TextStyle(
fontFamily: 'Poppins',
fontSize: 40,
fontWeight: FontWeight.w600,
),
),
Text(
'Italic',
style: TextStyle(
fontFamily: 'Poppins',
fontSize: 40,
fontStyle: FontStyle.italic,
),
),
],
),
),
),
);
}