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';
          });
        },
      ),
    );
  }
}
42
likes
140
pub points
91%
popularity

Publisher

unverified uploader

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

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on swipe