LCOV - code coverage report
Current view: top level - src - painter.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 18 18 100.0 %
Date: 2020-02-15 12:36:36 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:flutter/cupertino.dart';
       2             : import 'package:flutter/material.dart';
       3             : 
       4             : import 'convex_shape.dart';
       5             : import 'reused_gradient.dart';
       6             : 
       7             : class ConvexPainter extends CustomPainter {
       8             :   final _paint = Paint();
       9             :   final _shadowPaint = Paint();
      10             :   final _shape = ConvexNotchedRectangle();
      11             :   final ReusedGradient _gradient = ReusedGradient();
      12             :   final double width;
      13             :   final double height;
      14             :   final double top;
      15             :   final Animation<double> leftPercent;
      16             : 
      17           1 :   ConvexPainter({
      18             :     this.top,
      19             :     this.width,
      20             :     this.height,
      21             :     this.leftPercent = const AlwaysStoppedAnimation<double>(0.5),
      22             :     Color color = Colors.white,
      23             :     Color shadowColor = Colors.black38,
      24             :     double sigma = 2,
      25             :     Gradient gradient,
      26           1 :   }) : super(repaint: leftPercent) {
      27           2 :     _paint..color = color;
      28           1 :     _shadowPaint
      29           1 :       ..color = shadowColor
      30           2 :       ..maskFilter = MaskFilter.blur(BlurStyle.outer, sigma);
      31           2 :     _gradient.gradient = gradient;
      32             :   }
      33             : 
      34           1 :   @override
      35             :   void paint(Canvas canvas, Size size) {
      36           3 :     Rect host = Rect.fromLTWH(0, 0, size.width, size.height);
      37           1 :     Rect guest = Rect.fromLTWH(
      38          10 :         size.width * leftPercent.value - width / 2, top, width, height);
      39           3 :     _gradient.updateWith(_paint, size: host);
      40           2 :     Path path = _shape.getOuterPath(host, guest);
      41           2 :     canvas.drawPath(path, _shadowPaint);
      42           2 :     canvas.drawPath(path, _paint);
      43             :   }
      44             : 
      45           1 :   @override
      46             :   bool shouldRepaint(ConvexPainter oldDelegate) {
      47           5 :     return oldDelegate.leftPercent.value != leftPercent.value ||
      48           3 :         oldDelegate._paint != _paint;
      49             :   }
      50             : }

Generated by: LCOV version 1.14