Skip to content
Thanos snap effect in Flutter
Dart Ruby Objective-C Java
Branch: master
Clone or download
Latest commit 11ac439 Aug 9, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example Merge pull request #6 from Vanethos/PR-On-Snapped Aug 9, 2019
lib Change Function to VoidCallback Aug 9, 2019
test initial commit Aug 5, 2019
.gitignore initial commit Aug 5, 2019
.metadata initial commit Aug 5, 2019
CHANGELOG.md Added example Aug 6, 2019
LICENSE initial commit Aug 5, 2019
README.md Callback for when snap ends Aug 8, 2019
pubspec.lock initial commit Aug 5, 2019
pubspec.yaml Added example Aug 6, 2019

README.md

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';

Wrap any widget in Snappable

@override
Widget build(BuildContext context) {
  return Snappable(
    child: Text('This will be snapped'),
  );
}

Snap with a Key

class MyWidget extends StatelessWidget {
  final key = GlobalKey<SnappableState>();
  @override
  Widget build(BuildContext context) {
    return Snappable(
      key: key,
      child: Text('This will be snapped'),
    );
  }
  
  void snap() {
    key.currentState.snap();
  }
}

Undo by currentState.reset().

or snap by tap

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Snappable(
      snapOntap: true,
      child: Text('This will be snapped'),
    );
  }
}

Undo by tapping again.

Callback for when the snap ends

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Snappable(
      onSnapped: () => print("Snapped!"),
      child: Text('This will be snapped'),
    );
  }
}
You can’t perform that action at this time.