of method

SliderThemeData of (BuildContext context)

Returns the data from the closest SliderTheme instance that encloses the given context.

Defaults to the ambient ThemeData.sliderTheme if there is no SliderTheme in the given build context.

class Launch extends StatefulWidget {
  @override
  State createState() => LaunchState();
}

class LaunchState extends State<Launch> {
  double _rocketThrust;

  @override
  Widget build(BuildContext context) {
    return SliderTheme(
      data: SliderTheme.of(context).copyWith(activeTrackColor: const Color(0xff804040)),
      child: Slider(
        onChanged: (double value) { setState(() { _rocketThrust = value; }); },
        value: _rocketThrust,
      ),
    );
  }
}

See also:

  • SliderThemeData, which describes the actual configuration of a slider theme.

Implementation

static SliderThemeData of(BuildContext context) {
  final SliderTheme inheritedTheme = context.inheritFromWidgetOfExactType(SliderTheme);
  return inheritedTheme != null ? inheritedTheme.data : Theme.of(context).sliderTheme;
}