xxxxxxxxxx
Text(
"Hello",
style: TextStyle(fontFamily: 'Raleway'),
)
xxxxxxxxxx
MaterialApp(
title: 'Custom Fonts',
// Set Raleway as the default app font.
theme: ThemeData(fontFamily: 'Raleway'),
home: MyHomePage(),
);
xxxxxxxxxx
MaterialApp(
theme: ThemeData(
textTheme: GoogleFonts.montserratTextTheme(
Theme.of(context).textTheme,
),
),
)
xxxxxxxxxx
Text(
'Text',
fontFamily: 'Hind',
fontSize: 20,
fontWeight: FontWeight.w500),
)
xxxxxxxxxx
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
textTheme: TextTheme(
bodyText2: TextStyle(
fontFamily: 'Your-Font-Family', // Set your desired font family here
),
),
),
home: HomeScreen(),
);
}
}
class HomeScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Default Font Family'),
),
body: Center(
child: Text(
'Hello, World!',
style: Theme.of(context).textTheme.bodyText2,
),
),
);
}
}
xxxxxxxxxx
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Font Family Demo',
theme: ThemeData(
textTheme: TextTheme(
bodyText2: TextStyle(
fontFamily: 'CustomFont', // replace with your desired font family
),
),
),
home: Scaffold(
appBar: AppBar(
title: Text('Font Family Example'),
),
body: Center(
child: Text(
'Hello, Flutter!',
style: Theme.of(context).textTheme.bodyText2,
),
),
),
);
}
}
xxxxxxxxxx
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Text Fonts in Flutter'),
),
body: Center(
child: Text(
'Hello World',
style: TextStyle(
fontSize: 20,
fontFamily: 'Roboto', // Replace 'Roboto' with the desired font
fontWeight: FontWeight.bold, // Set font weight if desired
),
),
),
),
);
}
}