Add Fontsource fonts to your flutter app. Direct access to Fontsource API

0 0

Fontsource for Flutter

Add Fontsource fonts to your flutter app. Direct access to Fontsource API.

Getting started

To start, create a config in either your pubspec.yaml file under the fontsource key or in the fontsource.yaml file.

fonts:
  alex-brush: # This can be any font id
    version: 4.5.3 # Defaults to latest
    subsets: [latin, latin-ext] # Defaults to all
    weights: [400] # Defaults to all
    styles: [normal] # Defaults to all

The config will tell fontsource what to download and bundle into your flutter app. To ensure everything is downloaded, execute dart run fontsource after your config is modified. Also make sure to run it whenever your repository is cloned. This will generate a local package in the .fontsource directory.

You can then import the fontsource package:

import 'package:fontsource/fontsource.dart';

Use FontsourceTextStyle to use a Fontsource font:

const Text(
  'Hello world!',
  style: FontsourceTextStyle(fontFamily: 'Alex Brush', fontSize: 30),
),

FontsourceTextStyle extends the TextStyle class, so any styling properties can be used to change the way the text looks.

Fontsource API

The Fontsource API also has a dart interface that can be accessed through fontsource/api.dart.

GitHub

View Github

Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Deja una respuesta

Entrada anterior Flutter app to track the value of cryptocurrencies in different currencies
Entrada siguiente A Flutter app for practicing and understanding the GetX State Management and Route Management