Skip to content

Commit 4583f6b

Browse files
committed
MaxWidthBox Creation
1 parent baece94 commit 4583f6b

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

lib/max_width_box.dart

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import 'package:flutter/material.dart';
2+
3+
class MaxWidthBox extends StatelessWidget {
4+
final double? maxWidth;
5+
6+
/// Control the internal Stack alignment. This widget
7+
/// uses a Stack to set the widget to max width on top of
8+
/// a background.
9+
/// Defaults to [Alignment.topCenter] because app
10+
/// content is usually top aligned.
11+
final AlignmentGeometry alignment;
12+
final Widget child;
13+
final Widget? background;
14+
15+
const MaxWidthBox(
16+
{Key? key,
17+
required this.maxWidth,
18+
required this.child,
19+
this.background,
20+
this.alignment = Alignment.topCenter})
21+
: super(key: key);
22+
23+
@override
24+
Widget build(BuildContext context) {
25+
return Stack(
26+
alignment: alignment,
27+
children: [
28+
background ?? const SizedBox.shrink(),
29+
SizedBox(width: maxWidth, child: child),
30+
],
31+
);
32+
}
33+
}

lib/responsive_framework.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
library responsive_framework;
22

33
export 'breakpoint.dart';
4+
export 'max_width_box.dart';
45
export 'responsive_breakpoints.dart';
56
export 'responsive_grid.dart';
67
export 'responsive_row_column.dart';

0 commit comments

Comments
 (0)