feat(tablet): cap wide-layout margins at 80dp so content uses the screen

This commit is contained in:
zarzet
2026-07-27 01:39:22 +07:00
parent ac56e76b62
commit c42a1be76c
2 changed files with 25 additions and 10 deletions
+19 -9
View File
@@ -1,15 +1,25 @@
import 'package:flutter/widgets.dart';
/// Horizontal inset that centers content of [maxWidth] at [contentMaxWidth];
/// zero once it fits, so rows stop stretching across a wide surface. Prefer
/// this constraint-based form when the widget may live inside an already
/// clamped box (e.g. a bottom sheet), where screen width would over-inset.
double wideInsetForWidth(double maxWidth, {double contentMaxWidth = 720}) =>
maxWidth > contentMaxWidth ? (maxWidth - contentMaxWidth) / 2 : 0;
/// Widest content span for a surface of [maxWidth]: content is never narrower
/// than [contentMaxWidth], and the centering margin never exceeds 80dp per
/// side — so tablets keep near-full-width rows (issue #493) instead of a
/// fixed 720dp column floating in whitespace.
double adaptiveContentMaxWidth(
double maxWidth, {
double contentMaxWidth = 720,
}) => maxWidth > contentMaxWidth + 160 ? maxWidth - 160 : contentMaxWidth;
/// Horizontal inset that centers full-width list content at [contentMaxWidth]
/// on tablets/landscape; zero on phones, so rows stop stretching across the
/// whole screen.
/// Horizontal inset that centers content of [maxWidth] at
/// [adaptiveContentMaxWidth]; zero once it fits. Prefer this constraint-based
/// form when the widget may live inside an already clamped box (e.g. a bottom
/// sheet), where screen width would over-inset.
double wideInsetForWidth(double maxWidth, {double contentMaxWidth = 720}) =>
maxWidth > contentMaxWidth
? ((maxWidth - contentMaxWidth) / 2).clamp(0.0, 80.0)
: 0;
/// Horizontal inset that centers full-width list content on tablets/landscape;
/// zero on phones, so rows stop stretching across the whole screen.
double wideListInset(BuildContext context, {double contentMaxWidth = 720}) =>
wideInsetForWidth(
MediaQuery.sizeOf(context).width,