An immutable style describing how to format and paint text.
How can I create a custom TextStyle class in flutter?
Text is a very important part of any mobile app UI. In this guide I’ll go over all the ways text can be modified in Flutter and applying global text themes. To show text in Flutter you use the Text Widget.
Text('FilledStacks')
This will show the text on the screen using the default text for the OS. Roboto on Android and Helvetiva Neue on iOS. Let’s start playing around. Create a build method like this so you can see what’s happening with all the changes.
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(child: Text('FilledStacks')),
),
);
}
FontWeight
Font weight has multiple values that can be supplied using the FontWeight consts. In addition to bold and normal you can supply actual weights by using FontWeight.w[weightValue] i.e. FontWeight.w900 for heavy font bolder than bold.
FontStyle
The font style is what you’ll use to make the text italic fontStyle: FontStyle.italic.
Custom Fonts
To use custom fonts is a 2 step process. Copy over the assets and declare in the pubspec file. Then supply the font family. The fonts can be placed in the assets folder in the root of the project under a fonts folder to keep everything organized.
Then you import these assets into the app through the pubspec assets section. Scroll down in the pubspec file and you’ll see some commented out font related text. That’s where you’ll import your fonts.
fonts:
family: Open Sans
fonts:
asset: assets/fonts/OpenSans-Bold.ttf
weight: 700
asset: assets/fonts/OpenSans-ExtraBold.ttf
weight: 800
asset: assets/fonts/OpenSans-Light.ttf
weight: 300
asset: assets/fonts/OpenSans-Regular.ttf
weight: 400
Global Theming
You probably wouldn’t want to set the text style for every single Text widget you use in the app, luckily Flutter makes that easy for us to handle. In your main app when you supply your Material app you can optionally provide a theme. When doing this you can take the current theme and apply some additional changes to it so that you still inherit most of the Theming besides the small changes you want to make. #flutter #flutterdeveloper #flutterproject #fluttercommunity #flutter #fluttercommunity #flutterdeveloper #flutterwidgets Change UI selected item | Riverpod 2.0 | State Notifier Provider: • Change UI selected item | Riverpod 2....
How to make Image border rounded in Flutter | ClipRRect Widget in Flutter: • How to make Image border rounded in F...
Flutter Provider for Beginners | Simple Project for first step in provider: • Flutter Provider for Beginners | Simp...
Flutter Navigation (FirstPage to SecondPage) - Using the Navigator Push: • Flutter Navigation (FirstPage to Seco...
Powerful File manager for Windows | XYplorer: • Powerful File manager for Windows | X...
Solved ! LIstview not showing?? : • Solved ! LIstview not showing?? Vanis...
Custom TextStyle Widget in Flutter | How to use 1 TextStyle in several Text Widget style ? : • Custom TextStyle Widget in Flutter | ...
How To add background Image || How to Flutter || Set Background Image (Flutter Screen Background): • How To add background Image || How to...
Toast Message in Flutter | How to show toast message in Flutter: • Toast Message in Flutter | How to sho...
How to get image from assets folder in flutter | Local Image: • How to get image from assets folder i... How to Create a Splash Screen in Flutter App | Without external packageLL • How to Create a Splash Screen in Flut...