LCOV - code coverage report
Current view: top level - lib/widgets/form_widget - enum_form_widget.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 26 26 100.0 %
Date: 2021-11-04 14:59:29 Functions: 0 0 -

          Line data    Source code
       1             : part of apptive_grid_form_widgets;
       2             : 
       3             : /// FormComponent Widget to display a [EnumFormComponent]
       4             : class EnumFormWidget extends StatefulWidget {
       5             :   /// Creates a [Checkbox] to display a boolean value contained in [component]
       6           3 :   const EnumFormWidget({
       7             :     Key? key,
       8             :     required this.component,
       9           3 :   }) : super(key: key);
      10             : 
      11             :   /// Component this Widget should reflect
      12             :   final EnumFormComponent component;
      13             : 
      14           2 :   @override
      15           2 :   _EnumFormWidgetState createState() => _EnumFormWidgetState();
      16             : }
      17             : 
      18             : class _EnumFormWidgetState extends State<EnumFormWidget> {
      19           2 :   @override
      20             :   Widget build(BuildContext context) {
      21           2 :     return DropdownButtonFormField<String>(
      22             :       isExpanded: true,
      23           8 :       items: widget.component.data.options
      24           2 :           .map(
      25           2 :             (e) => DropdownMenuItem(
      26             :               value: e,
      27           2 :               child: AbsorbPointer(absorbing: false, child: Text(e)),
      28             :             ),
      29             :           )
      30           2 :           .toList(),
      31          10 :       selectedItemBuilder: ((_) => widget.component.data.options
      32           2 :           .map(
      33           2 :             (e) => Text(
      34             :               e,
      35             :               maxLines: 1,
      36             :               overflow: TextOverflow.ellipsis,
      37             :             ),
      38             :           )
      39           2 :           .toList()),
      40           1 :       onChanged: (newValue) {
      41           2 :         setState(() {
      42           4 :           widget.component.data.value = newValue;
      43             :         });
      44             :       },
      45           1 :       validator: (value) {
      46           3 :         if (widget.component.required && value == null) {
      47           1 :           return ApptiveGridLocalization.of(context)!
      48           4 :               .fieldIsRequired(widget.component.property);
      49             :         } else {
      50             :           return null;
      51             :         }
      52             :       },
      53             :       autovalidateMode: AutovalidateMode.onUserInteraction,
      54           8 :       value: widget.component.data.value,
      55           2 :       decoration: InputDecoration(
      56           8 :         helperText: widget.component.options.description,
      57             :         helperMaxLines: 100,
      58          14 :         labelText: widget.component.options.label ?? widget.component.property,
      59             :       ),
      60             :     );
      61             :   }
      62             : }

Generated by: LCOV version 1.15