2023-02-26 14:59:37 +01:00
|
|
|
import 'package:provider/provider.dart';
|
2023-02-15 14:30:40 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2023-02-26 14:59:37 +01:00
|
|
|
import 'package:smoke_cess_app/providers/input_provider.dart';
|
2023-02-15 14:30:40 +01:00
|
|
|
|
2023-02-26 14:59:37 +01:00
|
|
|
class MySlider extends StatelessWidget {
|
2023-02-26 17:07:38 +01:00
|
|
|
const MySlider({super.key});
|
2023-02-15 14:30:40 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-02-26 17:07:38 +01:00
|
|
|
InputProvider inputModel = context.watch<InputProvider>();
|
2023-02-21 13:39:06 +01:00
|
|
|
return Center(
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
2023-02-26 11:30:24 +01:00
|
|
|
const SizedBox(height: 16),
|
2023-02-26 14:59:37 +01:00
|
|
|
Text('${inputModel.sliderValue.toInt()}',
|
2023-02-26 11:30:24 +01:00
|
|
|
style: const TextStyle(fontSize: 22)),
|
2023-02-21 13:39:06 +01:00
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
2023-02-26 11:30:24 +01:00
|
|
|
IconButton(
|
|
|
|
icon: const Icon(Icons.remove_outlined),
|
|
|
|
onPressed: () {
|
2023-02-26 14:59:37 +01:00
|
|
|
inputModel.sliderValue -= 1;
|
2023-02-26 11:30:24 +01:00
|
|
|
},
|
|
|
|
),
|
2023-02-21 13:39:06 +01:00
|
|
|
Expanded(
|
|
|
|
child: Slider(
|
2023-02-26 14:59:37 +01:00
|
|
|
value: inputModel.sliderValue,
|
2023-02-26 11:30:24 +01:00
|
|
|
min: 0,
|
2023-02-21 00:20:43 +01:00
|
|
|
max: 100,
|
2023-02-26 11:30:24 +01:00
|
|
|
divisions: 100,
|
2023-02-26 14:59:37 +01:00
|
|
|
label: '${inputModel.sliderValue.toInt()}',
|
2023-02-21 00:20:43 +01:00
|
|
|
onChanged: (double value) {
|
2023-02-26 14:59:37 +01:00
|
|
|
inputModel.sliderValue = value;
|
2023-02-21 13:39:06 +01:00
|
|
|
},
|
2023-02-21 00:20:43 +01:00
|
|
|
),
|
2023-02-21 13:39:06 +01:00
|
|
|
),
|
2023-02-26 11:30:24 +01:00
|
|
|
IconButton(
|
|
|
|
icon: const Icon(Icons.add_outlined),
|
|
|
|
onPressed: () {
|
2023-02-26 14:59:37 +01:00
|
|
|
inputModel.sliderValue += 1;
|
2023-02-26 11:30:24 +01:00
|
|
|
},
|
2023-02-21 00:20:43 +01:00
|
|
|
),
|
2023-02-21 13:39:06 +01:00
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2023-02-15 14:30:40 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|