LCOV - code coverage report
Current view: top level - src - icon_btn.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 15 0.0 %
Date: 2022-02-12 14:49:12 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:flutter/cupertino.dart';
       2             : import 'package:flutter/material.dart';
       3             : 
       4             : /// Icon button widget built different
       5             : /// depends on [MaterialApp] or [CupertinoApp] ancestor.
       6             : class IconBtn extends StatelessWidget {
       7             :   /// Widget to use inside button.
       8             :   ///
       9             :   /// Typically [Icon] widget.
      10             :   final Widget icon;
      11             : 
      12             :   /// Function called when user tap on the button.
      13             :   ///
      14             :   /// Can be null. In this case button will be disabled.
      15             :   final VoidCallback? onTap;
      16             : 
      17             :   /// Tooltip for button.
      18             :   ///
      19             :   /// Applied only for material style buttons.
      20             :   /// It means only if widget has [MaterialApp] ancestor.
      21             :   final String? tooltip;
      22             : 
      23             :   /// Creates button with [icon] different
      24             :   /// depends on [MaterialApp] or [CupertinoApp] ancestor.
      25           0 :   const IconBtn({
      26             :     Key? key,
      27             :     required this.icon,
      28             :     this.onTap,
      29             :     this.tooltip
      30           0 :   }) : super(key: key);
      31             : 
      32           0 :   @override
      33             :   Widget build(BuildContext context) {
      34           0 :     bool isMaterial =  Material.of(context) != null;
      35             : 
      36             :     return isMaterial
      37           0 :       ? _materialBtn()
      38           0 :       : _cupertinoBtn();
      39             :   }
      40             : 
      41           0 :   Widget _cupertinoBtn() =>
      42           0 :       CupertinoButton(
      43             :         padding: const EdgeInsets.all(0.0),
      44           0 :         child: icon,
      45           0 :         onPressed: onTap,
      46             :       );
      47             : 
      48           0 :   Widget _materialBtn() =>
      49           0 :      IconButton(
      50           0 :        icon: icon,
      51           0 :        tooltip: tooltip ?? "",
      52           0 :        onPressed: onTap,
      53             :     );
      54             : }

Generated by: LCOV version 1.15