main.dart
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
void main() {
runApp(
MaterialApp(
theme: ThemeData(primarySwatch: Colors.pink),
home: Scaffold(
appBar: AppBar(
title: const Text("Flutter - Google Fonts")
),
body: bodyContent()
),
),
);
}
bodyContent(){
// dependencies: google_fonts: ^2.2.0
return Column(
children: [
box(
"Cute Font",
GoogleFonts.cuteFont(textStyle: const TextStyle(fontSize: 50))
),
box(
"Rubik Beastly",
GoogleFonts.rubikBeastly(
textStyle: const TextStyle(fontSize: 50)
)
),
box(
"Pacifico",
GoogleFonts.pacifico(textStyle: const TextStyle(fontSize: 50))
)
]
);
}
box(String fontName, TextStyle style){
return Container(
height: 150, width: double.infinity,
color: Colors.pink.shade50,
margin: const EdgeInsets.all(8),
child: Text(
fontName,
style: style,
textAlign: TextAlign.center,
),
alignment: Alignment.center
);
}
More flutter tutorials
- flutter – How to use IconButton onPressed
- flutter – FloatingActionButton with Scaffold
- flutter – FloatingActionButton with text
- flutter – How to change PopupMenuButton shape
- flutter – PopupMenuButton position
- flutter – ListTile shape
- flutter – ListTile separator
- flutter – How to use Table
- flutter – Random number in range
- flutter – Random material color
- flutter – Random material color with shade
- flutter – Random bool custom probability
- flutter – How to generate random uuid
- flutter – Google fonts text theme
- flutter – Function default value