import 'package:flutter/material.dart'; import 'package:manager_app/constants.dart'; class SliderInputContainer extends StatefulWidget { final Color color; final String label; final double initialValue; final int min; final int max; final ValueChanged onChanged; const SliderInputContainer({ Key? key, this.color = kSecond, required this.label, required this.initialValue, required this.min, required this.max, required this.onChanged, }) : super(key: key); @override _SliderInputContainerState createState() => _SliderInputContainerState(); } class _SliderInputContainerState extends State { double? currentValue; @override void initState() { super.initState(); currentValue = widget.initialValue; } @override Widget build(BuildContext context) { return Container( child: Row( children: [ Align( alignment: AlignmentDirectional.centerStart, child: Text(widget.label, style: TextStyle(fontSize: 25, fontWeight: FontWeight.w300)) ), Padding( padding: const EdgeInsets.all(10.0), child: Slider( value: currentValue!, onChanged: (value) { setState(() => currentValue = value); widget.onChanged(value); }, divisions: widget.max - widget.min, min: widget.min.toDouble(), max: widget.max.toDouble(), label: "$currentValue", activeColor: widget.color, ), ), ], ), ); } }