swipe_back_detector 1.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 72

swipe_back_detector #

A detector to add "swipe to go back" functionality in custom routes or non cupertino routes.

Attributes #

  • child: is the child to wrap with the pop gesture detector
  • cutoffVelocity: is the minimum velocity needed for the gesture to trigger
  • swipeAreaWidth: is the width of the detection area
  • verticalPadding: allows to restrict the detection area remaining vertically centered
  • popValue: is the value you want to pop out when performing a gesture

Todos: #

  • [ ] Add RTL support

1.0.3 #

Minor bugfixes

1.0.2 #

Improved GestureDetector behavior.

1.0.1 #

Solved a bug which allowed to pop the initial route.

1.0.0 #

Initial release

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:swipe_back_detector/swipe_back_detector.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: FirstScreen(),
    );
  }
}

class FirstScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Swipe back detector example"),
      ),
      body: Center(
        child: RaisedButton(
          child: Text("Push route"),
          onPressed: () {
            Navigator.of(context).push(
              MyCustomRoute(
                widget: SecondScreen(),
              ),
            );
          },
        ),
      ),
    );
  }
}

class SecondScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Second screen"),
        automaticallyImplyLeading: false,
      ),
      body: Center(
          child: Row(
        mainAxisAlignment: MainAxisAlignment.start,
        children: [
          Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            mainAxisAlignment: MainAxisAlignment.center,
            children: List<Widget>.generate(
              5,
              (_) => Icon(Icons.chevron_left),
            ),
          ),
          Text("Swipe here to go back")
        ],
      )),
    );
  }
}

class MyCustomRoute extends PageRouteBuilder {
  final RouteSettings routeSettings;

  MyCustomRoute({
    @required Widget widget,
    this.routeSettings,
  }) : super(
          settings: routeSettings,
          pageBuilder: (context, animation1, animation2) {
            return widget;
          },
          transitionsBuilder: (context, animation1, animation2, child) {
            return SwipeBackDetector(
              child: SlideTransition(
                position: Tween<Offset>(begin: Offset(1, 1), end: Offset.zero)
                    .animate(animation1),
                child: FadeTransition(
                  opacity: animation1,
                  child: widget,
                ),
              ),
            );
          },
          transitionDuration: Duration(milliseconds: 250),
          opaque: false,
          barrierDismissible: true,
        );
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  swipe_back_detector: ^1.0.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:swipe_back_detector/swipe_back_detector.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
44
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
72
Learn more about scoring.

We analyzed this package on Jul 7, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

because of import path [swipe_back_detector] that is in a package requiring null.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.1
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8