flutter_adaptive_text 1.0.0
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— importpackage: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; enumsContrastAlgorithm,WcagLevel. AdaptiveText: Drop-inTextreplacement; inheritspaletteandalgorithmfromAdaptiveTextThemewhen omitted (algorithmisContrastAlgorithm?;null→ theme / WCAG).AdaptiveTextTheme/AdaptiveTextThemeData: Subtree-wide background, palette, and algorithm; cachedthemeData;maybeOfreturns the same instance (no per-lookup allocation). Constructor is notconst(initializer constraint).hashCodematches palette contents (consistent with==).- Extensions:
AdaptiveColorExtensiononColor—.adaptiveTextColor,.adaptiveTextColorFrom,.isLight,.isDark,.relativeLuminance,.contrastRatioWith,.meetsWcagWith,.apcaContrastOn. BuildContext:AdaptiveTextBuildContext—adaptiveForegroundColor,adaptiveTextTheme(lib/src/context_extension.dart).- Performance: WCAG palette path in
getAdaptiveColorcomputes background luminance once per call. - APCA:
getApcaContrastno longer returns 0 for black-on-white due to over-aggressive near-zero luminance handling. - Pub / dartdoc:
dart doc --validate-linksclean (doc references,See [Text.…]forwarding docs, override docs); README license links use GitHub URLs;.pubignoreexcludesdoc/api/; CI runsdart doc --validate-linksbeforedart 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(); exampleanalysis_optionsrelaxes demo-only deprecations. - CI: Format, analyze, test, dart doc validation,
dart pub publish --dry-runon the package; parallel example job. - Platforms: Declared in
pubspec.yaml(Android, iOS, Linux, macOS, web, Windows).