-
Notifications
You must be signed in to change notification settings - Fork 32
/
yaru_section.dart
79 lines (72 loc) · 2.39 KB
/
yaru_section.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import 'package:flutter/material.dart';
import 'package:yaru_widgets/src/constants.dart';
class YaruSection extends StatelessWidget {
/// Creates a yaru style section widget with multiple
/// [Widgets] as children.
const YaruSection({
Key? key,
this.headline,
required this.children,
this.width,
this.headerWidget,
this.padding = const EdgeInsets.only(bottom: 20.0),
}) : super(key: key);
/// Text that is placed above the list of `children`.
final String? headline;
/// Creates a vertical list of widgets.
/// All children will be of type [Widget],
final List<Widget> children;
/// Specifies the [width] of the [Container].
/// By default the width will be 500.
final double? width;
/// Aligns the widget horizontally along with headline.
///
/// Both `headline` and `headerWidget` will be aligned horizontally
/// with [mainAxisAlignment] as [MainAxisAlignment.spaceBetween].
final Widget? headerWidget;
/// The padding [EdgeInsets] which defaults to `EdgeInsets.only(bottom: 20.0)`.
final EdgeInsets padding;
@override
Widget build(BuildContext context) {
return Padding(
padding: padding,
child: SizedBox(
width: width,
child: Container(
padding: const EdgeInsets.all(8.0),
decoration: BoxDecoration(
border: Border.all(
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.15),
),
borderRadius: const BorderRadius.all(
Radius.circular(kDefaultContainerRadius),
),
),
child: Column(
children: [
Padding(
padding: EdgeInsets.all(headline != null ? 8.0 : 0),
child: Align(
alignment: Alignment.topLeft,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
if (headline != null)
Text(
headline!,
style: Theme.of(context).textTheme.titleLarge,
textAlign: TextAlign.left,
),
headerWidget ?? const SizedBox()
],
),
),
),
Column(children: children)
],
),
),
),
);
}
}