LCOV - code coverage report
Current view: top level - lib/design/form - list_account_selector.dart Coverage Total Hit
Test: lcov.info Lines: 57.9 % 38 22
Test Date: 2026-11-14 15:04:37 Functions: - 0 0

            Line data    Source code
       1              : // Copyright 2023 The terCAD team. All rights reserved.
       2              : // Use of this source code is governed by a CC BY-NC-ND 4.0 license that can be found in the LICENSE file.
       3              : 
       4              : import 'package:app_finance/_classes/storage/app_data.dart';
       5              : import 'package:app_finance/design/form/list_selector_item.dart';
       6              : import 'package:app_finance/design/form/list_selector.dart';
       7              : import 'package:app_finance/design/generic/base_line_widget.dart';
       8              : import 'package:material_ui/material_ui.dart';
       9              : 
      10              : class ListAccountSelectorItem extends ListSelectorItem {
      11              :   dynamic item;
      12              : 
      13            1 :   @override
      14            2 :   Widget build(context) => LayoutBuilder(builder: (_, constraints) {
      15            1 :         return BaseLineWidget(
      16            2 :           uuid: item.uuid ?? '',
      17            2 :           title: item.title ?? '',
      18            2 :           description: item.description ?? '',
      19            2 :           details: item.detailsFormatted ?? '',
      20              :           progress: 1.0,
      21            2 :           color: item.color ?? Colors.transparent,
      22            2 :           icon: item.icon ?? Icons.radio_button_unchecked_sharp,
      23            2 :           hidden: item.hidden ?? false,
      24            2 :           skip: item.skip ?? false,
      25            1 :           width: constraints.maxWidth,
      26              :           showDivider: false,
      27              :         );
      28              :       });
      29              : 
      30            0 :   @override
      31            0 :   Widget suggest(context) => LayoutBuilder(builder: (_, constraints) {
      32            0 :         return BaseLineWidget(
      33            0 :           uuid: item.uuid ?? '',
      34            0 :           title: item.title ?? '',
      35            0 :           description: item.description ?? '',
      36            0 :           details: item.detailsFormatted ?? '',
      37            0 :           progress: item.progress ?? 0.0,
      38            0 :           color: item.color ?? Colors.transparent,
      39            0 :           icon: item.icon ?? Icons.radio_button_unchecked_sharp,
      40            0 :           hidden: item.hidden ?? false,
      41            0 :           skip: item.skip ?? false,
      42            0 :           width: constraints.maxWidth,
      43              :           showDivider: false,
      44              :         );
      45              :       });
      46              : 
      47            1 :   @override
      48            2 :   String get id => item.uuid;
      49              : 
      50            0 :   @override
      51            0 :   String get name => item.title;
      52              : 
      53            1 :   ListAccountSelectorItem({
      54              :     required this.item,
      55              :     super.name = '',
      56              :     super.id = '',
      57              :   });
      58              : }
      59              : 
      60              : class ListAccountSelector<K extends ListAccountSelectorItem> extends ListSelector<ListAccountSelectorItem> {
      61              :   final AppData state;
      62              :   final double width;
      63              : 
      64            4 :   const ListAccountSelector({
      65              :     super.key,
      66              :     required this.state,
      67              :     required super.setState,
      68              :     required this.width,
      69              :     required super.hintText,
      70              :     super.options = const [],
      71              :     super.value,
      72              :     super.tooltip,
      73              :     super.withLabel,
      74            4 :   }) : super();
      75              : 
      76            1 :   @override
      77              :   List<ListAccountSelectorItem> get options {
      78            2 :     return super.options.isNotEmpty
      79            0 :         ? super.options
      80            6 :         : state.getList(AppDataType.accounts).map((item) => ListAccountSelectorItem(item: item)).toList();
      81              :   }
      82              : 
      83            4 :   @override
      84            4 :   ListSelectorState createState() => ListSelectorState<ListAccountSelector, ListAccountSelectorItem>();
      85              : }
        

Generated by: LCOV version 2.0-1