added reusable slider, used it in mood page

main
Julian Gegner 2023-02-15 14:30:40 +01:00
parent 40018431dd
commit 92333d7b2d
2 changed files with 29 additions and 1 deletions

View File

@ -1,10 +1,11 @@
import 'package:flutter/material.dart';
import 'package:smoke_cess_app/widgets/slider.dart';
class MoodPage extends StatelessWidget {
const MoodPage({super.key});
@override
Widget build(BuildContext context) {
return const Center(child: Text('Hier Fragen wir die Stimmung ab'));
return Column(children: const [MySlider(), Text('Freitext')]);
}
}

View File

@ -0,0 +1,27 @@
import 'package:flutter/material.dart';
class MySlider extends StatefulWidget {
const MySlider({super.key});
@override
State<StatefulWidget> createState() => SliderState();
}
class SliderState extends State<MySlider> {
double _currentSliderValue = 50;
@override
Widget build(BuildContext context) {
return Row(
children: [
Slider(
value: _currentSliderValue,
max: 100,
label: _currentSliderValue.round().toString(),
onChanged: (double value) =>
{setState((() => _currentSliderValue = value))}),
Text(_currentSliderValue.round().toString())
],
);
}
}