Styles and Themes of Text

 import "package:celloip/ui_helper/util.dart";

import "package:flutter/material.dart";

void main() {
runApp(const MyApp(),);
}
class MyApp extends StatelessWidget {
const MyApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
title: "Styles and Themes",
theme: ThemeData(
primarySwatch: Colors.indigo,
textTheme: TextTheme(
headline1: TextStyle(fontSize: 21.0, fontWeight: FontWeight.bold,),
headline2: TextStyle(fontSize: 21.0, fontWeight: FontWeight.bold, color: Colors.lightGreen,),
subtitle1: TextStyle(fontSize: 11.0, fontWeight: FontWeight.w500, fontStyle: FontStyle.italic,),
subtitle2: TextStyle(fontSize: 11.0, fontWeight: FontWeight.w500, fontStyle: FontStyle.italic, color: Colors.orange,),
),
),
home: const ThemeDemo(),
);
}
}
class ThemeDemo extends StatefulWidget {
const ThemeDemo({super.key});

@override
State<ThemeDemo> createState() {
return ThemeState();
}
}
class ThemeState extends State<ThemeDemo> {

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Styles and Themes"),
),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("Text 1", style: Theme.of(context).textTheme.headline1?.copyWith(color: Colors.green,),),
Text("Text 2", style: Theme.of(context).textTheme.subtitle1,),
Text("Text 3", style: Theme.of(context).textTheme.headline2,),
Text("Text 4", style: mTextStyle11(textColor: Colors.blue,),),
],
),
);
}
}

Comments

Popular posts from this blog

Second GET API Calling with Bloc simple Example in Flutter

Stack Container Scrollable Card widget UI with Custom Widget

Pagination with Bloc Pattern in Flutter