design: Column mode auto padding
This commit is contained in:
parent
098dc70bdd
commit
0fa02fec45
13 changed files with 1325 additions and 1220 deletions
38
lib/views/widgets/max_width_body.dart
Normal file
38
lib/views/widgets/max_width_body.dart
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MaxWidthBody extends StatelessWidget {
|
||||
final Widget child;
|
||||
final double maxWidth;
|
||||
final bool withScrolling;
|
||||
|
||||
const MaxWidthBody({
|
||||
this.child,
|
||||
this.maxWidth = 600,
|
||||
this.withScrolling = false,
|
||||
Key key,
|
||||
}) : super(key: key);
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final padding = EdgeInsets.symmetric(
|
||||
horizontal: max(0, (constraints.maxWidth - maxWidth) / 2),
|
||||
);
|
||||
return withScrolling
|
||||
? SingleChildScrollView(
|
||||
physics: ScrollPhysics(),
|
||||
child: Padding(
|
||||
padding: padding,
|
||||
child: child,
|
||||
),
|
||||
)
|
||||
: Padding(
|
||||
padding: padding,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue