swipe 0.0.1 copy "swipe: ^0.0.1" to clipboard
swipe: ^0.0.1 copied to clipboard

The easy way to detect swipe up, down, left and right in Flutter.

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Swipe Demo',
      theme: ThemeData(
        primarySwatch: Colors.teal,
      ),
      home: SwipePage(),
    );
  }
}

class SwipePage extends StatefulWidget {
  @override
  _SwipePageState createState() => _SwipePageState();
}

class _SwipePageState extends State<SwipePage> {
  String _message = 'Swipe your screen';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Swipe(
        child: Container(
          color: Colors.teal,
          width: MediaQuery.of(context).size.width,
          height: MediaQuery.of(context).size.height,
          child: Center(
            child: Text(_message,
                style: TextStyle(
                  color: Colors.white,
                  fontSize: 32,
                )),
          ),
        ),
        onSwipeUp: () {
          setState(() {
            _message = 'Swiping up';
          });
        },
        onSwipeDown: () {
          setState(() {
            _message = 'Swiping down';
          });
        },
        onSwipeLeft: () {
          setState(() {
            _message = 'Swiping left';
          });
        },
        onSwipeRight: () {
          setState(() {
            _message = 'Swiping right';
          });
        },
      ),
    );
  }
}
45
likes
160
points
1.49k
downloads

Publisher

unverified uploader

Weekly Downloads

The easy way to detect swipe up, down, left and right in Flutter.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on swipe