LCOV - code coverage report
Current view: top level - components/checkbox - foss_checkbox_style.dart Coverage Total Hit
Test: fossui coverage Lines: 100.0 % 13 13
Test Date: 2026-11-29 09:15:47 Functions: - 0 0

            Line data    Source code
       1              : part of 'foss_checkbox.dart';
       2              : 
       3              : /// Visual overrides for a single checkbox. Every field is optional; a null
       4              : /// field falls back to the value the theme resolves. Pass one via `style:` to
       5              : /// tweak a one-off without changing the theme for every other checkbox.
       6              : ///
       7              : /// State-derived colors (the focus ring, the invalid border, the indeterminate
       8              : /// minus) stay token-driven. To restyle those globally, retheme [FossColors].
       9              : ///
      10              : /// A larger box with a custom checked fill:
      11              : ///
      12              : /// ```dart
      13              : /// FossCheckbox(
      14              : ///   value: true,
      15              : ///   label: 'Pro',
      16              : ///   style: const FossCheckboxStyle(
      17              : ///     boxSize: 22,
      18              : ///     checkedColor: Color(0xFF8A38F5),
      19              : ///   ),
      20              : /// );
      21              : /// ```
      22              : @immutable
      23              : class FossCheckboxStyle {
      24              :   /// Creates a set of checkbox overrides. All fields default to null (inherit).
      25            1 :   const FossCheckboxStyle({
      26              :     this.backgroundColor,
      27              :     this.checkedColor,
      28              :     this.checkColor,
      29              :     this.borderColor,
      30              :     this.shadow,
      31              :     this.boxSize,
      32              :     this.glyphSize,
      33              :     this.gap,
      34              :     this.labelStyle,
      35              :     this.descriptionStyle,
      36              :   });
      37              : 
      38              :   /// Fill of the box when unchecked or indeterminate.
      39              :   final Color? backgroundColor;
      40              : 
      41              :   /// Fill of the box when checked.
      42              :   final Color? checkedColor;
      43              : 
      44              :   /// Color of the checkmark when checked.
      45              :   final Color? checkColor;
      46              : 
      47              :   /// Resting border color of the box.
      48              :   final Color? borderColor;
      49              : 
      50              :   /// Drop shadow layers on the resting box; empty for none.
      51              :   final List<BoxShadow>? shadow;
      52              : 
      53              :   /// Side length of the square box in logical pixels.
      54              :   final double? boxSize;
      55              : 
      56              :   /// Side length of the centered glyph in logical pixels.
      57              :   final double? glyphSize;
      58              : 
      59              :   /// Gap between the box and the texts in logical pixels.
      60              :   final double? gap;
      61              : 
      62              :   /// Style of the label. Its color is ignored; the title color stays
      63              :   /// token-driven.
      64              :   final TextStyle? labelStyle;
      65              : 
      66              :   /// Style of the description. Its color is ignored; the description color
      67              :   /// stays token-driven.
      68              :   final TextStyle? descriptionStyle;
      69              : 
      70              :   /// Returns a copy with every non-null field of [other] laid over this one.
      71              :   ///
      72              :   /// ```dart
      73              :   /// const base = FossCheckboxStyle(boxSize: 18, glyphSize: 14);
      74              :   /// const override = FossCheckboxStyle(glyphSize: 16);
      75              :   /// base.merge(override); // boxSize 18 kept, glyphSize becomes 16
      76              :   /// ```
      77            1 :   FossCheckboxStyle merge(FossCheckboxStyle? other) {
      78              :     if (other == null) return this;
      79            1 :     return FossCheckboxStyle(
      80            2 :       backgroundColor: other.backgroundColor ?? backgroundColor,
      81            2 :       checkedColor: other.checkedColor ?? checkedColor,
      82            2 :       checkColor: other.checkColor ?? checkColor,
      83            2 :       borderColor: other.borderColor ?? borderColor,
      84            2 :       shadow: other.shadow ?? shadow,
      85            2 :       boxSize: other.boxSize ?? boxSize,
      86            2 :       glyphSize: other.glyphSize ?? glyphSize,
      87            2 :       gap: other.gap ?? gap,
      88            2 :       labelStyle: other.labelStyle ?? labelStyle,
      89            2 :       descriptionStyle: other.descriptionStyle ?? descriptionStyle,
      90              :     );
      91              :   }
      92              : }
        

Generated by: LCOV version 2.0-1