dev
dart 55 lines 1.6 KB
Raw
1 import 'package:flutter/cupertino.dart';
2 import 'package:flutter/material.dart';
3
4 class ScrollableWithBottomSection extends StatefulWidget {
5 ScrollableWithBottomSection({
6 required this.content,
7 required this.bottomSection,
8 this.topSection,
9 this.contentPadding,
10 this.bottomSectionPadding,
11 this.topSectionPadding,
12 this.scrollableKey,
13 });
14
15 final Widget content;
16 final Widget bottomSection;
17 final Widget? topSection;
18 final EdgeInsets? contentPadding;
19 final EdgeInsets? bottomSectionPadding;
20 final EdgeInsets? topSectionPadding;
21 final Key? scrollableKey;
22
23 @override
24 ScrollableWithBottomSectionState createState() => ScrollableWithBottomSectionState();
25 }
26
27 class ScrollableWithBottomSectionState extends State<ScrollableWithBottomSection> {
28 @override
29 Widget build(BuildContext context) {
30 return Column(
31 children: [
32 if (widget.topSection != null)
33 Padding(
34 padding: widget.topSectionPadding?.copyWith(top: 10) ??
35 EdgeInsets.only(top: 10, bottom: 20, right: 20, left: 20),
36 child: widget.topSection,
37 ),
38 Expanded(
39 child: SingleChildScrollView(
40 key: widget.scrollableKey,
41 child: Padding(
42 padding: widget.contentPadding ?? EdgeInsets.only(left: 20, right: 20),
43 child: widget.content,
44 ),
45 ),
46 ),
47 Padding(
48 padding: widget.bottomSectionPadding?.copyWith(top: 10) ??
49 EdgeInsets.only(top: 10, bottom: 20, right: 20, left: 20),
50 child: widget.bottomSection,
51 ),
52 ],
53 );
54 }
55 }