swipe_to_action 0.2.0 copy "swipe_to_action: ^0.2.0" to clipboard
swipe_to_action: ^0.2.0 copied to clipboard

A widget which can be used to call functions when the wrapped child is dragged or flinged.

example/lib/main.dart

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

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _text = "Swipe some tiles!";

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: ListView(
          children: [
            Swipeable(
              key: ValueKey(1),
              onSwipe: (direction) {
                if (direction == SwipeDirection.startToEnd) {
                  setState(() {
                    _text = "Swiped to right!";
                  });
                } else {
                  setState(() {
                    _text = "Swiped to left!";
                  });
                }
              },
              child: ListTile(
                title: Text("Tile one"),
              ),
            ),
            Swipeable(
              key: ValueKey(2),
              onSwipe: (direction) {
                setState(() {
                  _text = "This one can only be swiped to right!";
                });
              },
              background: Container(color: Colors.orange),
              direction: SwipeDirection.startToEnd,
              child: ListTile(
                title: Text("Tile one"),
              ),
            ),
            Swipeable(
              key: ValueKey(3),
              onSwipe: (direction) {
                setState(() {
                  _text = "This one was confirmed with a function!";
                });
              },
              background: Container(color: Colors.green),
              secondaryBackground: Container(color: Colors.teal),
              confirmSwipe: (direction) async {
                return true;
              },
              child: ListTile(
                title: Text("Tile three"),
              ),
            ),
            Center(child: Text(_text)),
          ],
        ),
      ),
    );
  }
}
9
likes
130
pub points
90%
popularity

Publisher

verified publisherinex.dev

A widget which can be used to call functions when the wrapped child is dragged or flinged.

Homepage

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, flutter_web_plugins

More

Packages that depend on swipe_to_action