remote_fonts 1.1.4 copy "remote_fonts: ^1.1.4" to clipboard
remote_fonts: ^1.1.4 copied to clipboard

Fetch and load remote fonts during Flutter app runtime. Also has ability to cache previously loaded fonts.

Features 💘 #

Fetch and load remote fonts during Flutter app runtime 💘 Also has ability to cache previously loaded fonts.

Getting started #

flutter pub add remote_fonts

Screenshot #

Example screenshot

Usage #

import 'package:remote_fonts/remote_fonts.dart';
import 'package:path_provider/path_provider.dart';
import 'package:flutter/material.dart';
import 'package:path/path.dart' as path;

RemoteFont _notoSansFont(Future<String> cacheDirPath) {
  return RemoteFont(
    family: 'NotoSans',
    cacheDirPath: cacheDirPath, // Optional but required for caching to work
    assets: [
      const RemoteFontAsset(
        'https://example.com/fonts/NotoSans/NotoSans-Regular.ttf',

        // Optional but required for caching to work
        // md5sum (or sha256sum) of font file
        'b9ba72dfa580114ddb2ccf06f93b31b1',
      ),
      const RemoteFontAsset(
        'https://example.com/fonts/NotoSans/NotoSans-Bold.ttf',

        // Optional but required for caching to work
        // sha256sum (or md5sum) of font file
        '5dd7fc028a59d98f1c87e58b70cc94077633ca0c33d2522c08985fee26334ee6',
      ),
    ],
  );
}

class NiceText extends StatelessWidget {
  const NiceText({super.key});

  @override
  Widget build(BuildContext context) {
    final cacheDirPath = getTemporaryDirectory().then(
      (tempDir) => path.join(tempDir.path, 'font_cache'),
    );
    final font = _notoSansFont(cacheDirPath);
    RemoteFontsLoader.load([font]); // No need to await the Future, fonts are
                                    // automatically loaded to flutter engine

    return Text(
      'Some nice text',
      style: TextStyle(fontFamily: font.family),
    );
  }
}
1
likes
130
points
53
downloads

Documentation

API reference

Publisher

verified publishergopaul.me

Weekly Downloads

Fetch and load remote fonts during Flutter app runtime. Also has ability to cache previously loaded fonts.

Repository (GitHub)
View/report issues

License

Apache-2.0 (license)

Dependencies

crypto, flutter, http, path

More

Packages that depend on remote_fonts