LCOV - code coverage report
Current view: top level - shared/widgets - stretchable_button.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 23 0.0 %
Date: 2022-03-03 12:16:56 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:flutter/material.dart';
       2             : 
       3             : const double defaultBorderRadius = 3.0;
       4             : 
       5             : class StretchableButton extends StatelessWidget {
       6             :   final double borderRadius;
       7             :   final Color buttonColor;
       8             :   final VoidCallback? onPressed;
       9             :   final double? buttonPadding;
      10             :   final Color? splashColor;
      11             :   final Color? buttonBorderColor;
      12             :   final List<Widget> children;
      13             :   final bool centered;
      14             : 
      15           0 :   const StretchableButton({
      16             :     Key? key,
      17             :     required this.buttonColor,
      18             :     required this.borderRadius,
      19             :     required this.children,
      20             :     this.splashColor,
      21             :     this.buttonBorderColor,
      22             :     this.onPressed,
      23             :     this.buttonPadding,
      24             :     this.centered = false,
      25           0 :   }) : super(key: key);
      26             : 
      27           0 :   @override
      28             :   Widget build(BuildContext context) {
      29           0 :     return LayoutBuilder(
      30           0 :       builder: (context, constraints) {
      31           0 :         var contents = List<Widget>.from(children);
      32             : 
      33           0 :         if (constraints.minWidth == 0) {
      34           0 :           contents.add(const SizedBox.shrink());
      35             :         } else {
      36           0 :           if (centered) {
      37           0 :             contents.insert(0, const Spacer());
      38             :           }
      39           0 :           contents.add(const Spacer());
      40             :         }
      41             : 
      42             :         BorderSide bs;
      43           0 :         if (buttonBorderColor != null) {
      44           0 :           bs = BorderSide(
      45           0 :             color: buttonBorderColor ?? Colors.white,
      46             :           );
      47             :         } else {
      48             :           bs = BorderSide.none;
      49             :         }
      50             : 
      51           0 :         return ButtonTheme(
      52             :             height: 40.0,
      53           0 :             padding: EdgeInsets.all(buttonPadding ?? 2),
      54           0 :             shape: RoundedRectangleBorder(
      55           0 :               borderRadius: BorderRadius.circular(borderRadius),
      56             :               side: bs,
      57             :             ),
      58           0 :             child: ElevatedButton(
      59           0 :               onPressed: onPressed,
      60           0 :               style: ButtonStyle(
      61           0 :                 backgroundColor: MaterialStateProperty.all(buttonColor),
      62             :               ),
      63           0 :               child: Row(
      64             :                 mainAxisSize: MainAxisSize.min,
      65             :                 children: contents,
      66             :               ),
      67             :             ));
      68             :       },
      69             :     );
      70             :   }
      71             : }

Generated by: LCOV version 1.13