Skip to content

Commit 3cf8415

Browse files
create VerticalAnimationHeroPage
1 parent 1c20741 commit 3cf8415

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import 'package:flutter/material.dart';
2+
3+
class VerticalAnimationHeroPage extends StatefulWidget {
4+
const VerticalAnimationHeroPage({
5+
required this.onSwipe,
6+
required this.child,
7+
super.key,
8+
});
9+
final VoidCallback onSwipe;
10+
final Widget child;
11+
@override
12+
State<VerticalAnimationHeroPage> createState() =>
13+
_VerticalAnimationHeroPageState();
14+
}
15+
16+
class _VerticalAnimationHeroPageState extends State<VerticalAnimationHeroPage> {
17+
final ScrollController controller = ScrollController();
18+
@override
19+
void dispose() {
20+
controller.dispose();
21+
super.dispose();
22+
}
23+
24+
@override
25+
Widget build(BuildContext context) {
26+
return Listener(
27+
onPointerUp: (event) {
28+
double offset = controller.offset;
29+
if (offset < 0) offset = offset * -1;
30+
if (offset > 50) widget.onSwipe();
31+
},
32+
child: CustomScrollView(
33+
physics: const BouncingScrollPhysics(),
34+
controller: controller,
35+
slivers: [
36+
SliverFillRemaining(child: widget.child),
37+
const SliverToBoxAdapter(child: SizedBox(height: 1)),
38+
],
39+
),
40+
);
41+
}
42+
}

0 commit comments

Comments
 (0)