LCOV - code coverage report
Current view: top level - lib/src/particles - moving_particle.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 9 0.0 %
Date: 2021-08-10 15:50:53 Functions: 0 0 -

          Line data    Source code
       1             : import 'dart:ui';
       2             : 
       3             : import 'package:flutter/animation.dart';
       4             : 
       5             : import '../../extensions.dart';
       6             : import '../components/mixins/single_child_particle.dart';
       7             : import '../particles/curved_particle.dart';
       8             : import 'particle.dart';
       9             : 
      10             : /// Statically move given child [Particle] by given [Vector2].
      11             : ///
      12             : /// If you're looking to move the child, consider the [MovingParticle].
      13             : class MovingParticle extends CurvedParticle with SingleChildParticle {
      14             :   @override
      15             :   Particle child;
      16             : 
      17             :   final Vector2 from;
      18             :   final Vector2 to;
      19             : 
      20           0 :   MovingParticle({
      21             :     required this.child,
      22             :     required this.to,
      23             :     Vector2? from,
      24             :     double? lifespan,
      25             :     Curve curve = Curves.linear,
      26           0 :   })  : from = from ?? Vector2.zero(),
      27           0 :         super(lifespan: lifespan, curve: curve);
      28             : 
      29           0 :   @override
      30             :   void render(Canvas c) {
      31           0 :     c.save();
      32           0 :     final current = from.clone()..lerp(to, progress);
      33           0 :     c.translateVector(current);
      34           0 :     super.render(c);
      35           0 :     c.restore();
      36             :   }
      37             : }

Generated by: LCOV version 1.15