import 'package:flutter/material.dart';
class SimpleSliderScreen extends StatefulWidget {
@override
State<SimpleSliderScreen> createState() => _SimpleSliderScreenState();
}
class _SimpleSliderScreenState extends State<SimpleSliderScreen> {
double _sliderValue = 50;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Simple Slider Screen')),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text('Slider Value: ${_sliderValue.round()}', style: TextStyle(fontSize: 24)),
Slider(
min: 0,
max: 100,
value: _sliderValue,
onChanged: (newValue) {
setState(() {
_sliderValue = newValue;
});
},
),
],
),
),
);
}
}This screen uses a StatefulWidget to keep track of the slider's current value in _sliderValue. The Text widget above the slider shows the value rounded to the nearest whole number. The Slider widget has a range from 0 to 100 and updates _sliderValue inside its onChanged callback. Calling setState tells Flutter to redraw the UI with the new value, so the number updates as the slider moves.