fieldSliderTheme function

SliderThemeData fieldSliderTheme(
  1. BuildContext context,
  2. NyFieldColors colors, {
  3. Color? active,
  4. Color? inactive,
  5. Color? thumb,
})

The slider look form fields share: a 4 px track in colors, no tick marks, and an accent thumb in a ring of background, so it stands off the track.

Implementation

SliderThemeData fieldSliderTheme(
  BuildContext context,
  NyFieldColors colors, {
  Color? active,
  Color? inactive,
  Color? thumb,
}) {
  final Color background = Theme.of(context).scaffoldBackgroundColor;
  final Color accent = thumb ?? active ?? colors.accent;
  return SliderTheme.of(context).copyWith(
    trackHeight: 4,
    activeTrackColor: active ?? colors.accent,
    inactiveTrackColor: inactive ?? colors.track,
    activeTickMarkColor: Colors.transparent,
    inactiveTickMarkColor: Colors.transparent,
    disabledActiveTickMarkColor: Colors.transparent,
    disabledInactiveTickMarkColor: Colors.transparent,
    thumbColor: accent,
    overlayColor: accent.withValues(alpha: 0.16),
    overlayShape: const RoundSliderOverlayShape(overlayRadius: 16),
    // Both tracks run the field's full width, so they line up with each
    // other and with the label; a thumb at either end overhangs by half.
    trackShape: const _InsetTrack(),
    rangeTrackShape: const _InsetRangeTrack(),
    thumbShape: _RingThumb(background),
    rangeThumbShape: _RingRangeThumb(background),
  );
}