Add Custom Text Font Family
Step 1: Open Google Fonts and search for a font family in the search bar (here “Pacifico”,"Robot",etc.).
Step 2: Select the “Pacifico” font file.
Step 3: To download, click the “Download Family” button.
Step 4: Open file manager and go to downloads. Extract and open the “Pacifico” zip file.
Step 5: Move the “Pacifico Regular” file into this directory. After moving, the font directory contains a file named “Pacifico-Regular.ttf”.
Step 6:
We cannot directly remove the time stamp from Custom Font Family but using the intl.dart package we can easily filter the date stamp from time stamp. So open your flutter project’s pubspec.yaml in code
dependencies: flutter: sdk: flutter google_fonts: ^0.3.8 flutter: fonts: - family: Pacifico fonts: - asset: fonts/Pacifico-Regular.ttf - family: Pacifico fonts: - asset: fonts/MontserratSubrayada-Regular.ttf - family: Pacifico fonts: - asset: fonts/FredokaOne-Regular.ttf
flutter pub get
import 'package:google_fonts/google_fonts.dart';
import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData( primarySwatch: Colors.indigo, ), home: MyHomePage(), ); } } class MyHomePage extends StatefulWidget { @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( centerTitle: true, title: Text('Custom Fonts'), ), body: Container( alignment: Alignment.topCenter, child: Column( mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[ Text( 'Pacifico Regular', style: TextStyle( fontFamily: 'Pacifico', fontSize: 32.0, color: Colors.pink), ), SizedBox(height: 20,), Text( 'Pacifico Bold', style: TextStyle( fontFamily: 'Pacifico', fontWeight: FontWeight.bold, fontSize: 32.0, color: Colors.orange), ), SizedBox(height: 20,), Text( 'MontserratSunbrayada', style: TextStyle( fontFamily: 'MontserratSunbrayada', fontWeight: FontWeight.bold, fontSize: 22.0, color: Colors.green), ), SizedBox(height: 20,), Text( 'FredokaOne', style: TextStyle( fontFamily: 'FradokaOne', fontWeight: FontWeight.bold, fontSize: 28.0, color: Color(0xFFFFC107)), ), SizedBox(height: 20,), Text( 'Hello world', style: GoogleFonts.pinyonScript( fontSize: 50, color: Colors.lightBlue ), ), SizedBox(height: 20,), Text( 'Anna meets Otto', style: TextStyle( fontFamily: 'Some handwriting font', fontSize: 30, color: Colors.red ), ), SizedBox(height: 20,), Text( 'Small Caps', style: TextStyle( fontSize: 30, color: Colors.deepPurple ), ), ], ), ), ); } }