LCOV - code coverage report
Current view: top level - instances - instance.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 20 24 83.3 %
Date: 2021-10-29 10:23:11 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:collection/collection.dart';
       2             : import 'package:meta/meta.dart';
       3             : 
       4             : import 'package:widgetbook_generator/code_generators/instances/base_instance.dart';
       5             : import 'package:widgetbook_generator/code_generators/properties/property.dart';
       6             : 
       7             : @immutable
       8             : abstract class Instance extends BaseInstance {
       9           6 :   const Instance({
      10             :     required this.name,
      11             :     required this.properties,
      12             :     this.trailingComma = true,
      13             :   });
      14             : 
      15             :   final String name;
      16             :   final List<Property> properties;
      17             :   final bool trailingComma;
      18             : 
      19           1 :   String _propertiesToCode() {
      20             :     final codeForProperties =
      21           5 :         properties.map((property) => property.toCode()).toList();
      22             : 
      23           1 :     return codeForProperties.join(', ');
      24             :   }
      25             : 
      26           1 :   @override
      27             :   String toCode() {
      28           1 :     final stringBuffer = StringBuffer()
      29           2 :       ..write(name)
      30           1 :       ..write('(')
      31           1 :       ..write(
      32           1 :         _propertiesToCode(),
      33             :       );
      34             : 
      35           3 :     if (trailingComma && properties.isNotEmpty) {
      36           1 :       stringBuffer.write(',');
      37             :     }
      38             : 
      39           1 :     stringBuffer.write(')');
      40           1 :     return stringBuffer.toString();
      41             :   }
      42             : 
      43           2 :   @override
      44             :   bool operator ==(Object other) {
      45             :     if (identical(this, other)) return true;
      46           2 :     final listEquals = const DeepCollectionEquality().equals;
      47             : 
      48           2 :     return other is Instance &&
      49           6 :         other.name == name &&
      50           4 :         listEquals(other.properties, properties) &&
      51           6 :         other.trailingComma == trailingComma;
      52             :   }
      53             : 
      54           0 :   @override
      55             :   int get hashCode =>
      56           0 :       name.hashCode ^ properties.hashCode ^ trailingComma.hashCode;
      57             : 
      58           0 :   @override
      59             :   String toString() =>
      60           0 :       'Instance(name: $name, properties: $properties, trailingComma: $trailingComma)';
      61             : }

Generated by: LCOV version 1.15