This is the pubspec.yaml. I defined the fonts that I am going to use and I copied the font file to fonts directory of my android project.
name: your_flutter_app
description: A new Flutter project
environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
math_expressions: ^2.0.0 # Add this line to include the math_expressions package
flutter:
fonts:
- family: My-font
fonts:
- asset: fonts/Yarndings20Charted-regular.ttf
And this is my main.dart:
import 'package:flutter/material.dart';
void main() => runApp(MaterialApp(
home: Scaffold (
appBar: AppBar(
title: Text('my First App'),
centerTitle: true,
backgroundColor: Colors.amber.shade100,
),
body: Center(
child: Text(
'I am Haroon',
style: TextStyle(
fontSize: 20,
color: Colors.green,
fontFamily: 'My-font',
),
),
),
floatingActionButton: FloatingActionButton(
child: Text('click'),
onPressed: () {
//Something Here;
},
backgroundColor: Colors.green,
),
),
));
I used pub.get and update dependencies. But none worked!
There might some cases: