Files

29 lines
784 B
Dart

import 'dart:math' as math;
import 'package:flutter/widgets.dart';
/// Fits the current window, retaining child state during split-screen resizing.
class AdaptivePage extends StatelessWidget {
const AdaptivePage({super.key, required this.child, this.maxWidth = 840});
final Widget child;
final double maxWidth;
@override
Widget build(BuildContext context) => LayoutBuilder(
builder: (context, constraints) {
final width = constraints.maxWidth;
final contentWidth = width >= 600
? math.min(maxWidth, width - 32)
: width;
return Align(
alignment: Alignment.topCenter,
child: SizedBox(
width: contentWidth,
height: constraints.maxHeight,
child: child,
),
);
},
);
}