Skip to content

Commit 2a96fb5

Browse files
committed
stable channel support
1 parent aca3694 commit 2a96fb5

File tree

4 files changed

+35
-29
lines changed

4 files changed

+35
-29
lines changed

example/lib/main.dart

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import 'package:flutter/material.dart';
33
import 'package:gesture_handlers/gesture_handlers.dart';
44

55
void main() {
6+
// debugPrintRecognizerCallbacksTrace = true;
67
// debugPrintPreventCancelPointer = true;
8+
9+
/// [GestureBinding] implementation for prevent route [GestureHandler] active pointers canceling by [NavigatorState].
710
NavigatorGesturesFlutterBinding.ensureInitialized();
811
runApp(const MyApp());
912
}
@@ -40,7 +43,7 @@ class MyHomePage extends StatefulWidget {
4043
}
4144

4245
class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {
43-
late final AnimationControllerSwipeHandler persistentBottomSwipeHandler;
46+
late final AnimationController persistentBottomController;
4447
late final SwipeRouteHandler secondSwipeHandler;
4548
late final AnimationControllerGestureMixin horizontalSwipeHandler;
4649
late final GestureHandler handlerComposer;
@@ -51,15 +54,16 @@ class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {
5154

5255
double get bottomSheetHeight => 0.8 * size.height;
5356

54-
bool get isPersistentBottomOpened => persistentBottomSwipeHandler.controller.value.round() > 0;
57+
bool get isPersistentBottomOpened => persistentBottomController.value.round() > 0;
5558

5659
@override
5760
void initState() {
5861
super.initState();
59-
persistentBottomSwipeHandler = AnimationControllerSwipeHandler(
62+
persistentBottomController = AnimationController(duration: const Duration(milliseconds: 300), vsync: this);
63+
final persistentBottomSwipeHandler = AnimationControllerSwipeHandler(
6064
direction: DragDirection.vertical,
6165
reverse: true,
62-
controller: AnimationController(duration: const Duration(milliseconds: 300), vsync: this),
66+
controller: persistentBottomController,
6367
getChildSize: () => persistentBottomHeight,
6468
);
6569
secondSwipeHandler = SwipeRouteHandler(
@@ -99,9 +103,8 @@ class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {
99103

100104
@override
101105
void dispose() {
102-
persistentBottomSwipeHandler.controller.dispose();
103-
secondSwipeHandler.controller.dispose();
104-
horizontalSwipeHandler.controller.dispose();
106+
persistentBottomController.dispose();
107+
handlerComposer.dispose();
105108
super.dispose();
106109
}
107110

@@ -126,7 +129,7 @@ class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {
126129

127130
Widget buildPersistentBottom(BuildContext context) {
128131
return SizeTransition(
129-
sizeFactor: persistentBottomSwipeHandler.controller,
132+
sizeFactor: persistentBottomController,
130133
axisAlignment: -1.0,
131134
child: Card(
132135
margin: EdgeInsets.zero,

lib/src/gesture_navigation/gesture_bottom_sheet.dart

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ class ModalBottomSheet<T> extends StatefulWidget {
104104
final BoxConstraints? constraints;
105105

106106
@override
107-
_ModalBottomSheetState<T> createState() => _ModalBottomSheetState<T>();
107+
ModalBottomSheetState<T> createState() => ModalBottomSheetState<T>();
108108
}
109109

110-
class _ModalBottomSheetState<T> extends State<ModalBottomSheet<T>> {
110+
class ModalBottomSheetState<T> extends State<ModalBottomSheet<T>> {
111111
GestureModalBottomSheetRoute<T> get route => widget.route;
112112

113113
String _getRouteLabel(MaterialLocalizations localizations) {
@@ -136,20 +136,23 @@ class _ModalBottomSheetState<T> extends State<ModalBottomSheet<T>> {
136136
label: routeLabel,
137137
explicitChildNodes: true,
138138
child: ClipRect(
139-
child: BottomSheet(
140-
// animationController: route.controller,
141-
onClosing: () {
142-
if (route.isCurrent) {
143-
Navigator.pop(context);
144-
}
145-
},
146-
builder: route.builder,
147-
backgroundColor: widget.backgroundColor,
148-
elevation: widget.elevation,
149-
shape: widget.shape,
150-
clipBehavior: widget.clipBehavior,
151-
constraints: widget.constraints,
152-
enableDrag: false,
139+
child: Container(
140+
constraints: widget.constraints, // TODO: remove & use BottomSheet constraints
141+
child: BottomSheet(
142+
// animationController: route.controller,
143+
onClosing: () {
144+
if (route.isCurrent) {
145+
Navigator.pop(context);
146+
}
147+
},
148+
builder: route.builder,
149+
backgroundColor: widget.backgroundColor,
150+
elevation: widget.elevation,
151+
shape: widget.shape,
152+
clipBehavior: widget.clipBehavior,
153+
// constraints: widget.constraints,
154+
enableDrag: false,
155+
),
153156
),
154157
),
155158
);

lib/src/gesture_navigation/navigator_gesture_recognizer.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ mixin NavigatorGesturesOneSequenceMixin on OneSequenceGestureRecognizer
3535

3636
class RouteHorizontalDragGestureRecognizer extends HorizontalDragGestureRecognizer
3737
with NavigatorGesturesPreventingCancelingMixin, NavigatorGesturesOneSequenceMixin {
38-
RouteHorizontalDragGestureRecognizer({Object? debugOwner, Set<PointerDeviceKind>? supportedDevices})
39-
: super(debugOwner: debugOwner, supportedDevices: supportedDevices);
38+
RouteHorizontalDragGestureRecognizer({Object? debugOwner, PointerDeviceKind? kind /*, Set<PointerDeviceKind>? supportedDevices */})
39+
: super(debugOwner: debugOwner, kind: kind/*, supportedDevices: supportedDevices */);
4040
}
4141

4242
class RouteVerticalDragGestureRecognizer extends VerticalDragGestureRecognizer
4343
with NavigatorGesturesPreventingCancelingMixin, NavigatorGesturesOneSequenceMixin {
44-
RouteVerticalDragGestureRecognizer({Object? debugOwner, Set<PointerDeviceKind>? supportedDevices})
45-
: super(debugOwner: debugOwner, supportedDevices: supportedDevices);
44+
RouteVerticalDragGestureRecognizer({Object? debugOwner, PointerDeviceKind? kind /*, Set<PointerDeviceKind>? supportedDevices */})
45+
: super(debugOwner: debugOwner, kind: kind/*, supportedDevices: supportedDevices */);
4646
}

lib/src/gestures_binding.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'package:flutter/widgets.dart';
66
/// This flag only has an effect in debug mode.
77
bool debugPrintPreventCancelPointer = false;
88

9-
/// [GestureBinding] implementation for prevent [RouteGestureHandler] active pointers canceling by [NavigatorState].
9+
/// [GestureBinding] implementation for prevent route [GestureHandler] active pointers canceling by [NavigatorState].
1010
///
1111
/// [NavigatorState] cancel active pointers after navigation.
1212
mixin NavigatorGesturesBinding on GestureBinding {

0 commit comments

Comments
 (0)