import 'dart:math' as math; import 'package:flutter/widgets.dart'; /// The widest a detail's reading body (a run or pipeline Summary, a stage /// page's sections) grows on a wide window, so its text, trailing copy /// buttons and facts stay within reach of the title instead of stretching /// to the window's far edge. const double kReadingMaxWidth = 840; /// Caps [child] at [maxWidth] from the leading edge, where the detail's bar /// pieces, header strip and tabs start. It passes the full height through /// unchanged, so a scrollable child fills the height as before; only its /// width is capped. class ReadingWidth extends StatelessWidget { const ReadingWidth({ super.key, required this.child, this.maxWidth = kReadingMaxWidth, }); final Widget child; final double maxWidth; @override Widget build(BuildContext context) => LayoutBuilder( // One structure at every width, so resizing across the cap never // remounts the body (its scroll offset and open sections stay). builder: (context, constraints) { return Align( alignment: AlignmentDirectional.topStart, child: SizedBox( width: math.min(maxWidth, constraints.maxWidth), height: constraints.hasBoundedHeight ? constraints.maxHeight : null, child: child, ), ); }, ); }