File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
lib/core/widgets/custom_widgets Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments