font_fit 0.0.2 copy "font_fit: ^0.0.2" to clipboard
font_fit: ^0.0.2 copied to clipboard

High-performance auto-sizing Text widget using binary search. Drop-in replacement that automatically fits text within constraints.

FontFit #

A drop-in replacement for Flutter’s Text widget that automatically scales its font size down to fit within the available width/lines.
It uses a fast binary search to find the largest font size that still fits the box.


✨ Features #

  • Keeps your text inside its box without overflowing.
  • Configurable minFontSize, maxFontSize, and maxLines.
  • Honors TextAlign, TextOverflow, and (optionally) the system text scale factor.
  • Works just like Text — easy to swap in.

📦 Installation #

Add to your pubspec.yaml:

dependencies:
  font_fit: ^0.0.1

Run:

flutter pub get

Import it:

import 'package:font_fit/font_fit.dart';

Usage:

FontFit(
  'Very long text that needs to shrink',
  style: const TextStyle(fontSize: 24),
  minFontSize: 10,
  maxLines: 1,
)

FontFit will try to render the text at the provided style size (24 in this example), and shrink down until it fits (but never below minFontSize).
1
likes
160
points
79
downloads

Publisher

unverified uploader

Weekly Downloads

High-performance auto-sizing Text widget using binary search. Drop-in replacement that automatically fits text within constraints.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on font_fit