Thanos snap effect in Flutter

Related tags

Animation snappable
Overview

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'),
    );
  }
}
Comments
  • Request to Add Product in Start Flutter

    Request to Add Product in Start Flutter

    Hello,

    I am Maheshwari from team GeekyAnts. On behalf of Start Flutter, we add open source products which we find helpful to the community & also we provide credits to author itself.

    Let me know if you are interested showcase your product in our open source website.

    Looking forward to hear from you.

    opened by maheshwari-1153 2
  • Effect isn't working for me.

    Effect isn't working for me.

    Hi, yesterday I found this package while building my hackathon project and it didn't work. I tried wrapping a couple of different widgets to check if it works or not.

    Today I scaffolded a new project, the famous counter app, and tried wrapping MyHomePage in Snappable widget and it still doesn't work.

    Am I missing something? Could you please help me? Thanks.

    Example

    import 'package:flutter/material.dart';
    import 'package:snappable/snappable.dart';
    
    void main() {
      runApp(MyApp());
    }
    
    class MyApp extends StatelessWidget {
      // This widget is the root of your application.
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Flutter Demo',
          theme: ThemeData(
            // This is the theme of your application.
            //
            // Try running your application with "flutter run". You'll see the
            // application has a blue toolbar. Then, without quitting the app, try
            // changing the primarySwatch below to Colors.green and then invoke
            // "hot reload" (press "r" in the console where you ran "flutter run",
            // or simply save your changes to "hot reload" in a Flutter IDE).
            // Notice that the counter didn't reset back to zero; the application
            // is not restarted.
            primarySwatch: Colors.blue,
            // This makes the visual density adapt to the platform that you run
            // the app on. For desktop platforms, the controls will be smaller and
            // closer together (more dense) than on mobile platforms.
            visualDensity: VisualDensity.adaptivePlatformDensity,
          ),
          home: Snappable(child: MyHomePage(title: 'Flutter Demo Home Page')),
        );
      }
    }
    
    class MyHomePage extends StatefulWidget {
      MyHomePage({Key key, this.title}) : super(key: key);
    
      // This widget is the home page of your application. It is stateful, meaning
      // that it has a State object (defined below) that contains fields that affect
      // how it looks.
    
      // This class is the configuration for the state. It holds the values (in this
      // case the title) provided by the parent (in this case the App widget) and
      // used by the build method of the State. Fields in a Widget subclass are
      // always marked "final".
    
      final String title;
    
      @override
      _MyHomePageState createState() => _MyHomePageState();
    }
    
    class _MyHomePageState extends State<MyHomePage> {
      int _counter = 0;
    
      void _incrementCounter() {
        setState(() {
          // This call to setState tells the Flutter framework that something has
          // changed in this State, which causes it to rerun the build method below
          // so that the display can reflect the updated values. If we changed
          // _counter without calling setState(), then the build method would not be
          // called again, and so nothing would appear to happen.
          _counter++;
        });
      }
    
      @override
      Widget build(BuildContext context) {
        // This method is rerun every time setState is called, for instance as done
        // by the _incrementCounter method above.
        //
        // The Flutter framework has been optimized to make rerunning build methods
        // fast, so that you can just rebuild anything that needs updating rather
        // than having to individually change instances of widgets.
        return Scaffold(
          appBar: AppBar(
            // Here we take the value from the MyHomePage object that was created by
            // the App.build method, and use it to set our appbar title.
            title: Text(widget.title),
          ),
          body: Center(
            // Center is a layout widget. It takes a single child and positions it
            // in the middle of the parent.
            child: Column(
              // Column is also a layout widget. It takes a list of children and
              // arranges them vertically. By default, it sizes itself to fit its
              // children horizontally, and tries to be as tall as its parent.
              //
              // Invoke "debug painting" (press "p" in the console, choose the
              // "Toggle Debug Paint" action from the Flutter Inspector in Android
              // Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
              // to see the wireframe for each widget.
              //
              // Column has various properties to control how it sizes itself and
              // how it positions its children. Here we use mainAxisAlignment to
              // center the children vertically; the main axis here is the vertical
              // axis because Columns are vertical (the cross axis would be
              // horizontal).
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Text(
                  'You have pushed the button this many times:',
                ),
                Text(
                  '$_counter',
                  style: Theme.of(context).textTheme.headline4,
                ),
              ],
            ),
          ),
          floatingActionButton: FloatingActionButton(
            onPressed: _incrementCounter,
            tooltip: 'Increment',
            child: Icon(Icons.add),
          ), // This trailing comma makes auto-formatting nicer for build methods.
        );
      }
    }
    

    Doctor

    Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel stable, 1.20.4, on Linux, locale en_IN)
     
    [✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    [✓] Android Studio (version 4.0)
    [✓] IntelliJ IDEA Ultimate Edition (version 2019.3)
    [✓] VS Code (version 1.49.1)
    [✓] Connected device (1 available)
    
    • No issues found!
    
    opened by piedcipher 1
  • NoSuchMethodError: The method 'findRenderObject' was called on null. Receiver: null Tried calling: findRenderObject()

    NoSuchMethodError: The method 'findRenderObject' was called on null. Receiver: null Tried calling: findRenderObject()

    Version 1.0.1.

    Non-fatal Exception: NoSuchMethodError: The method 'findRenderObject' was called on null.
    Receiver: null
    Tried calling: findRenderObject()
    0  ???                            0x0 _getImageFromWidget + 232 (snappable.dart:232)
    1  ???                            0x0 snap + 114 (snappable.dart:114)
    

    Probably it was called after parent widget was disposed.

    opened by pawlowskim 0
  • The method 'markNeedsBuild' was called on null. Receiver: null Tried calling: markNeedsBuild()

    The method 'markNeedsBuild' was called on null. Receiver: null Tried calling: markNeedsBuild()

    snappable: 1.0.1

    Non-fatal Exception: NoSuchMethodError: The method 'markNeedsBuild' was called on null.
    Receiver: null
    Tried calling: markNeedsBuild()
    0  ???                            0x0 setState + 1168 (framework.dart:1168)
    1  ???                            0x0 snap + 150 (snappable.dart:150)
    

    Set state called on unmouted widget. Possible fix: add mounted check before setState

    opened by pawlowskim 0
  • NoSuchMethodError: The method 'stop' was called on null. Receiver: null Tried calling: stop()

    NoSuchMethodError: The method 'stop' was called on null. Receiver: null Tried calling: stop()

    Hi, I'm receiving this error on our production application. Our usage is not good enough, I just spotted it, we are using timer to delay some action then call snap method. We are using delays, but also there is delay in the snap method itself. Before calling _animationController.forward(); you should check if controller is not null and widget is mounted. snappable: 1.0.1, error:

    Non-fatal Exception: NoSuchMethodError: The method 'stop' was called on null.
    Receiver: null
    Tried calling: stop()
    0  ???                            0x0 stop + 738 (animation_controller.dart:738)
    1  ???                            0x0 _animateToInternal + 576 (animation_controller.dart:576)
    2  ???                            0x0 forward + 458 (animation_controller.dart:458)
    3  ???                            0x0 snap + 161 (snappable.dart:161)
    
    opened by pawlowskim 0
  • Error on Web

    Error on Web

    Platform Web

    Log: org-dartlang-sdk:///flutter_web_sdk/lib/_engine/engine/surface/scene_builder.dart:227:12 retainedSurface.isActive || retainedSurface.isReleased is not true

    opened by pdliuw 0
Owner
Marcin Szałek
Flutter developer
Marcin Szałek
A Flutter plugin to create views using concentric transition effect.

Concentric Transition A Flutter plugin to create views using Concentric Transition Clipper. Useful for onboarding, page transitions, custom clippers,

Vladyslav Korniienko 202 Jan 7, 2023
A custom Flutter value slider that makes a wave effect when dragged.

A Flutter slider that makes a wave effect when dragged. Does a little bounce when dropped. Demo Getting Started To use this plugin, add wave_slider as

Gordon Hayes 33 Dec 21, 2022
Kenburns effect on flutter

KenBurns The Ken Burns effect is a type of panning and zooming effect used in video production from still imagery. Wrap your image with a KenBurns wid

Florent CHAMPIGNY 82 Sep 22, 2022
🔔 A flutter package to create cool and beautiful text animations. [Flutter Favorite Package]

Animated Text Kit A flutter package which contains a collection of some cool and awesome text animations. Recommended package for text animations in C

Ayush Agarwal 1.4k Jan 6, 2023
This repository demonstrates use of various widgets in flutter and tricks to create beautiful UI elements in flutter for Android and IOS

AwesomeFlutterUI The purpose of this repository is to demonstrate the use of different widgets and tricks in flutter and how to use them in your proje

Subir Chakraborty 132 Nov 13, 2022
This is a Flutter URL preview plugin for Flutter that previews the content of a URL

flutter_link_preview This is a URL preview plugin that previews the content of a URL Language: English | 中文简体 Special feature Use multi-processing to

yung 67 Nov 2, 2022
Flutter liquid swipe - Liquid Swipe Animation Built With Flutter

Flutter Liquid Swipe liquid Swipe animation is amazing and its Created for iOS P

Jahongir Anvarov 6 Dec 1, 2022
A candy sorter game made with Flutter for the march flutter challenge.

A candy sorter game made with Flutter for the march flutter challenge.

Debjeet Das 1 Apr 9, 2022
✨ A collection of loading indicators animated with flutter. Heavily Inspired by http://tobiasahlin.com/spinkit.

✨ Flutter Spinkit A collection of loading indicators animated with flutter. Heavily inspired by @tobiasahlin's SpinKit. ?? Installing dependencies:

Jeremiah Ogbomo 2.7k Dec 30, 2022
A Flutter library for gradually painting SVG path objects on canvas (drawing line animation).

drawing_animation From static SVG assets See more examples in the showcasing app. Dynamically created from Path objects which are animated over time m

null 442 Dec 27, 2022
Flutter package for creating awesome animations.

?? Simple Animations Simple Animations is a powerful package to create beautiful custom animations in no time. ?? fully tested ?? well documented ?? e

Felix Blaschke 879 Dec 31, 2022
Fun canvas animations in Flutter based on time and math functions.

funvas Flutter package that allows creating canvas animations based on time and math (mostly trigonometric) functions. The name "funvas" is based on F

null 472 Jan 9, 2023
A flutter package that adds support for vector data based animations.

animated_vector Description and inspiration A package that adds support for vector data based animations. The data format is heavily inspired from the

Potato Open Sauce Project 6 Apr 26, 2022
Flutter UI Challenges

Introduction ?? Zoo is a small, simple and beautiful app that lists 3d model of animals. Before we start, you can take a look at the app: Usage ?? To

Sanjeev Madhav 58 Dec 22, 2022
A Flutter app with flip animation to view profiles of friends. 🌟

Flip View Made with ?? in India This flutter app is based on the design made Dmytro Prudnikov for Yalantis on Dribble.He describes the design as: Just

Shubham Soni 68 Sep 23, 2022
Simple reactive animations in your Flutter apps.

just.motion Flutter package to create organic motion transitions. Why? The Motion Value stateless hot reload status notifier Ease Motion Spring Motion

Roi Peker 49 Nov 14, 2022
Timer UI animation challenge from 'Flutter Animations Masterclass'

stopwatch_flutter An IOS stopwatch challenge from Flutter Animations Masterclass - Full Course What I learned; Use timer Use ticker Create custom shap

Ali Riza Reisoglu 11 Jan 4, 2023
💙 Google Classroom Clone using Flutter, GCP

Introduction ?? Classroom is a Google Classroom clone built using ?? Flutter. Before we start, you can take a look at the app: Screenshots ?? Key Feat

Sanjeev Madhav 20 Dec 14, 2022
Animated Menu in Flutter using radial.

Animated_radial_Menu_in_Flutter Animated Menu in Flutter using radial. Getting Started This project is a starting point for a Flutter application. A f

Habib ullah 4 Jul 18, 2022