flutter_adaptive_text 1.0.0 copy "flutter_adaptive_text: ^1.0.0" to clipboard
flutter_adaptive_text: ^1.0.0 copied to clipboard

Automatically picks a legible text color (black, white, or any palette color) based on the background color. WCAG 2.1 AA/AAA + APCA support. Drop-in AdaptiveText widget, Color extension, and standalon [...]

1.0.0 #

  • Package name: Published as flutter_adaptive_text — import package:flutter_adaptive_text/flutter_adaptive_text.dart (pub.dev: flutter_adaptive_text).
  • Overview: Legible text color from any solid background — WCAG 2.1 math, optional APCA, zero runtime pub dependencies (Flutter SDK only). Flutter 3.10+, Dart 3.0+.
  • API: getAdaptiveColor, getContrastRatio, getLuminance, isLight / isDark, meetsWcag, getApcaContrast, wcagMinimumRatio, wcagContrastRatioFromLuminance; enums ContrastAlgorithm, WcagLevel.
  • AdaptiveText: Drop-in Text replacement; inherits palette and algorithm from AdaptiveTextTheme when omitted (algorithm is ContrastAlgorithm?; null → theme / WCAG).
  • AdaptiveTextTheme / AdaptiveTextThemeData: Subtree-wide background, palette, and algorithm; cached themeData; maybeOf returns the same instance (no per-lookup allocation). Constructor is not const (initializer constraint). hashCode matches palette contents (consistent with ==).
  • Extensions: AdaptiveColorExtension on Color.adaptiveTextColor, .adaptiveTextColorFrom, .isLight, .isDark, .relativeLuminance, .contrastRatioWith, .meetsWcagWith, .apcaContrastOn.
  • BuildContext: AdaptiveTextBuildContextadaptiveForegroundColor, adaptiveTextTheme (lib/src/context_extension.dart).
  • Performance: WCAG palette path in getAdaptiveColor computes background luminance once per call.
  • APCA: getApcaContrast no longer returns 0 for black-on-white due to over-aggressive near-zero luminance handling.
  • Pub / dartdoc: dart doc --validate-links clean (doc references, See [Text.…] forwarding docs, override docs); README license links use GitHub URLs; .pubignore excludes doc/api/; CI runs dart doc --validate-links before dart pub publish --dry-run.
  • Tests: 50+ unit and widget tests; theme inheritance; context helper; sRGB hex luminance checks.
  • Example: Full multi-platform example/ (including desktop); widget demo for theme + context.adaptiveForegroundColor(); example analysis_options relaxes demo-only deprecations.
  • CI: Format, analyze, test, dart doc validation, dart pub publish --dry-run on the package; parallel example job.
  • Platforms: Declared in pubspec.yaml (Android, iOS, Linux, macOS, web, Windows).
6
likes
150
points
--
downloads

Documentation

API reference

Publisher

verified publisheruzairaslam.com

Weekly Downloads

Automatically picks a legible text color (black, white, or any palette color) based on the background color. WCAG 2.1 AA/AAA + APCA support. Drop-in AdaptiveText widget, Color extension, and standalone utility functions.

Repository (GitHub)
View/report issues

Topics

#text #color #accessibility #wcag #contrast

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_adaptive_text