LCOV - code coverage report
Current view: top level - lib/util - string_buffer_ext.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 5 6 83.3 %
Date: 2022-01-14 16:05:24 Functions: 0 0 -

          Line data    Source code
       1             : // ignore_for_file: parameter_assignments
       2             : 
       3             : /// extension to [StringBuffer]
       4             : extension StringBufferX on StringBuffer {
       5             :   /// accepts a header string to name the section
       6             :   ///
       7             :   /// wraps the header with brakets
       8           1 :   void writeObject(
       9             :     String string, {
      10             :     required void Function() body,
      11             :     String? open,
      12             :     String? close,
      13             :   }) {
      14           1 :     final openAndCloseAreNullOrNotNull = (open == null) ^ (close == null);
      15             :     if (openAndCloseAreNullOrNotNull) {
      16           0 :       throw ArgumentError(
      17             :         'open and close must both be null or both be non-null',
      18             :       );
      19             :     }
      20             : 
      21             :     final opener = open ?? '{';
      22             :     final closer = close ?? '}';
      23             : 
      24           2 :     writeln('$string$opener');
      25           1 :     body();
      26           1 :     write(closer);
      27             :   }
      28             : }

Generated by: LCOV version 1.15