Styles and Themes of Text

 import 'package:flutter/material.dart';

import 'package:practice/ui_helper/util.dart';

void main() {
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
title: "Hello Flutter Application",
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.lightGreen,
textTheme: const TextTheme(
displayLarge: TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
displayMedium: TextStyle(
fontSize: 30,
fontWeight: FontWeight.bold,
color: Colors.lightGreen),
titleMedium: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
fontStyle: FontStyle.italic),
titleSmall: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
fontStyle: FontStyle.italic,
color: Colors.orange),
),
),
home: const FlutterApp(),
);
}
}

class FlutterApp extends StatelessWidget {
const FlutterApp({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text(
"Hello World",
style: TextStyle(fontWeight: FontWeight.bold),
),
centerTitle: true,
backgroundColor: Colors.grey,
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Text 1",
style: Theme.of(context)
.textTheme
.displayLarge!
.copyWith(color: Colors.orange),
),
Text("Text 2",
style: Theme.of(context)
.textTheme
.titleMedium), //"Theme.of" indicates Theme of Application.
Text("Text 3",
style: Theme.of(context)
.textTheme
.displayMedium), //"textTheme" indicates Theme of Text.
//Text("Text 4", style: Theme.of(context).textTheme.titleSmall),
//Text("Text 4", style: mTextStyle11()),

/*When we add "mTextStyle11()", then "package:practice/ui_helper/util.dart"
package will Automatically Import.*/

//Text("Text 4", style: mTextStyle30()),
Text(
"Text 4",
style: mTextStyle11(textColor: Colors.pink),
),
],
),
),
);
}
}

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