flutter_shader_snap 0.0.3 copy "flutter_shader_snap: ^0.0.3" to clipboard
flutter_shader_snap: ^0.0.3 copied to clipboard

A plugin to create the snap effect on any widget. Just add an animationController and a SnapShader with any widget to add the snap effect.

flutter_shader_snap #

pub package MIT license

Create the Thanos snap effect with a simple widget.

Split (default) Smoke
customcropcircle customcropsquare

Getting Started #

Add the dependency to your pubspec.yaml file:

dependencies:
  flutter_shader_snap: latest version

IMPORTANT #

Add the shader to your pubspec.yaml file:

flutter:
  shaders:
    - packages/flutter_shader_snap/shaders/split_snap_effect_shader.glsl # add if you use SnapShaderType.split (default)
    - packages/flutter_shader_snap/shaders/split_reversed_snap_effect_shader.glsl # add if you use SnapShaderType.splitReversed
    - packages/flutter_shader_snap/shaders/smoke_snap_effect_shader.glsl # add if you use SnapShaderType.smoke

Create an AnimationController and just add the SnapShader widget:

class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateMixin {
  late final _controller = AnimationController(
    vsync: this,
    duration: const Duration(seconds: 5),
  );

  @override
  Widget build(BuildContext context) {
    return SnapShader(
        controller: _controller,
        child: Any Widget...
    );
  }
}

Performance #

The shader is only applied to the child widget when the animation is running, so it doesn't affect the performance of the app.

builder: (context, child) => controller.value == 0
    ? child!
    : AnimatedSampler

It works best with "transparent" widgets (for example Text), but you can use it with any widget.

5
likes
130
pub points
71%
popularity

Publisher

verified publisherwive.be

A plugin to create the snap effect on any widget. Just add an animationController and a SnapShader with any widget to add the snap effect.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, flutter_shaders

More

Packages that depend on flutter_shader_snap