accessibility_kit

Flutter widgets for safer text scaling and accessible text rendering.

accessibility_kit helps you respect the user's system text size while keeping important UI text readable inside constrained layouts. It is useful for labels, buttons, cards, headers, empty states, and other places where very large or very small text scaling can break the interface.

Features

  • AccessibleText: a drop-in wrapper around Flutter's Text widget with an optional maximum text scale.
  • SafeAccessibleText: applies a safe text scale range with configurable minimum and maximum values.
  • Supports common Text options such as style, textAlign, maxLines, overflow, softWrap, and semanticsLabel.
  • Uses Flutter's modern TextScaler API.

Installation

Add the package to your pubspec.yaml:

dependencies:
  accessibility_kit: ^0.0.1

Then run:

flutter pub get

Import it:

import 'package:accessibility_kit/accessibility_kit.dart';

Usage

AccessibleText

Use AccessibleText when you want normal Text behavior, but with the option to cap the text scale for a specific part of the UI.

AccessibleText(
  'Profile settings',
  style: Theme.of(context).textTheme.titleMedium,
  maxScaleFactor: 1.3,
)

Without maxScaleFactor, AccessibleText behaves like a regular Text widget:

const AccessibleText(
  'This text follows the system text scale.',
)

SafeAccessibleText

Use SafeAccessibleText when the text must stay inside a predictable scale range. By default, it keeps the scale between 0.85 and 1.3.

const SafeAccessibleText(
  'Continue',
  maxLines: 1,
)

You can customize the range:

const SafeAccessibleText(
  'Important action',
  minScaleFactor: 1.0,
  maxScaleFactor: 1.4,
  overflow: TextOverflow.ellipsis,
)

You can also provide a separate semantic label for screen readers:

const SafeAccessibleText(
  'Pay',
  semanticsLabel: 'Pay now',
)

Which widget should I use?

Use AccessibleText when you want a regular Text widget with an optional maximum scale.

Use SafeAccessibleText when your layout needs both a minimum and maximum text scale to avoid broken or unreadable UI.

Accessibility note

Avoid limiting text scale globally across your app. Prefer applying these widgets only to constrained UI elements where uncontrolled scaling would break the layout. Body text, articles, forms, and long reading experiences should usually follow the user's full system text scale.

Testing

Run the package tests with:

flutter test

Repository

Source code and issues:

https://github.com/EduardaGarangau/accessibility_kit

License

MIT