File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
docs/src/content/docs/components Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -60,4 +60,9 @@ A tooltip text that appears when hovering over the switch.
60
60
## Functions
61
61
62
62
### toggle()
63
- Toggles the switch state between checked and unchecked.
63
+ Toggles the switch state between checked and unchecked.
64
+
65
+ ## Callbacks
66
+
67
+ ### checked_state_changed(checked: bool)
68
+ The switch state changed.
Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ export component Switch {
17
17
property <bool > has_icon : (root .checked && root .on_icon.width > 0 && root .on_icon.height > 0 ) || (root .off_icon.width > 0 && root .off_icon.height > 0 );
18
18
property <color > foreground : root .checked ? MaterialPalette.on_primary_container : MaterialPalette.surface_container_highest;
19
19
20
+ callback checked_state_changed (checked : bool );
21
+
20
22
min_width : MaterialStyleMetrics.size_52 ;
21
23
min_height : MaterialStyleMetrics.size_32 ;
22
24
@@ -125,6 +127,10 @@ export component Switch {
125
127
root .checked = !root .checked;
126
128
}
127
129
130
+ changed checked => {
131
+ root .checked_state_changed (root .checked);
132
+ }
133
+
128
134
states [
129
135
disabled when !root .enabled : {
130
136
state_layer.display_background : false ;
You can’t perform that action at this time.
0 commit comments