network_font

Last updated:

0 purchases

network_font Image
network_font Images
Add to Cart

Description:

network font

network_font #
Help you easily uses font from network 💪
In case you want user to use a plenty of custom font from network, This network_font package will help you use your custom font from network, so you don't have to store those fonts in your project directory's asset folder.
Also this package is inspired by google_fonts and cached_network_image
Getting Started #

This network_font package will help you use your custom font from network, so you don't have to store in asset folder in the project directory.
How it work? #
Basically just like cached_network_image. If your font file from network isn't exists in user's cache directory or expired, this package'll download and store your font to user's cache directory.

How to use? #
1️⃣ First step is to import network_font
import 'package:network_font/network_font.dart';
copied to clipboard
2️⃣ Second step is to declare you network font's data
final NetworkFont _networkFont = NetworkFont('family', url:'font_url');
copied to clipboard
3️⃣ Last step is to use network_font, there are 3 ways


NetworkFontText Widget
NetworkFontText(
'NetworkFontText Widget',
font: _networkFont,
style: TextStyle(fontSize: 18),
),
copied to clipboard


NetworkFont's style
Text(
'NetworkFont Style',
style: _networkFont.style(fontSize: 18),
),
copied to clipboard


TextStyle network_font extension
Text(
'NetworkFont Extension',
style: TextStyle(fontSize: 18).network(_networkFont),
),
copied to clipboard
However there are no different in technical, only code style that's different 🏄‍♂️


Other function #
initFont #

allow you to init font from network to your application.
copied to clipboard

This function'll read font data from cache.
But If font data doesn't exist or expired, this function'll download from fontData.url and store it to user's cache directory.
Also This operation has unnecessary initialization checker to,
so call initFont on same fontData multiple-time will not repeated.
import 'package:network_font/network_font.dart';
.
.
final NetworkFont _networkFont = NetworkFont('family', url:'font_url');

@override
void initState() {
FontFunction.instance.initFont(_networkFont);
super.initState();
}

@override
Widget build(BuildContext context) {
return Text(
'Example Text',
style: TextStyle(fontFamily: fontFamily: _networkFont.family),
);
}

copied to clipboard
Note: Currently only support OpenType (OTF) and TrueType (TTF) fonts.
setExpiredDuration #

Set expired duration of cached font.
copied to clipboard

Default is 30 days
final DateTime _oneWeek = const Duration(days: 7);

FontFunction.instance.setExpiredDuration(_oneWeek)
copied to clipboard
Note: You should call this before initFont
Join flutter community #
🌎 Global FlutterDev Discord
🇹🇭 Thailand Flutter Developer Group
🇹🇭 FlutterDevTH Discord

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.