clampTextScale static method
Protects the debug pages from a large system font size setting — otherwise text overflows its boxes.
Implementation
static Widget clampTextScale(BuildContext context, Widget child) {
final mediaQuery = MediaQuery.of(context);
final currentScale = mediaQuery.textScaler.scale(14) / 14;
if (currentScale <= _maxTextScale) return child;
return MediaQuery(
data: mediaQuery.copyWith(
textScaler: const TextScaler.linear(_maxTextScale),
),
child: child,
);
}