Hello guys, The text widget the Style property has a sub property TextStyle. TextStyle contains all the text styling options and one of them is fontWeight. fontWeight create bold style text in flutter. It has 11 sub properties which can make text bold in 11 different ways.
Properties of fontWeight in flutter:
- FontWeight.bold
- FontWeight.normal
- FontWeight.w100
- FontWeight.w200
- FontWeight.w300
- FontWeight.w400
- FontWeight.w500
- FontWeight.w600
- FontWeight.w700
- FontWeight.w800
- FontWeight.w900
How to Create Bold Style Text in Flutter:
1. Open your flutter project's main.dart file and create Text widget with fontWeight.
Text(
'Sample Text',
style: TextStyle(fontWeight: FontWeight.bold),
)
2. Complete Source code for main.dart file:
import 'package:flutter/material.dart';
void main() => runApp(App());
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(
body: Center(
child: Text(
'Sample Text',
style: TextStyle(fontWeight: FontWeight.bold),
))),
);
}
}
Screenshot of flutter app:
Comments
Post a Comment