bouncing_sheet.dart
1.41 KB
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
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:sheet/sheet.dart';
class BounceTopSheet extends StatelessWidget {
const BounceTopSheet({super.key});
@override
Widget build(BuildContext context) {
return Sheet(
physics: const BouncingSheetPhysics(),
child: Container(),
maxExtent: 300,
minExtent: 100,
);
}
}
class BouncingSheetPage extends StatefulWidget {
@override
_BouncingSheetPageState createState() => _BouncingSheetPageState();
}
class _BouncingSheetPageState extends State<BouncingSheetPage> {
final SheetController controller = SheetController();
double minExtent = 0;
@override
void initState() {
Future<void>.delayed(const Duration(milliseconds: 400), animateSheet);
super.initState();
}
void animateSheet() {
controller
.animateTo(
100,
duration: const Duration(milliseconds: 400),
curve: Curves.easeOut,
)
.then(
(_) {
setState(() {
minExtent = 100;
});
},
);
}
@override
void dispose() {
controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Sheet(
minExtent: minExtent,
maxExtent: 400,
elevation: 4,
physics: const BouncingSheetPhysics(),
child: Container(),
controller: controller,
);
}
}