Initial commit
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
class ResponsiveBody extends StatelessWidget {
|
||||
const ResponsiveBody({
|
||||
super.key,
|
||||
required this.child,
|
||||
this.maxWidth = 960,
|
||||
this.padding = EdgeInsets.zero,
|
||||
});
|
||||
|
||||
final Widget child;
|
||||
final double maxWidth;
|
||||
final EdgeInsetsGeometry padding;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final width = constraints.maxWidth;
|
||||
final horizontalPadding = switch (width) {
|
||||
>= 1200 => 96.0,
|
||||
>= 900 => 64.0,
|
||||
>= 600 => 32.0,
|
||||
_ => 16.0,
|
||||
};
|
||||
|
||||
return Padding(
|
||||
padding: padding.add(
|
||||
EdgeInsets.symmetric(horizontal: horizontalPadding),
|
||||
),
|
||||
child: Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(maxWidth: maxWidth),
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
height: constraints.maxHeight,
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user