https://github.com/MarcinusX/snappable
Thanos snap effect in Flutter
https://github.com/MarcinusX/snappable
Last synced: 11 months ago
JSON representation
Thanos snap effect in Flutter
- Host: GitHub
- URL: https://github.com/MarcinusX/snappable
- Owner: MarcinusX
- License: bsd-2-clause
- Created: 2019-08-05T19:29:21.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-10-01T19:00:04.000Z (over 2 years ago)
- Last Synced: 2024-10-30T02:59:22.544Z (over 1 year ago)
- Language: Dart
- Homepage: https://fidev.io/thanos
- Size: 64.5 KB
- Stars: 335
- Watchers: 9
- Forks: 34
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-list - snappable
README
# snappable
Thanos effect library in Flutter
Check out [blog post](https://fidev.io/thanos) describing the package on [Fidev](https://fidev.io).
## Examples



## Getting Started
### Import it
```dart
import 'package:snappable/snappable.dart';
```
### Wrap any widget in Snappable
```dart
@override
Widget build(BuildContext context) {
return Snappable(
child: Text('This will be snapped'),
);
}
```
#### Snap with a Key
```dart
class MyWidget extends StatelessWidget {
final key = GlobalKey();
@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
```dart
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
```dart
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Snappable(
onSnapped: () => print("Snapped!"),
child: Text('This will be snapped'),
);
}
}
```