LCOV - code coverage report
Current view: top level - components/otp_field - foss_otp_field_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_otp_field.dart';
       2              : 
       3              : /// Visual overrides for a [FossOtpField]. Every field is optional; a null field
       4              : /// falls back to the value the theme resolves for the size and state. Pass one
       5              : /// via `style:` to tweak a single field without retheming every other one.
       6              : ///
       7              : /// State-derived colors (the focus ring and error border) stay token-driven. To
       8              : /// restyle those globally, retheme `FossColors`.
       9              : ///
      10              : /// Wider slots with a custom resting border and no shadow:
      11              : ///
      12              : /// ```dart
      13              : /// FossOtpField(
      14              : ///   length: 6,
      15              : ///   style: const FossOtpFieldStyle(
      16              : ///     slotSize: 48,
      17              : ///     borderColor: Color(0xFFD4D4D4),
      18              : ///     shadow: [],
      19              : ///   ),
      20              : /// );
      21              : /// ```
      22              : @immutable
      23              : class FossOtpFieldStyle {
      24              :   /// Creates a set of slot overrides. All fields default to null (inherit).
      25            1 :   const FossOtpFieldStyle({
      26              :     this.backgroundColor,
      27              :     this.borderColor,
      28              :     this.borderRadius,
      29              :     this.slotSize,
      30              :     this.textStyle,
      31              :     this.gap,
      32              :     this.shadow,
      33              :     this.separatorColor,
      34              :     this.separatorSize,
      35              :   });
      36              : 
      37              :   /// Fill color of each slot.
      38              :   final Color? backgroundColor;
      39              : 
      40              :   /// Resting border color, used when the slot is neither active nor invalid.
      41              :   final Color? borderColor;
      42              : 
      43              :   /// Corner radius of each slot in logical pixels.
      44              :   final double? borderRadius;
      45              : 
      46              :   /// Edge length of each square slot in logical pixels, before text scaling.
      47              :   final double? slotSize;
      48              : 
      49              :   /// Style of the slot character. Its color is ignored; the character color
      50              :   /// stays token-driven.
      51              :   final TextStyle? textStyle;
      52              : 
      53              :   /// Gap between slots and around a group separator in logical pixels.
      54              :   final double? gap;
      55              : 
      56              :   /// Drop shadow layers at rest; empty for none.
      57              :   final List<BoxShadow>? shadow;
      58              : 
      59              :   /// Color of the group separator pill.
      60              :   final Color? separatorColor;
      61              : 
      62              :   /// Size of the group separator pill in logical pixels, before text scaling.
      63              :   final Size? separatorSize;
      64              : 
      65              :   /// Returns a copy with every non-null field of [other] laid over this one.
      66              :   ///
      67              :   /// ```dart
      68              :   /// const base = FossOtpFieldStyle(slotSize: 36, gap: 8);
      69              :   /// const override = FossOtpFieldStyle(slotSize: 44);
      70              :   /// base.merge(override); // slotSize 44, gap 8 kept
      71              :   /// ```
      72            1 :   FossOtpFieldStyle merge(FossOtpFieldStyle? other) {
      73              :     if (other == null) return this;
      74            1 :     return FossOtpFieldStyle(
      75            2 :       backgroundColor: other.backgroundColor ?? backgroundColor,
      76            2 :       borderColor: other.borderColor ?? borderColor,
      77            2 :       borderRadius: other.borderRadius ?? borderRadius,
      78            2 :       slotSize: other.slotSize ?? slotSize,
      79            2 :       textStyle: other.textStyle ?? textStyle,
      80            2 :       gap: other.gap ?? gap,
      81            2 :       shadow: other.shadow ?? shadow,
      82            2 :       separatorColor: other.separatorColor ?? separatorColor,
      83            2 :       separatorSize: other.separatorSize ?? separatorSize,
      84              :     );
      85              :   }
      86              : }
      87              : 
      88              : /// The fully resolved, non-null slot appearance for one size. A
      89              : /// [FossOtpFieldStyle] override is laid over it by [_apply], so the widget
      90              : /// reads only non-null fields and never needs the null-assertion operator.
      91              : @immutable
      92              : class _OtpVisuals {
      93            1 :   const _OtpVisuals({
      94              :     required this.background,
      95              :     required this.borderColor,
      96              :     required this.textColor,
      97              :     required this.borderRadius,
      98              :     required this.slotSize,
      99              :     required this.textStyle,
     100              :     required this.gap,
     101              :     required this.shadow,
     102              :     required this.separatorColor,
     103              :     required this.separatorSize,
     104              :   });
     105              : 
     106              :   final Color background;
     107              :   final Color borderColor;
     108              :   final Color textColor;
     109              :   final double borderRadius;
     110              :   final double slotSize;
     111              :   final TextStyle textStyle;
     112              :   final double gap;
     113              :   final List<BoxShadow> shadow;
     114              :   final Color separatorColor;
     115              :   final Size separatorSize;
     116              : }
        

Generated by: LCOV version 2.0-1