Skip to content

Reusable gesture handler and interactive transitions between routes

License

Notifications You must be signed in to change notification settings

JesperBllnbm/gesture_handlers

This branch is 3 commits ahead of kyuqw/gesture_handlers:main.

Repository files navigation

Gesture handlers

Pub Version Pub Likes Pub popularity Flutter Platform

Gesture handlers Flutter project.

Provide reusable gesture handler and Support interactive transitions between routes (i.e., controlled by gesture).

Preview

bottom sheet demo right sheet demo

Installation

Add gesture_handlers as a dependency in your pubspec.yaml file.

flutter pub add gesture_handlers

Import it in your Dart code

import 'package:gesture_handlers/gesture_handlers.dart';

Usage

Basic usage

Initialize concrete GestureHandler implementation.

final tapHandler = TapHandlerDelegate(onTap: () => print('tap handled'));

Pass handler to GestureListener.

@override
Widget build(BuildContext context) {
  return GestureListener(
    handler: tapHandler,
    child: Scaffold(body: Center(child: Text('Tap'))),
  );
}

Dispose it at the end.

@override
void dispose() {
  tapHandler.dispose();
  super.dispose();
}

Route gesture transition

  • Initialize NavigatorGesturesFlutterBinding or use your own NavigatorGesturesBinding implementation for prevent route GestureHandler active pointers canceling by NavigatorState.
import 'package:gesture_handlers/gesture_handlers.dart';

void main() {
  /// Prints information about preventing cancel pointer with [GestureBinding.cancelPointer].
  // debugPrintPreventCancelPointer = true;

  NavigatorGesturesFlutterBinding.ensureInitialized();
  runApp(const MyApp());
}
  • Initialize SwipeRouteHandler or your own GestureRouteDelegate implementation.
  • Use GestureModalBottomSheetRoute, MaterialGesturePageRoute or create custom gesture route with GestureRouteTransitionMixin.

About

Reusable gesture handler and interactive transitions between routes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 55.4%
  • C++ 21.9%
  • CMake 15.9%
  • HTML 4.0%
  • C 1.5%
  • Swift 1.2%
  • Other 0.1%