online_font 1.0.0 copy "online_font: ^1.0.0" to clipboard
online_font: ^1.0.0 copied to clipboard

retracted

A package to allow you to use online fonts in your flutter app.

online_font #

pub package

A package to allow you to use online fonts in your flutter app.

Inspired by google_fonts.

Usage #

Declare your font family like this:

class YujiMai extends OnlineFont {
  const YujiMai();

  @override
  String get fontFamily => 'YujiMai';

  @override
  Map<FontVariant, FontFile> get fonts => {
    const FontVariant(fontWeight: FontWeight.w400, fontStyle: FontStyle.normal):
        const FontFile(
            url:
                'https://fonts.gstatic.com/s/a/d6741e6df72abe0287210735f84bb297fb8704e9e44ae1bd53e9366f75215ce8.ttf',
            // optional
            expectedFileHash:
                'd6741e6df72abe0287210735f84bb297fb8704e9e44ae1bd53e9366f75215ce8',
            // optional
            expectedLength: 7830152,
            // optional
            extensionName: 'ttf',
        ),
    };
}

or like this:

final yujiMai = RawOnlineFont(fontFamily: 'YujiMai', fonts: ...);

Use it like this:

Text('Hello, world', style: yujiMai.textStyle());
Text('Hello, world', style: const YujiMai().textStyle());

And you can preload it like this:

await yujiMai.loadAll();

// then use it like this
const Text('Hello, world', style: TextStyle(fontFamily: 'YujiMai-Regular'));
// If you don't matter the `const`, you can use the above written way
Text('Hello, world', style: yujiMai.textStyle());
Text('Hello, world', style: const YujiMai().textStyle());

Or you just want to preload one variant:

await yujiMai.loadVariant(FontVariant.regular);
1
likes
0
points
173
downloads

Publisher

verified publishernysm.dev

Weekly Downloads

A package to allow you to use online fonts in your flutter app.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

crypto, flutter, http, path_provider

More

Packages that depend on online_font