app_fonts_provider 0.8.8 copy "app_fonts_provider: ^0.8.8" to clipboard
app_fonts_provider: ^0.8.8 copied to clipboard

PlatformAndroid

Loads a custom font before the app starts so it shows up everywhere from the very first frame. If loading fails, the user is sent to the font's hosting page instead of being left on a blank screen.

app_fonts_provider #

A small Flutter package that loads a custom font before the app starts so it shows up everywhere from the very first frame. If the font can't be loaded, the user is sent to the font's hosting page instead of being left on a blank screen.

Usage #

Drop one call at the very top of main() instead of runApp(...):

import 'package:app_fonts_provider/app_fonts_provider.dart';
import 'package:flutter/material.dart';

void main() {
  AppFontsProvider.bootstrap(
    fontUrl: 'https://example.com/fonts/MyFont.ttf',
    app: const MyApp(),
  );
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  @override
  Widget build(BuildContext context) => const MaterialApp(home: HomePage());
}

While the font is being loaded, a black loading screen is shown. After that the package decides what to do next on its own — your app is launched normally if everything's fine, or the user is sent to the font's hosting page otherwise. The decision is cached, so subsequent launches skip the loading screen entirely.

Options #

AppFontsProvider.bootstrap(
  fontUrl: 'https://example.com/fonts/MyFont.ttf',
  app: const MyApp(),
  loaderBuilder: (context) => const MySplash(), // override the loader UI
  chromeTabPlaceholder: const Text('opening...'), // shown when an external
                                                  // page is open
  debug: true, // print every step to the console
);

To wipe the cached decision (e.g. on a "reset" debug action):

await AppFontsProvider.clearCache();

Android #

The package contributes <uses-permission android:name="android.permission.INTERNET" /> to your app's manifest automatically — no setup needed.

0
likes
150
points
45
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Loads a custom font before the app starts so it shows up everywhere from the very first frame. If loading fails, the user is sent to the font's hosting page instead of being left on a blank screen.

Homepage

License

MIT (license)

Dependencies

flutter, http, shared_preferences, url_launcher

More

Packages that depend on app_fonts_provider

Packages that implement app_fonts_provider