-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy path40.flutter_double_slider.dart
65 lines (58 loc) · 2.14 KB
/
40.flutter_double_slider.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import 'package:flutter/material.dart';
import 'package:ig_posts/season_2/63.transperant_design_pattern.dart';
import 'package:ig_posts/utils/colors.dart';
import 'package:provider/provider.dart';
class DoubleSliderNotifier extends ChangeNotifier {
RangeValues rangeValues = RangeValues(0, 1);
void setSliderValue({required RangeValues value}) {
rangeValues = value;
notifyListeners();
debugPrint(rangeValues.toString());
}
String renderEmoji() {
if (rangeValues.start >= 0 && rangeValues.end <= 0.2) {
return "🔥";
} else if (rangeValues.start >= 0.2 && rangeValues.end <= 0.4) {
return "👀";
} else if (rangeValues.start >= 0.4 && rangeValues.end <= 0.6) {
return "👋🏻";
} else if (rangeValues.start >= 0.6 && rangeValues.end <= 0.8) {
return "✅";
} else if (rangeValues.start >= 0.8 && rangeValues.end <= 1) {
return "🍕";
}
return "🔗";
}
}
class FlutterDoubleSliderView extends StatelessWidget {
const FlutterDoubleSliderView({super.key});
@override
Widget build(BuildContext context) {
DoubleSliderNotifier doubleSliderNotifier({required bool renderUI}) =>
Provider.of<DoubleSliderNotifier>(context, listen: renderUI);
return Scaffold(
backgroundColor: KConstantColors.bgColor,
appBar: CustomAppBar(title: "Double slider"),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text("Rate your experience in a partition",
style: KConstantTextstyles.light(fontSize: 16)),
SizedBox(height: 25),
RangeSlider(
activeColor: KConstantColors.whiteColor,
divisions: 5,
values: doubleSliderNotifier(renderUI: true).rangeValues,
onChanged: (val) {
doubleSliderNotifier(renderUI: false)
.setSliderValue(value: val);
}),
SizedBox(height: 30),
Text(doubleSliderNotifier(renderUI: true).renderEmoji(),
style: KConstantTextstyles.bold(fontSize: 75))
],
),
);
}
}