File tree Expand file tree Collapse file tree 3 files changed +61
-0
lines changed
Expand file tree Collapse file tree 3 files changed +61
-0
lines changed Original file line number Diff line number Diff line change @@ -237,6 +237,28 @@ class DashbookContext {
237237 );
238238 }
239239
240+ double sliderProperty (
241+ String name,
242+ double defaultValue, {
243+ String ? tooltipMessage,
244+ ControlProperty ? visibilityControlProperty,
245+ }) {
246+ return addProperty (
247+ Property <double >.withBuilder (
248+ name,
249+ defaultValue,
250+ tooltipMessage: tooltipMessage,
251+ visibilityControlProperty: visibilityControlProperty,
252+ builder: (property, onChanged, key) => p.SliderProperty (
253+ property: property,
254+ onChanged: onChanged,
255+ key: key,
256+ ),
257+ ),
258+ );
259+
260+ }
261+
240262 Color colorProperty (
241263 String name,
242264 Color defaultValue, {
Original file line number Diff line number Diff line change @@ -5,4 +5,5 @@ export 'edge_insets_property.dart';
55export 'list_property.dart' ;
66export 'number_property.dart' ;
77export 'options_property.dart' ;
8+ export 'slider_property.dart' ;
89export 'text_property.dart' ;
Original file line number Diff line number Diff line change 1+ import 'package:dashbook/dashbook.dart' ;
2+ import 'package:flutter/material.dart' ;
3+
4+ class SliderProperty extends StatefulWidget {
5+ final Property <double > property;
6+ final PropertyChanged onChanged;
7+
8+ const SliderProperty ({
9+ required this .property,
10+ required this .onChanged,
11+ super .key,
12+ });
13+
14+ @override
15+ State <StatefulWidget > createState () =>
16+ SliderPropertyState (property.getValue ());
17+ }
18+
19+ class SliderPropertyState extends State <SliderProperty > {
20+ double value;
21+ SliderPropertyState (this .value);
22+
23+ @override
24+ Widget build (BuildContext context) {
25+ return PropertyScaffold (
26+ tooltipMessage: widget.property.tooltipMessage,
27+ label: widget.property.name,
28+ child: Slider (
29+ value: value,
30+ onChanged: (newValue) {
31+ value = newValue;
32+ widget.property.value = newValue;
33+ widget.onChanged ();
34+ },
35+ ),
36+ );
37+ }
38+ }
You can’t perform that action at this time.
0 commit comments