39 lines
940 B
Dart
39 lines
940 B
Dart
import 'package:flutter/material.dart';
|
|
|
|
double _currentSliderValue = 50;
|
|
|
|
class MySlider extends StatefulWidget {
|
|
final String _title;
|
|
const MySlider(this._title, {super.key});
|
|
|
|
@override
|
|
State<StatefulWidget> createState() => SliderState();
|
|
|
|
double getSliderValue() {
|
|
return _currentSliderValue;
|
|
}
|
|
}
|
|
|
|
class SliderState extends State<MySlider> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
children: [
|
|
Text(widget._title),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Slider(
|
|
value: _currentSliderValue,
|
|
max: 100,
|
|
label: _currentSliderValue.round().toString(),
|
|
onChanged: (double value) =>
|
|
{setState((() => _currentSliderValue = value))}),
|
|
Text(_currentSliderValue.round().toString())
|
|
],
|
|
)
|
|
],
|
|
);
|
|
}
|
|
}
|