afjal1 / snappable

Thanos snap effect in Flutter

Home Page:https://fidev.io/thanos

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

snappable

Thanos effect library in Flutter

Check out blog post describing the package on Fidev.

Examples

Example 1 Example 2 Example 3

Getting Started

Import it

import 'package:snappable/snappable.dart';

Snap with a Key

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  MyHomePageState createState() => MyHomePageState();
}

class MyHomePageState extends State<MyHomePage> {
  final _snappableKey = GlobalKey<SnappableState>();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Snap'),
      ),
      body: Column(
        children: <Widget>[
          Snappable(
            key: _snappableKey,
            snapOnTap: true,
            onSnapped: () => print("Snapped!"),
            child: Card(
              child: Container(
                height: 300,
                width: double.infinity,
                color: Colors.deepPurple,
                alignment: Alignment.center,
                child: Text(
                  'This will be sanpped',
                  style: Theme.of(context).textTheme.headline6!.copyWith(
                        color: Colors.white,
                      ),
                ),
              ),
            ),
          ),
          RaisedButton(
            child: const Text('Snap / Reverse'),
            onPressed: () {
              SnappableState state = _snappableKey.currentState!;
              if (state.isGone) {
                state.reset();
              } else {
                state.snap();
              }
            },
          )
        ],
      ),
    );
  }
}

About

Thanos snap effect in Flutter

https://fidev.io/thanos

License:BSD 2-Clause "Simplified" License


Languages

Language:C++ 38.5%Language:CMake 33.4%Language:Dart 19.8%Language:HTML 3.3%Language:C 2.6%Language:Swift 2.1%Language:Kotlin 0.2%Language:Objective-C 0.1%