LCOV - code coverage report
Current view: top level - form_widget - check_box_form_widget.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 30 30 100.0 %
Date: 2021-10-26 11:03:55 Functions: 0 0 -

          Line data    Source code
       1             : part of apptive_grid_form_widgets;
       2             : 
       3             : /// FormComponent Widget to display a [BooleanFormComponent]
       4             : class CheckBoxFormWidget extends StatefulWidget {
       5             :   /// Creates a [Checkbox] to display a boolean value contained in [component]
       6           3 :   const CheckBoxFormWidget({
       7             :     Key? key,
       8             :     required this.component,
       9           3 :   }) : super(key: key);
      10             : 
      11             :   /// Component this Widget should reflect
      12             :   final BooleanFormComponent component;
      13             : 
      14           2 :   @override
      15           2 :   _CheckBoxFormWidgetState createState() => _CheckBoxFormWidgetState();
      16             : }
      17             : 
      18             : class _CheckBoxFormWidgetState extends State<CheckBoxFormWidget> {
      19           2 :   @override
      20             :   Widget build(BuildContext context) {
      21           2 :     return FormField<bool>(
      22           8 :       initialValue: widget.component.data.value,
      23           1 :       validator: (value) {
      24           3 :         if (widget.component.required && !value!) {
      25             :           return 'Required';
      26             :         } else {
      27             :           return null;
      28             :         }
      29             :       },
      30             :       autovalidateMode: AutovalidateMode.onUserInteraction,
      31           2 :       builder: (state) {
      32           2 :         return InputDecorator(
      33           2 :           decoration: InputDecoration(
      34           8 :             helperText: widget.component.options.description,
      35             :             helperMaxLines: 100,
      36           2 :             errorText: state.errorText,
      37             :             contentPadding: EdgeInsets.zero,
      38             :             border: InputBorder.none,
      39             :             isDense: true,
      40             :             filled: false,
      41             :           ),
      42           2 :           child: ColorFiltered(
      43           2 :             colorFilter: ColorFilter.mode(
      44           4 :               Theme.of(context).errorColor,
      45           2 :               state.hasError ? BlendMode.srcATop : BlendMode.dstIn,
      46             :             ),
      47           2 :             child: Row(
      48             :               crossAxisAlignment: CrossAxisAlignment.start,
      49           2 :               children: [
      50           2 :                 SizedBox(
      51             :                   height: 24,
      52             :                   width: 24,
      53           2 :                   child: Checkbox(
      54           8 :                     value: widget.component.data.value,
      55           1 :                     onChanged: (newValue) {
      56           4 :                       widget.component.data.value = newValue;
      57           1 :                       state.didChange(newValue);
      58           2 :                       setState(() {});
      59             :                     },
      60             :                   ),
      61             :                 ),
      62             :                 const SizedBox(
      63             :                   width: 4,
      64             :                 ),
      65           2 :                 Expanded(
      66           2 :                   child: Text(
      67          14 :                     widget.component.options.label ?? widget.component.property,
      68             :                   ),
      69             :                 ),
      70             :               ],
      71             :             ),
      72             :           ),
      73             :         );
      74             :       },
      75             :     );
      76             :   }
      77             : }

Generated by: LCOV version 1.15