mationani 0.0.22 copy "mationani: ^0.0.22" to clipboard
mationani: ^0.0.22 copied to clipboard

create animation by stateless widget

see mationani in Pub.dev and Github

To prevent scattered instances of AnimationController, Animation, Tween in multiple widgets; there is a stateful widget called Mationani empower us to have an easy way to create animation. With Matoinani, we can only create widgets in a build.

before,

class SampleSlide extends StatefulWidget {
  const SampleSlide({super.key});

  @override
  State<SampleSlide> createState() => _SampleSlideState();
}

class _SampleSlideState extends State<SampleSlide> with SingleTickerProviderStateMixin {
  late final AnimationController controller;
  late final Animation<Offset> animation;

  @override
  void initState() {
    controller = AnimationController(vsync: this, duration: const Duration(seconds: 1));
    animation = controller.drive(Tween(begin: Offset.zero, end: Offset(1, 1)));
    controller.forward();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return SlideTransition(
      position: animation,
      child: CircularProgressIndicator(),
    );
  }
}

after,

class SampleSlide extends StatelessWidget {
  const SampleSlide({super.key});

  @override
  Widget build(BuildContext context) {
    return Mationani(
      mation: MamionTransition.slide(Between(Offset.zero, Offset(1, 1))),
      ani: Ani(
        duration: DurationFR(Duration(seconds: 1), Duration.zero),
        initializer: Ani.initializeForward,
      ),
      child: CircularProgressIndicator(),
    );
  }
}

In tradition, an animation needs a stateful widget with ticker mixin, but now, an animation just needs a stateless widget with Mation and Ani as argument.

Mationani is different to ImplicitlyAnimatedWidget. ImplicitlyAnimatedWidget provides implicitly animation by inheritance through many classes, while Mationani requires only Mation, Between, Ani as arguments in widget build,

2
likes
0
points
11
downloads

Publisher

unverified uploader

Weekly Downloads

create animation by stateless widget

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

damath, datter, flutter, vector_math

More

Packages that depend on mationani