59 lines
1.6 KiB
Dart
59 lines
1.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class LabeledSlider extends StatelessWidget {
|
|
final String label;
|
|
final double value;
|
|
final double min, max;
|
|
final int? divisions;
|
|
final String display;
|
|
final Color color;
|
|
final ValueChanged<double> onChanged;
|
|
const LabeledSlider({
|
|
required this.label,
|
|
required this.value,
|
|
required this.min,
|
|
required this.max,
|
|
required this.display,
|
|
required this.color,
|
|
required this.onChanged,
|
|
this.divisions,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) => Row(children: [
|
|
SizedBox(
|
|
width: 90,
|
|
child: Text(label,
|
|
style: TextStyle(fontSize: 13, color: Colors.grey.shade600)),
|
|
),
|
|
Expanded(
|
|
child: SliderTheme(
|
|
data: SliderTheme.of(context).copyWith(
|
|
activeTrackColor: color,
|
|
thumbColor: color,
|
|
overlayColor: color.withOpacity(0.15),
|
|
inactiveTrackColor: Colors.grey.shade200,
|
|
trackHeight: 3.0,
|
|
thumbShape: const RoundSliderThumbShape(enabledThumbRadius: 8),
|
|
),
|
|
child: Slider(
|
|
value: value.clamp(min, max),
|
|
min: min,
|
|
max: max,
|
|
divisions: divisions,
|
|
onChanged: onChanged,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
width: 48,
|
|
child: Text(display,
|
|
textAlign: TextAlign.right,
|
|
style: const TextStyle(
|
|
fontSize: 13,
|
|
fontWeight: FontWeight.w500,
|
|
fontFeatures: [FontFeature.tabularFigures()])),
|
|
),
|
|
]);
|
|
}
|