-
Notifications
You must be signed in to change notification settings - Fork 1
/
slider.dart
67 lines (61 loc) · 1.78 KB
/
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
66
67
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:platty/src/widgets/material_patcher.dart';
import 'platform.dart';
/// A [PlatformAdaptingWidget] that renders a [Slider] on Android and [CupertinoSlider]
/// on iOS.
class PSlider extends PlatformAdaptingWidget {
final double value;
final ValueChanged<double> onChanged;
final ValueChanged<double> onChangeStart;
final ValueChanged<double> onChangeEnd;
final double min;
final double max;
final int divisions;
final Color activeColor;
/// See [Slider.activeColor]
final Color androidInActiveColor;
PSlider(
{Key key,
@required this.value,
@required this.onChanged,
this.onChangeEnd,
this.onChangeStart,
this.max = 1.0,
this.min = 0.0,
this.divisions,
this.activeColor,
this.androidInActiveColor,
TargetPlatform renderPlatform})
: super(key: key, renderPlatform: renderPlatform);
@override
get renderMaterial => (BuildContext context) {
return Slider(
value: value,
onChanged: onChanged,
onChangeEnd: onChangeEnd,
onChangeStart: onChangeStart,
max: max,
min: min,
divisions: divisions,
activeColor: activeColor,
inactiveColor: androidInActiveColor,
);
};
@override
get renderCupertino => (BuildContext context) {
return MaterialPatcher(
child: CupertinoSlider(
value: value,
onChanged: onChanged,
onChangeStart: onChangeStart,
onChangeEnd: onChangeEnd,
min: min,
max: max,
divisions: divisions,
activeColor: activeColor,
),
);
};
}