LCOV - code coverage report
Current view: top level - src/style - blend_image_icon.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 10 15 66.7 %
Date: 2020-03-09 19:58:44 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:flutter/cupertino.dart';
       2             : import 'package:flutter/foundation.dart';
       3             : import 'package:flutter/material.dart';
       4             : 
       5             : /// Decorate the provided [Image] or [IconData].
       6             : class BlendImageIcon<T> extends StatelessWidget {
       7             :   /// Create image widget
       8           1 :   const BlendImageIcon(this.image, {Key key, this.color, this.size})
       9           2 :       : assert(image is Widget || image is IconData,
      10             :             'image must be IconData or Widget'),
      11           1 :         super(key: key);
      12             : 
      13             :   /// Color used for Icon and gradient.
      14             :   final Color color;
      15             : 
      16             :   /// Child image.
      17             :   final T image;
      18             : 
      19             :   /// Size of icon.
      20             :   final double size;
      21             : 
      22           1 :   @override
      23             :   Widget build(BuildContext context) {
      24           2 :     if (image is Widget) {
      25           3 :       var s = size ?? IconTheme.of(context).size;
      26             :       // flutter web do not support shader mask. (flutter v1.12.x)
      27           1 :       var showRawImage = kIsWeb || color == null;
      28             :       if (showRawImage) {
      29           1 :         return SizedBox(
      30             :           width: s,
      31             :           height: s,
      32           1 :           child: image as Widget,
      33             :         );
      34             :       }
      35           0 :       return SizedBox(
      36             :         width: s,
      37             :         height: s,
      38           0 :         child: ShaderMask(
      39           0 :           child: image as Widget,
      40           0 :           shaderCallback: (Rect bounds) {
      41           0 :             return LinearGradient(colors: [color, color]).createShader(bounds);
      42             :           },
      43             :           blendMode: BlendMode.srcIn,
      44             :         ),
      45             :       );
      46             :     }
      47           4 :     return Icon(image as IconData, size: size, color: color);
      48             :   }
      49             : }

Generated by: LCOV version 1.14