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

            Line data    Source code
       1              : part of 'foss_switch.dart';
       2              : 
       3              : /// Visual overrides for a single switch. Every field is optional; a null field
       4              : /// falls back to the value the theme resolves. Pass one via `style:` to tweak a
       5              : /// one-off without changing the theme for every other switch.
       6              : ///
       7              : /// The focus ring stays token-driven (the `ring` role); to restyle it globally,
       8              : /// retheme [FossColors].
       9              : ///
      10              : /// A wider track with a custom on color:
      11              : ///
      12              : /// ```dart
      13              : /// FossSwitch(
      14              : ///   value: true,
      15              : ///   style: const FossSwitchStyle(
      16              : ///     trackWidth: 44,
      17              : ///     activeTrackColor: Color(0xFF16A34A),
      18              : ///   ),
      19              : /// );
      20              : /// ```
      21              : @immutable
      22              : class FossSwitchStyle {
      23              :   /// Creates a set of switch overrides. All fields default to null (inherit).
      24            1 :   const FossSwitchStyle({
      25              :     this.activeTrackColor,
      26              :     this.inactiveTrackColor,
      27              :     this.thumbColor,
      28              :     this.shadow,
      29              :     this.trackWidth,
      30              :     this.trackHeight,
      31              :     this.thumbSize,
      32              :   });
      33              : 
      34              :   /// Track fill when on.
      35              :   final Color? activeTrackColor;
      36              : 
      37              :   /// Track fill when off.
      38              :   final Color? inactiveTrackColor;
      39              : 
      40              :   /// Fill of the sliding thumb.
      41              :   final Color? thumbColor;
      42              : 
      43              :   /// Drop shadow layers under the thumb; empty for none.
      44              :   final List<BoxShadow>? shadow;
      45              : 
      46              :   /// Track width in logical pixels. The thumb travel is the inner width minus
      47              :   /// the thumb, so a wider track lengthens the travel.
      48              :   final double? trackWidth;
      49              : 
      50              :   /// Track height in logical pixels. The thumb inset is half the difference
      51              :   /// between this and [thumbSize].
      52              :   final double? trackHeight;
      53              : 
      54              :   /// Diameter of the thumb in logical pixels.
      55              :   final double? thumbSize;
      56              : 
      57              :   /// Returns a copy with every non-null field of [other] laid over this one.
      58              :   ///
      59              :   /// ```dart
      60              :   /// const base = FossSwitchStyle(trackWidth: 38, thumbSize: 20);
      61              :   /// const override = FossSwitchStyle(thumbSize: 18);
      62              :   /// base.merge(override); // trackWidth 38 kept, thumbSize becomes 18
      63              :   /// ```
      64            1 :   FossSwitchStyle merge(FossSwitchStyle? other) {
      65              :     if (other == null) return this;
      66            1 :     return FossSwitchStyle(
      67            1 :       activeTrackColor: other.activeTrackColor ?? activeTrackColor,
      68            2 :       inactiveTrackColor: other.inactiveTrackColor ?? inactiveTrackColor,
      69            2 :       thumbColor: other.thumbColor ?? thumbColor,
      70            2 :       shadow: other.shadow ?? shadow,
      71            2 :       trackWidth: other.trackWidth ?? trackWidth,
      72            2 :       trackHeight: other.trackHeight ?? trackHeight,
      73            1 :       thumbSize: other.thumbSize ?? thumbSize,
      74              :     );
      75              :   }
      76              : }
        

Generated by: LCOV version 2.0-1