Coder Social home page Coder Social logo

kyuqw / gesture_handlers Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 2.0 2.97 MB

Reusable gesture handler and interactive transitions between routes

License: Apache License 2.0

Kotlin 0.13% Swift 1.22% Objective-C 0.04% Dart 55.22% CMake 15.94% C++ 21.92% C 1.50% HTML 4.04%
flutter flutter-apps gesture-routes gesture-handling gesture-transition swipe-routes flutter-package gestures swipes transition-routes

gesture_handlers's Introduction

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.

gesture_handlers's People

Contributors

kyuqw avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.