floating_sheet.dart
1.34 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
import 'package:flutter/material.dart';
import 'package:sheet/sheet.dart';
class FloatingSheet extends StatefulWidget {
@override
State<FloatingSheet> createState() => _FitSheetState();
}
class _FitSheetState extends State<FloatingSheet> {
final SheetController controller = SheetController();
@override
void initState() {
Future<void>.delayed(const Duration(milliseconds: 400), animateSheet);
super.initState();
}
void animateSheet() {
controller.relativeAnimateTo(1,
duration: const Duration(milliseconds: 400), curve: Curves.easeOut);
}
@override
void dispose() {
controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Sheet.raw(
physics: const SnapSheetPhysics(
parent: BouncingSheetPhysics(overflowViewport: false),
stops: <double>[0, 1],
),
padding: const EdgeInsets.all(20),
child: Container(
height: 200,
alignment: Alignment.topCenter,
child: Container(
height: 200,
width: double.infinity,
child: Material(
elevation: 1,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
color: Colors.grey[900],
),
),
),
controller: controller,
);
}
}