-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsliders_page.dart
83 lines (78 loc) · 2.33 KB
/
sliders_page.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import 'package:example/helpers.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:platty/platty.dart';
class SlidersPage extends StatefulWidget {
@override
SlidersPageState createState() {
return new SlidersPageState();
}
}
class SlidersPageState extends State<SlidersPage> {
final List<double> values = [0.0, 0.0, 0.0];
_setValue(int index, {double value}) {
setState(() {
values[index] = value;
});
}
@override
Widget build(BuildContext context) {
return PScaffold(
backgroundColor: Colors.white,
appBar: navBarFor(title: "Sliders"),
child: Container(
color: Colors.white,
child: Column(
children: <Widget>[
_buildSlider(
title: "Platform Slider",
sliderBuilder: () => PSlider(
value: values[0],
activeColor: Colors.red,
onChanged: (value) {
_setValue(0, value: value);
},
)),
_buildSlider(
title: "IOS Slider",
sliderBuilder: () => PSlider(
value: values[1],
activeColor: Colors.red,
renderPlatform: TargetPlatform.iOS,
onChanged: (value) {
_setValue(1, value: value);
},
)),
_buildSlider(
title: "Android Slider",
sliderBuilder: () => PSlider(
value: values[2],
activeColor: Colors.red,
renderPlatform: TargetPlatform.android,
onChanged: (value) {
_setValue(2, value: value);
},
)),
],
),
),
);
}
Padding _buildSlider(
{@required String title,
@required Widget Function() sliderBuilder}) =>
Padding(
padding: EdgeInsets.all(8.0),
child: Row(
children: <Widget>[
Padding(
padding: EdgeInsets.all(8.0),
child: Text(title),
),
Expanded(
child: sliderBuilder(),
),
],
),
);
}