LCOV - code coverage report
Current view: top level - code_generators/properties - list_property.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 15 15 100.0 %
Date: 2021-10-28 15:15:49 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:widgetbook_generator/code_generators/properties/property.dart';
       2             : 
       3             : class ListProperty extends Property {
       4           1 :   ListProperty({
       5             :     required String key,
       6             :     required this.properties,
       7             :     this.trailingComma = true,
       8           1 :   }) : super(
       9             :           key: key,
      10             :         );
      11             : 
      12             :   final List<Property> properties;
      13             :   final bool trailingComma;
      14             : 
      15           1 :   @override
      16             :   String valueToCode() {
      17           1 :     final codeOfValues = properties
      18           1 :         .map(
      19             :           // TODO this is a bit weird
      20             :           // since the key is not used in lists
      21           2 :           (property) => property.valueToCode(),
      22             :         )
      23           1 :         .toList();
      24             : 
      25           1 :     final stringBuffer = StringBuffer()
      26           1 :       ..write('[')
      27           1 :       ..write(
      28           1 :         codeOfValues.join(', '),
      29             :       );
      30             : 
      31           3 :     if (trailingComma && properties.isNotEmpty) {
      32           1 :       stringBuffer.write(',');
      33             :     }
      34             : 
      35           1 :     stringBuffer.write(']');
      36           1 :     return stringBuffer.toString();
      37             :   }
      38             : }

Generated by: LCOV version 1.15