SliderTheme(
data: SliderTheme.of(context).copyWith(
trackHeight: 3,
trackShape: const GradientRectSliderTrackShape(radius: 1.5),
thumbShape: const GradientSliderComponentShape(
rectWH: 14, overlayRectSpace: 4, overlayColor: Colours.black),
),
child: Slider(
value: 3,
inactiveColor: Color(0x55FFFFFF),
min: 1,
max: 10,
),
)

import 'package:flutter/material.dart';
class GradientRectSliderTrackShape extends SliderTrackShape
with BaseSliderTrackShape {
final double disabledThumbGapWidth;
final double radius;
final LinearGradient gradient;
const GradientRectSliderTrackShape(
{
this.disabledThumbGapWidth = 2.0,
this.radius = 0,
this.gradient = const LinearGradient(
colors: [Color(0xFFA2FFB7), Color(0xFF00FAED)])});
@override
Rect getPreferredRect({
required RenderBox parentBox,
Offset offset = Offset.zero,
required SliderThemeData sliderTheme,
bool isEnabled = false,
bool isDiscrete = false,
}) {
final double overlayWidth =
sliderTheme.overlayShape