Skip to main content

waft_material/
checkbox_theme.rs

1//! Flutter counterpart: material_ui's `checkbox_theme.dart`.
2
3use waft_embedder::{Color, lerp_double};
4use waft_foundation::{App, DiagnosticsProperty, DoubleProperty};
5use waft_painting::{AnyBorderSide, BorderSide, EdgeInsets, OutlinedBorderRef};
6use waft_services::MouseCursorRef;
7use waft_widgets::{
8    BuildContext, InheritedWidget, IntoWidget, KeyRef, WidgetRef, WidgetStateBorderSide,
9    WidgetStateProperty, WidgetStatePropertyRef, WidgetStates,
10};
11
12use crate::theme::Theme;
13use crate::theme_data::{MaterialTapTargetSize, VisualDensity};
14
15/// Defines default property values for descendant `Checkbox` widgets.
16///
17/// Descendant widgets obtain the current [`CheckboxThemeData`] object using
18/// [`CheckboxTheme::of`]. Instances of [`CheckboxThemeData`] can be
19/// customized with [`CheckboxThemeData::copy_with`].
20///
21/// Typically a [`CheckboxThemeData`] is specified as part of the overall `Theme`
22/// with `ThemeData::checkbox_theme`.
23///
24/// All [`CheckboxThemeData`] properties are `None` by default. When null, the
25/// `Checkbox` will use the values from `ThemeData` if they exist, otherwise it
26/// will provide its own defaults based on the overall `Theme`'s color_scheme.
27/// See the individual `Checkbox` properties for details.
28///
29/// See also:
30///
31///  * `ThemeData`, which describes the overall theme information for the
32///    application.
33#[derive(Clone, Debug, Default)]
34pub struct CheckboxThemeData {
35    /// The cursor for a mouse pointer when it enters or is hovering over the
36    /// widget.
37    ///
38    /// If `mouse_cursor` is a `WidgetStateMouseCursor`,
39    /// [`WidgetStateProperty::resolve`] is used for the following `WidgetState`s:
40    ///
41    ///  * `WidgetState::Selected`.
42    ///  * `WidgetState::Focused`.
43    ///  * `WidgetState::Disabled`.
44    ///
45    /// If specified, overrides the default value of `Checkbox::mouse_cursor`.
46    pub mouse_cursor: Option<WidgetStatePropertyRef<Option<MouseCursorRef>>>,
47
48    /// The color that fills the checkbox, in all `WidgetState`s.
49    ///
50    /// Resolves in the following states:
51    ///  * `WidgetState::Selected`.
52    ///  * `WidgetState::Hovered`.
53    ///  * `WidgetState::Focused`.
54    ///  * `WidgetState::Disabled`.
55    ///
56    /// If specified, overrides the default value of `Checkbox::fill_color`.
57    pub fill_color: Option<WidgetStatePropertyRef<Option<Color>>>,
58
59    /// The color to use for the check icon when this checkbox is checked.
60    ///
61    /// Resolves in the following states:
62    ///  * `WidgetState::Selected`.
63    ///  * `WidgetState::Hovered`.
64    ///  * `WidgetState::Focused`.
65    ///  * `WidgetState::Disabled`.
66    ///
67    /// If specified, overrides the default value of `Checkbox::check_color`.
68    pub check_color: Option<WidgetStatePropertyRef<Option<Color>>>,
69
70    /// The color for the checkbox's `Material`.
71    ///
72    /// Resolves in the following states:
73    ///  * `WidgetState::Pressed`.
74    ///  * `WidgetState::Selected`.
75    ///  * `WidgetState::Hovered`.
76    ///  * `WidgetState::Focused`.
77    ///
78    /// If specified, overrides the default value of `Checkbox::overlay_color`.
79    pub overlay_color: Option<WidgetStatePropertyRef<Option<Color>>>,
80
81    /// The splash radius of the circular `Material` ink response.
82    ///
83    /// If specified, overrides the default value of `Checkbox::splash_radius`.
84    pub splash_radius: Option<f64>,
85
86    /// Configures the minimum size of the tap target.
87    ///
88    /// If specified, overrides the default value of
89    /// `Checkbox::material_tap_target_size`.
90    pub material_tap_target_size: Option<MaterialTapTargetSize>,
91
92    /// Defines how compact the checkbox's layout will be.
93    ///
94    /// If specified, overrides the default value of `Checkbox::visual_density`.
95    pub visual_density: Option<VisualDensity>,
96
97    /// The shape of the checkbox's `Material`.
98    ///
99    /// If specified, overrides the default value of `Checkbox::shape`.
100    pub shape: Option<OutlinedBorderRef>,
101
102    /// The color and width of the checkbox's border.
103    ///
104    /// This property can be a [`WidgetStateBorderSide`] that can
105    /// specify different border color and widths depending on the
106    /// checkbox's state.
107    ///
108    /// Resolves in the following states:
109    ///  * `WidgetState::Pressed`.
110    ///  * `WidgetState::Selected`.
111    ///  * `WidgetState::Hovered`.
112    ///  * `WidgetState::Focused`.
113    ///  * `WidgetState::Disabled`.
114    ///  * `WidgetState::Error`.
115    ///
116    /// If this property is not a [`WidgetStateBorderSide`] and it is
117    /// non-null, then it is only rendered when the checkbox's value is
118    /// false. The difference in interpretation is for backwards
119    /// compatibility.
120    ///
121    /// If specified, overrides the default value of `Checkbox::side`.
122    pub side: Option<AnyBorderSide>,
123
124    /// The insets applied around the check mark when the checkbox is checked or
125    /// in its indeterminate (tristate) state.
126    ///
127    /// This insets the check mark inward; the size of the checkbox box itself
128    /// is not affected. The check mark and its stroke shrink to fit the
129    /// remaining space, so the mark stays proportional. Its size is the smaller
130    /// of the remaining width and height, and it is centered in the remaining
131    /// space, so an inset on one axis also shrinks it on the other. For example,
132    /// `EdgeInsets::only(9.0, 0.0, 0.0, 0.0)` draws a half-size mark centered in the right
133    /// half of the box.
134    ///
135    /// On iOS and macOS, when using `Checkbox::adaptive`, this property has no
136    /// effect, because the checkbox delegates to `CupertinoCheckbox`, which does
137    /// not support insets.
138    ///
139    /// Must be non-negative. If the horizontal or vertical insets are
140    /// greater than or equal to the checkbox size, the check mark or indeterminate
141    /// dash is not painted.
142    ///
143    /// If null, [`CheckboxThemeData::mark_insets`] is used. If that is also null,
144    /// it defaults to [`EdgeInsets::ZERO`] and the check mark renders at full size.
145    pub mark_insets: Option<EdgeInsets>,
146}
147
148crate::theme_data_getters::theme_data_getters! {
149    /// Dart's getters of `CheckboxThemeData`: the theme data answers with its fields, and a defaults
150    /// subclass (Dart's `_...Defaults...(context)`) computes the ones it overrides when they
151    /// are read.
152    pub trait CheckboxThemeDataGetters for CheckboxThemeData, fields: checkbox_theme_data {
153        mouse_cursor: Option<WidgetStatePropertyRef<Option<MouseCursorRef>>>,
154        fill_color: Option<WidgetStatePropertyRef<Option<Color>>>,
155        check_color: Option<WidgetStatePropertyRef<Option<Color>>>,
156        overlay_color: Option<WidgetStatePropertyRef<Option<Color>>>,
157        splash_radius: Option<f64>,
158        material_tap_target_size: Option<MaterialTapTargetSize>,
159        visual_density: Option<VisualDensity>,
160        shape: Option<OutlinedBorderRef>,
161        side: Option<AnyBorderSide>,
162        mark_insets: Option<EdgeInsets>,
163    }
164}
165
166impl CheckboxThemeData {
167    /// Creates a theme that can be used for `ThemeData::checkbox_theme`; Dart's optional
168    /// named arguments are the fluent setters.
169    pub fn new() -> CheckboxThemeData {
170        CheckboxThemeData::default()
171    }
172
173    /// Dart `CheckboxThemeData(mouseCursor:)`.
174    pub fn mouse_cursor(
175        mut self,
176        mouse_cursor: WidgetStatePropertyRef<Option<MouseCursorRef>>,
177    ) -> CheckboxThemeData {
178        self.mouse_cursor = Some(mouse_cursor);
179        self
180    }
181
182    /// Dart `CheckboxThemeData(fillColor:)`.
183    pub fn fill_color(
184        mut self,
185        fill_color: WidgetStatePropertyRef<Option<Color>>,
186    ) -> CheckboxThemeData {
187        self.fill_color = Some(fill_color);
188        self
189    }
190
191    /// Dart `CheckboxThemeData(checkColor:)`.
192    pub fn check_color(
193        mut self,
194        check_color: WidgetStatePropertyRef<Option<Color>>,
195    ) -> CheckboxThemeData {
196        self.check_color = Some(check_color);
197        self
198    }
199
200    /// Dart `CheckboxThemeData(overlayColor:)`.
201    pub fn overlay_color(
202        mut self,
203        overlay_color: WidgetStatePropertyRef<Option<Color>>,
204    ) -> CheckboxThemeData {
205        self.overlay_color = Some(overlay_color);
206        self
207    }
208
209    /// Dart `CheckboxThemeData(splashRadius:)`.
210    pub fn splash_radius(mut self, splash_radius: f64) -> CheckboxThemeData {
211        self.splash_radius = Some(splash_radius);
212        self
213    }
214
215    /// Dart `CheckboxThemeData(materialTapTargetSize:)`.
216    pub fn material_tap_target_size(
217        mut self,
218        material_tap_target_size: MaterialTapTargetSize,
219    ) -> CheckboxThemeData {
220        self.material_tap_target_size = Some(material_tap_target_size);
221        self
222    }
223
224    /// Dart `CheckboxThemeData(visualDensity:)`.
225    pub fn visual_density(mut self, visual_density: VisualDensity) -> CheckboxThemeData {
226        self.visual_density = Some(visual_density);
227        self
228    }
229
230    /// Dart `CheckboxThemeData(shape:)`.
231    pub fn shape(mut self, shape: impl Into<OutlinedBorderRef>) -> CheckboxThemeData {
232        self.shape = Some(shape.into());
233        self
234    }
235
236    /// Dart `CheckboxThemeData(side:)`.
237    pub fn side(mut self, side: impl Into<AnyBorderSide>) -> CheckboxThemeData {
238        self.side = Some(side.into());
239        self
240    }
241
242    /// Dart `CheckboxThemeData(markInsets:)`.
243    pub fn mark_insets(mut self, mark_insets: EdgeInsets) -> CheckboxThemeData {
244        self.mark_insets = Some(mark_insets);
245        self
246    }
247
248    /// Creates a copy of this object but with the given fields replaced with the
249    /// new values.
250    ///
251    /// Dart's named arguments are the fluent setters on the copy
252    /// (`data.copy_with().splash_radius(4.0)`).
253    pub fn copy_with(&self) -> CheckboxThemeData {
254        self.clone()
255    }
256
257    /// Linearly interpolate between two [`CheckboxThemeData`]s.
258    ///
259    /// {@macro dart.ui.shadow.lerp}
260    pub fn lerp(
261        a: Option<&CheckboxThemeData>,
262        b: Option<&CheckboxThemeData>,
263        t: f64,
264    ) -> CheckboxThemeData {
265        if let (Some(a), Some(b)) = (a, b)
266            && std::ptr::eq(a, b)
267        {
268            return a.clone();
269        }
270        CheckboxThemeData {
271            mouse_cursor: if t < 0.5 {
272                a.and_then(|a| a.mouse_cursor.clone())
273            } else {
274                b.and_then(|b| b.mouse_cursor.clone())
275            },
276            fill_color: <dyn WidgetStateProperty<Option<Color>>>::lerp_optional(
277                a.and_then(|a| a.fill_color.clone()),
278                b.and_then(|b| b.fill_color.clone()),
279                t,
280                Color::lerp,
281            ),
282            check_color: <dyn WidgetStateProperty<Option<Color>>>::lerp_optional(
283                a.and_then(|a| a.check_color.clone()),
284                b.and_then(|b| b.check_color.clone()),
285                t,
286                Color::lerp,
287            ),
288            overlay_color: <dyn WidgetStateProperty<Option<Color>>>::lerp_optional(
289                a.and_then(|a| a.overlay_color.clone()),
290                b.and_then(|b| b.overlay_color.clone()),
291                t,
292                Color::lerp,
293            ),
294            splash_radius: lerp_double(
295                a.and_then(|a| a.splash_radius),
296                b.and_then(|b| b.splash_radius),
297                t,
298            ),
299            material_tap_target_size: if t < 0.5 {
300                a.and_then(|a| a.material_tap_target_size)
301            } else {
302                b.and_then(|b| b.material_tap_target_size)
303            },
304            visual_density: if t < 0.5 {
305                a.and_then(|a| a.visual_density)
306            } else {
307                b.and_then(|b| b.visual_density)
308            },
309            shape: OutlinedBorderRef::lerp(
310                a.and_then(|a| a.shape.as_ref()),
311                b.and_then(|b| b.shape.as_ref()),
312                t,
313            ),
314            side: Self::lerp_sides(
315                a.and_then(|a| a.side.as_ref()),
316                b.and_then(|b| b.side.as_ref()),
317                t,
318            )
319            .map(AnyBorderSide::new),
320            mark_insets: EdgeInsets::lerp(
321                a.and_then(|a| a.mark_insets),
322                b.and_then(|b| b.mark_insets),
323                t,
324            ),
325        }
326    }
327
328    // Special case because BorderSide.lerp() doesn't support null arguments
329    fn lerp_sides(
330        a: Option<&AnyBorderSide>,
331        b: Option<&AnyBorderSide>,
332        t: f64,
333    ) -> Option<BorderSide> {
334        if a.is_none() && b.is_none() {
335            return None;
336        }
337        let a = a.and_then(Self::resolve_unconditionally);
338        let b = b.and_then(Self::resolve_unconditionally);
339        let a = a.unwrap_or_else(|| BorderSide {
340            width: 0.0,
341            color: b.expect("b! in Dart").color.with_alpha(0),
342            ..BorderSide::default()
343        });
344        let b = b.unwrap_or_else(|| BorderSide {
345            width: 0.0,
346            color: a.color.with_alpha(0),
347            ..BorderSide::default()
348        });
349
350        Some(BorderSide::lerp(a, b, t))
351    }
352
353    /// Dart's `if (a is WidgetStateBorderSide) { a = a.resolve(const <WidgetState>{}); }`.
354    fn resolve_unconditionally(side: &AnyBorderSide) -> Option<BorderSide> {
355        match side.extension::<WidgetStateBorderSide>() {
356            Some(side) => side.resolve(&WidgetStates::new()),
357            None => Some(**side),
358        }
359    }
360}
361
362impl PartialEq for CheckboxThemeData {
363    fn eq(&self, other: &CheckboxThemeData) -> bool {
364        if std::ptr::eq(self, other) {
365            return true;
366        }
367        other.mouse_cursor == self.mouse_cursor
368            && other.fill_color == self.fill_color
369            && other.check_color == self.check_color
370            && other.overlay_color == self.overlay_color
371            && other.splash_radius == self.splash_radius
372            && other.material_tap_target_size == self.material_tap_target_size
373            && other.visual_density == self.visual_density
374            && other.shape == self.shape
375            && other.side == self.side
376            && other.mark_insets == self.mark_insets
377    }
378}
379
380/// Applies a checkbox theme to descendant `Checkbox` widgets.
381///
382/// Descendant widgets obtain the current theme's [`CheckboxTheme`] object using
383/// [`CheckboxTheme::of`]. When a widget uses [`CheckboxTheme::of`], it is
384/// automatically rebuilt if the theme later changes.
385///
386/// A checkbox theme can be specified as part of the overall Material theme
387/// using `ThemeData::checkbox_theme`.
388///
389/// See also:
390///
391///  * [`CheckboxThemeData`], which describes the actual configuration of a
392///    checkbox theme.
393#[derive(Debug)]
394pub struct CheckboxTheme {
395    pub key: Option<KeyRef>,
396    /// The properties used for all descendant `Checkbox` widgets.
397    pub data: CheckboxThemeData,
398    pub child: WidgetRef,
399}
400
401impl CheckboxTheme {
402    /// Constructs a checkbox theme that configures all descendant `Checkbox`
403    /// widgets.
404    #[cfg_attr(debug_assertions, track_caller)]
405    pub fn new<K>(data: CheckboxThemeData, child: impl IntoWidget<K>) -> CheckboxTheme {
406        CheckboxTheme {
407            key: None,
408            data,
409            child: child.into_widget(),
410        }
411    }
412
413    /// Dart `CheckboxTheme(key:)`.
414    pub fn key(mut self, key: KeyRef) -> CheckboxTheme {
415        self.key = Some(key);
416        self
417    }
418
419    /// Returns the configuration [`data`](Self::data) from the closest [`CheckboxTheme`]
420    /// ancestor. If there is no ancestor, it returns `ThemeData::checkbox_theme`.
421    ///
422    /// Typical usage is as follows:
423    ///
424    /// ```text
425    /// let theme = CheckboxTheme::of(app, context);
426    /// ```
427    pub fn of(app: &mut App, context: BuildContext) -> CheckboxThemeData {
428        match context.depend_on_inherited_widget_of_exact_type::<CheckboxTheme>(app) {
429            Some(checkbox_theme) => checkbox_theme.data.clone(),
430            None => Theme::of(app, context).checkbox_theme.clone(),
431        }
432    }
433}
434
435impl InheritedWidget for CheckboxTheme {
436    fn key(&self) -> Option<&KeyRef> {
437        self.key.as_ref()
438    }
439
440    fn child(&self) -> &WidgetRef {
441        &self.child
442    }
443
444    fn update_should_notify(&self, old_widget: &CheckboxTheme) -> bool {
445        self.data != old_widget.data
446    }
447}
448
449impl waft_foundation::Diagnosticable for CheckboxThemeData {
450    fn debug_fill_properties(&self, properties: &mut waft_foundation::DiagnosticPropertiesBuilder) {
451        properties.add(
452            DiagnosticsProperty::<String>::new(
453                "mouseCursor",
454                self.mouse_cursor
455                    .as_deref()
456                    .map(|property| property.to_string()),
457            )
458            .default_value(None),
459        );
460        properties.add(
461            DiagnosticsProperty::<String>::new(
462                "fillColor",
463                self.fill_color
464                    .as_deref()
465                    .map(|property| property.to_string()),
466            )
467            .default_value(None),
468        );
469        properties.add(
470            DiagnosticsProperty::<String>::new(
471                "checkColor",
472                self.check_color
473                    .as_deref()
474                    .map(|property| property.to_string()),
475            )
476            .default_value(None),
477        );
478        properties.add(
479            DiagnosticsProperty::<String>::new(
480                "overlayColor",
481                self.overlay_color
482                    .as_deref()
483                    .map(|property| property.to_string()),
484            )
485            .default_value(None),
486        );
487        properties.add(DoubleProperty::new("splashRadius", self.splash_radius).default_value(None));
488        properties.add(
489            DiagnosticsProperty::<waft_foundation::DartEnum<MaterialTapTargetSize>>::new(
490                "materialTapTargetSize",
491                self.material_tap_target_size.map(waft_foundation::DartEnum),
492            )
493            .default_value(None),
494        );
495        properties.add(
496            DiagnosticsProperty::<VisualDensity>::new("visualDensity", self.visual_density)
497                .default_value(None),
498        );
499        properties.add(
500            DiagnosticsProperty::<OutlinedBorderRef>::new("shape", self.shape.clone())
501                .default_value(None),
502        );
503        properties.add(
504            DiagnosticsProperty::<AnyBorderSide>::new("side", self.side.clone())
505                .default_value(None),
506        );
507    }
508}
509
510impl std::fmt::Display for CheckboxThemeData {
511    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
512        f.write_str(&waft_foundation::Diagnosticable::to_string(self))
513    }
514}
515
516#[cfg(test)]
517mod tests {
518    use std::cell::Cell;
519    use std::rc::Rc;
520
521    use waft_embedder::{Offset, PointerChange, Radius, Size};
522    use waft_painting::{BorderRadiusGeometry, RoundedRectangleBorder};
523    use waft_services::SystemMouseCursors;
524    use waft_widgets::{FocusHighlightStrategy, SizedBox, WidgetState, WidgetStatePropertyAll};
525
526    use waft_rendering::testing::PaintCall;
527    use waft_widgets::testing::{TestPointer, WidgetTester, test_widgets};
528
529    use super::*;
530    use crate::checkbox::Checkbox;
531    use crate::checkbox::tests::{assert_paints, checkbox_center, checkbox_size, ignore, press};
532    use crate::color_scheme::ColorScheme;
533    use crate::colors::Colors;
534    use crate::scaffold::Scaffold;
535    use crate::test_support::{is_same_color_as, material_app};
536    use crate::theme_data::ThemeData;
537    use waft_painting::ShapeBorder;
538
539    #[test]
540    fn checkbox_theme_data_copy_with_equality_basics() {
541        assert_eq!(
542            CheckboxThemeData::new(),
543            CheckboxThemeData::new().copy_with()
544        );
545        assert_eq!(
546            CheckboxThemeData::new()
547                .copy_with()
548                .mark_insets(EdgeInsets::all(2.0)),
549            CheckboxThemeData::new().mark_insets(EdgeInsets::all(2.0))
550        );
551        assert_ne!(
552            CheckboxThemeData::new().mark_insets(EdgeInsets::all(2.0)),
553            CheckboxThemeData::new().mark_insets(EdgeInsets::all(3.0))
554        );
555    }
556
557    #[test]
558    fn checkbox_theme_data_lerp_special_cases() {
559        assert_eq!(
560            CheckboxThemeData::lerp(None, None, 0.0),
561            CheckboxThemeData::new()
562        );
563        let data = CheckboxThemeData::new();
564        // Dart's `identical`: the value comes back as it was.
565        assert_eq!(CheckboxThemeData::lerp(Some(&data), Some(&data), 0.5), data);
566    }
567
568    #[test]
569    fn checkbox_theme_data_defaults() {
570        let theme_data = CheckboxThemeData::new();
571        assert!(theme_data.mouse_cursor.is_none());
572        assert!(theme_data.fill_color.is_none());
573        assert!(theme_data.check_color.is_none());
574        assert!(theme_data.overlay_color.is_none());
575        assert_eq!(theme_data.splash_radius, None);
576        assert_eq!(theme_data.material_tap_target_size, None);
577        assert_eq!(theme_data.visual_density, None);
578
579        let theme = CheckboxTheme::new(CheckboxThemeData::new(), SizedBox::shrink());
580        assert!(theme.data.mouse_cursor.is_none());
581        assert!(theme.data.fill_color.is_none());
582        assert!(theme.data.check_color.is_none());
583        assert!(theme.data.overlay_color.is_none());
584        assert_eq!(theme.data.splash_radius, None);
585        assert_eq!(theme.data.material_tap_target_size, None);
586        assert_eq!(theme.data.visual_density, None);
587    }
588
589    /// `tester.pumpWidget(MaterialApp(theme: ThemeData(checkboxTheme:), home:
590    /// Scaffold(body: checkbox)))`.
591    fn pump_themed(tester: &mut WidgetTester, checkbox_theme: CheckboxThemeData, body: WidgetRef) {
592        let root = {
593            let app = tester.cell.borrow();
594            material_app(
595                ThemeData::builder()
596                    .checkbox_theme(checkbox_theme)
597                    .build(&app),
598                Scaffold::new().body(body).into_widget(),
599            )
600        };
601        tester.pump_widget(root);
602    }
603
604    /// Dart's `_pointGestureToCheckbox`.
605    fn point_gesture_to_checkbox(tester: &mut WidgetTester) -> TestPointer {
606        let center = checkbox_center(tester);
607        let mut gesture = TestPointer::mouse(1, 0);
608        tester.add_pointer(&mut gesture, Offset::ZERO);
609        tester.move_to(&mut gesture, center, false);
610        gesture
611    }
612
613    fn color_property(
614        resolve: impl Fn(&WidgetStates) -> Option<Color> + 'static,
615    ) -> WidgetStatePropertyRef<Option<Color>> {
616        <dyn WidgetStateProperty<Option<Color>>>::resolve_with(resolve)
617    }
618
619    fn all_colors(color: Color) -> WidgetStatePropertyRef<Option<Color>> {
620        <dyn WidgetStateProperty<Option<Color>>>::all(Some(color))
621    }
622
623    fn all_cursors(cursor: MouseCursorRef) -> WidgetStatePropertyRef<Option<MouseCursorRef>> {
624        <dyn WidgetStateProperty<Option<MouseCursorRef>>>::all(Some(cursor))
625    }
626
627    #[test]
628    fn checkbox_is_themeable() {
629        test_widgets(|tester| {
630            tester.set_highlight_strategy(FocusHighlightStrategy::AlwaysTraditional);
631
632            const DEFAULT_FILL_COLOR: Color = Color::new(0xfffffff0);
633            const SELECTED_FILL_COLOR: Color = Color::new(0xfffffff1);
634            const DEFAULT_CHECK_COLOR: Color = Color::new(0xfffffff2);
635            const FOCUSED_CHECK_COLOR: Color = Color::new(0xfffffff3);
636            const FOCUS_OVERLAY_COLOR: Color = Color::new(0xfffffff4);
637            const HOVER_OVERLAY_COLOR: Color = Color::new(0xfffffff5);
638            const SPLASH_RADIUS: f64 = 1.0;
639            const MATERIAL_TAP_TARGET_SIZE: MaterialTapTargetSize =
640                MaterialTapTargetSize::ShrinkWrap;
641            const VISUAL_DENSITY: VisualDensity = VisualDensity::new(1.0, 1.0);
642
643            let checkbox_theme = CheckboxThemeData::new()
644                .mouse_cursor(all_cursors(SystemMouseCursors::TEXT.into()))
645                .fill_color(color_property(|states| {
646                    if states.contains(&WidgetState::Selected) {
647                        return Some(SELECTED_FILL_COLOR);
648                    }
649                    Some(DEFAULT_FILL_COLOR)
650                }))
651                .check_color(color_property(|states| {
652                    if states.contains(&WidgetState::Focused) {
653                        return Some(FOCUSED_CHECK_COLOR);
654                    }
655                    Some(DEFAULT_CHECK_COLOR)
656                }))
657                .overlay_color(color_property(|states| {
658                    if states.contains(&WidgetState::Focused) {
659                        return Some(FOCUS_OVERLAY_COLOR);
660                    }
661                    if states.contains(&WidgetState::Hovered) {
662                        return Some(HOVER_OVERLAY_COLOR);
663                    }
664                    None
665                }))
666                .splash_radius(SPLASH_RADIUS)
667                .material_tap_target_size(MATERIAL_TAP_TARGET_SIZE)
668                .visual_density(VISUAL_DENSITY);
669            let frame = |tester: &mut WidgetTester, selected: bool, autofocus: bool| {
670                pump_themed(
671                    tester,
672                    checkbox_theme.clone(),
673                    Checkbox::new(Some(selected), ignore())
674                        .autofocus(autofocus)
675                        .into_widget(),
676                );
677                tester.pump_and_settle();
678            };
679
680            // Checkbox.
681            frame(tester, false, false);
682            assert_paints(tester, &[PaintCall::rrect(Some(DEFAULT_FILL_COLOR))]);
683            // Size from MaterialTapTargetSize.shrinkWrap with added VisualDensity.
684            assert_eq!(
685                checkbox_size(tester),
686                Size::new(40.0, 40.0) + VISUAL_DENSITY.base_size_adjustment()
687            );
688
689            // Selected checkbox.
690            frame(tester, true, false);
691            assert_paints(tester, &[PaintCall::rrect(Some(SELECTED_FILL_COLOR))]);
692            assert_paints(
693                tester,
694                &[
695                    PaintCall::rrect(Some(SELECTED_FILL_COLOR)),
696                    PaintCall::path(Some(DEFAULT_CHECK_COLOR)),
697                ],
698            );
699
700            // Checkbox with hover.
701            frame(tester, false, false);
702            let gesture = point_gesture_to_checkbox(tester);
703            tester.pump_and_settle();
704            assert_eq!(tester.active_cursor(1), SystemMouseCursors::TEXT.into());
705            assert_paints(tester, &[PaintCall::circle(Some(HOVER_OVERLAY_COLOR))]);
706
707            // Checkbox with focus.
708            frame(tester, true, true);
709            assert_paints(
710                tester,
711                &[PaintCall::Circle {
712                    x: None,
713                    y: None,
714                    radius: Some(SPLASH_RADIUS),
715                    color: Some(FOCUS_OVERLAY_COLOR),
716                    style: None,
717                }],
718            );
719            assert_paints(
720                tester,
721                &[
722                    PaintCall::rrect(Some(SELECTED_FILL_COLOR)),
723                    PaintCall::path(Some(FOCUSED_CHECK_COLOR)),
724                ],
725            );
726            tester.send(&gesture, PointerChange::Remove);
727        });
728    }
729
730    #[test]
731    fn checkbox_properties_are_taken_over_the_theme_values() {
732        test_widgets(|tester| {
733            tester.set_highlight_strategy(FocusHighlightStrategy::AlwaysTraditional);
734
735            const THEME_DEFAULT_FILL_COLOR: Color = Color::new(0xfffffff0);
736            const THEME_SELECTED_FILL_COLOR: Color = Color::new(0xfffffff1);
737            const THEME_CHECK_COLOR: Color = Color::new(0xfffffff2);
738            const THEME_FOCUS_OVERLAY_COLOR: Color = Color::new(0xfffffff3);
739            const THEME_HOVER_OVERLAY_COLOR: Color = Color::new(0xfffffff4);
740            const THEME_SPLASH_RADIUS: f64 = 1.0;
741
742            const DEFAULT_FILL_COLOR: Color = Color::new(0xfffffff5);
743            const SELECTED_FILL_COLOR: Color = Color::new(0xfffffff6);
744            const CHECK_COLOR: Color = Color::new(0xfffffff7);
745            const FOCUS_COLOR: Color = Color::new(0xfffffff8);
746            const HOVER_COLOR: Color = Color::new(0xfffffff9);
747            const SPLASH_RADIUS: f64 = 2.0;
748            const VISUAL_DENSITY: VisualDensity = VisualDensity::STANDARD;
749
750            let checkbox_theme = CheckboxThemeData::new()
751                .mouse_cursor(all_cursors(SystemMouseCursors::CLICK.into()))
752                .fill_color(color_property(|states| {
753                    if states.contains(&WidgetState::Selected) {
754                        return Some(THEME_SELECTED_FILL_COLOR);
755                    }
756                    Some(THEME_DEFAULT_FILL_COLOR)
757                }))
758                .check_color(all_colors(THEME_CHECK_COLOR))
759                .overlay_color(color_property(|states| {
760                    if states.contains(&WidgetState::Focused) {
761                        return Some(THEME_FOCUS_OVERLAY_COLOR);
762                    }
763                    if states.contains(&WidgetState::Hovered) {
764                        return Some(THEME_HOVER_OVERLAY_COLOR);
765                    }
766                    None
767                }))
768                .splash_radius(THEME_SPLASH_RADIUS)
769                .material_tap_target_size(MaterialTapTargetSize::Padded)
770                .visual_density(VisualDensity::STANDARD);
771            let fill_color = color_property(|states| {
772                if states.contains(&WidgetState::Selected) {
773                    return Some(SELECTED_FILL_COLOR);
774                }
775                Some(DEFAULT_FILL_COLOR)
776            });
777            let frame = |tester: &mut WidgetTester, selected: bool, autofocus: bool| {
778                pump_themed(
779                    tester,
780                    checkbox_theme.clone(),
781                    Checkbox::new(Some(selected), ignore())
782                        .autofocus(autofocus)
783                        .mouse_cursor(SystemMouseCursors::TEXT.into())
784                        .fill_color(Rc::clone(&fill_color))
785                        .check_color(CHECK_COLOR)
786                        .focus_color(FOCUS_COLOR)
787                        .hover_color(HOVER_COLOR)
788                        .splash_radius(SPLASH_RADIUS)
789                        .material_tap_target_size(MaterialTapTargetSize::ShrinkWrap)
790                        .visual_density(VISUAL_DENSITY)
791                        .into_widget(),
792                );
793                tester.pump_and_settle();
794            };
795
796            // Checkbox.
797            frame(tester, false, false);
798            assert_paints(tester, &[PaintCall::rrect(Some(DEFAULT_FILL_COLOR))]);
799            // Size from MaterialTapTargetSize.shrinkWrap with added VisualDensity.
800            assert_eq!(
801                checkbox_size(tester),
802                Size::new(40.0, 40.0) + VISUAL_DENSITY.base_size_adjustment()
803            );
804
805            // Selected checkbox.
806            frame(tester, true, false);
807            assert_paints(tester, &[PaintCall::rrect(Some(SELECTED_FILL_COLOR))]);
808            assert_paints(
809                tester,
810                &[
811                    PaintCall::rrect(Some(SELECTED_FILL_COLOR)),
812                    PaintCall::path(Some(CHECK_COLOR)),
813                ],
814            );
815
816            // Checkbox with hover.
817            frame(tester, false, false);
818            let gesture = point_gesture_to_checkbox(tester);
819            tester.pump_and_settle();
820            assert_eq!(tester.active_cursor(1), SystemMouseCursors::TEXT.into());
821            assert_paints(tester, &[PaintCall::circle(Some(HOVER_COLOR))]);
822
823            // Checkbox with focus.
824            frame(tester, false, true);
825            assert_paints(
826                tester,
827                &[PaintCall::Circle {
828                    x: None,
829                    y: None,
830                    radius: Some(SPLASH_RADIUS),
831                    color: Some(FOCUS_COLOR),
832                    style: None,
833                }],
834            );
835            tester.send(&gesture, PointerChange::Remove);
836        });
837    }
838
839    #[test]
840    fn checkbox_active_color_property_is_taken_over_the_theme() {
841        test_widgets(|tester| {
842            const THEME_SELECTED_FILL_COLOR: Color = Color::new(0xfffffff1);
843            const THEME_DEFAULT_FILL_COLOR: Color = Color::new(0xfffffff0);
844            const SELECTED_FILL_COLOR: Color = Color::new(0xfffffff6);
845            let checkbox_theme = CheckboxThemeData::new().fill_color(color_property(|states| {
846                if states.contains(&WidgetState::Selected) {
847                    return Some(THEME_SELECTED_FILL_COLOR);
848                }
849                Some(THEME_DEFAULT_FILL_COLOR)
850            }));
851            let frame = |tester: &mut WidgetTester, selected: bool| {
852                pump_themed(
853                    tester,
854                    checkbox_theme.clone(),
855                    Checkbox::new(Some(selected), ignore())
856                        .active_color(SELECTED_FILL_COLOR)
857                        .into_widget(),
858                );
859                tester.pump_and_settle();
860            };
861
862            // Unselected checkbox.
863            frame(tester, false);
864            assert_paints(tester, &[PaintCall::rrect(Some(THEME_DEFAULT_FILL_COLOR))]);
865
866            // Selected checkbox.
867            frame(tester, true);
868            assert_paints(tester, &[PaintCall::rrect(Some(SELECTED_FILL_COLOR))]);
869        });
870    }
871
872    #[test]
873    fn checkbox_theme_overlay_color_resolves_in_active_pressed_states() {
874        test_widgets(|tester| {
875            const ACTIVE_PRESSED_OVERLAY_COLOR: Color = Color::new(0xFF000001);
876            const INACTIVE_PRESSED_OVERLAY_COLOR: Color = Color::new(0xFF000002);
877            const SPLASH_RADIUS: f64 = 24.0;
878            let checkbox_theme = CheckboxThemeData::new()
879                .overlay_color(color_property(|states| {
880                    if states.contains(&WidgetState::Pressed) {
881                        if states.contains(&WidgetState::Selected) {
882                            return Some(ACTIVE_PRESSED_OVERLAY_COLOR);
883                        }
884                        return Some(INACTIVE_PRESSED_OVERLAY_COLOR);
885                    }
886                    None
887                }))
888                .splash_radius(SPLASH_RADIUS);
889
890            pump_themed(
891                tester,
892                checkbox_theme.clone(),
893                Checkbox::new(Some(false), ignore()).into_widget(),
894            );
895            let gesture1 = press(tester, 1);
896            tester.pump_and_settle();
897            assert_paints(
898                tester,
899                &[PaintCall::Circle {
900                    x: None,
901                    y: None,
902                    radius: Some(SPLASH_RADIUS),
903                    color: Some(INACTIVE_PRESSED_OVERLAY_COLOR),
904                    style: None,
905                }],
906            );
907
908            pump_themed(
909                tester,
910                checkbox_theme,
911                Checkbox::new(Some(true), ignore()).into_widget(),
912            );
913            let gesture2 = press(tester, 2);
914            tester.pump_and_settle();
915            assert_paints(
916                tester,
917                &[PaintCall::Circle {
918                    x: None,
919                    y: None,
920                    radius: Some(SPLASH_RADIUS),
921                    color: Some(ACTIVE_PRESSED_OVERLAY_COLOR),
922                    style: None,
923                }],
924            );
925
926            // Finish gesture to release resources.
927            tester.up(&gesture1);
928            tester.up(&gesture2);
929            tester.pump_and_settle();
930        });
931    }
932
933    #[test]
934    fn local_checkbox_theme_can_override_global_checkbox_theme() {
935        test_widgets(|tester| {
936            const GLOBAL_THEME_FILL_COLOR: Color = Color::new(0xfffffff1);
937            const GLOBAL_THEME_CHECK_COLOR: Color = Color::new(0xff000000);
938            const LOCAL_THEME_FILL_COLOR: Color = Color::new(0xffff0000);
939            const LOCAL_THEME_CHECK_COLOR: Color = Color::new(0xffffffff);
940            pump_themed(
941                tester,
942                CheckboxThemeData::new()
943                    .check_color(all_colors(GLOBAL_THEME_CHECK_COLOR))
944                    .fill_color(all_colors(GLOBAL_THEME_FILL_COLOR)),
945                CheckboxTheme::new(
946                    CheckboxThemeData::new()
947                        .fill_color(all_colors(LOCAL_THEME_FILL_COLOR))
948                        .check_color(all_colors(LOCAL_THEME_CHECK_COLOR)),
949                    Checkbox::new(Some(true), ignore()),
950                )
951                .into_widget(),
952            );
953            tester.pump_and_settle();
954            assert_paints(tester, &[PaintCall::rrect(Some(LOCAL_THEME_FILL_COLOR))]);
955            assert_paints(
956                tester,
957                &[
958                    PaintCall::rrect(Some(LOCAL_THEME_FILL_COLOR)),
959                    PaintCall::path(Some(LOCAL_THEME_CHECK_COLOR)),
960                ],
961            );
962        });
963    }
964
965    #[test]
966    fn checkbox_theme_data_lerp_with_null_parameters() {
967        let lerped = CheckboxThemeData::lerp(None, None, 0.25);
968
969        assert!(lerped.mouse_cursor.is_none());
970        assert!(lerped.fill_color.is_none());
971        assert!(lerped.check_color.is_none());
972        assert!(lerped.overlay_color.is_none());
973        assert_eq!(lerped.splash_radius, None);
974        assert_eq!(lerped.material_tap_target_size, None);
975        assert_eq!(lerped.visual_density, None);
976        assert!(lerped.shape.is_none());
977        assert_eq!(lerped.side, None);
978        assert_eq!(lerped.mark_insets, None);
979    }
980
981    fn rounded(radius: f64) -> RoundedRectangleBorder {
982        RoundedRectangleBorder::new(
983            BorderSide::NONE,
984            BorderRadiusGeometry::all(Radius::circular(radius)),
985        )
986    }
987
988    fn side_of_width(width: f64) -> BorderSide {
989        BorderSide {
990            width,
991            ..BorderSide::default()
992        }
993    }
994
995    fn populated(
996        colors: [u32; 3],
997        splash_radius: f64,
998        visual_density: f64,
999        radius: f64,
1000        side_width: f64,
1001        mark_insets: f64,
1002    ) -> CheckboxThemeData {
1003        CheckboxThemeData::new()
1004            .fill_color(all_colors(Color::new(colors[0])))
1005            .check_color(all_colors(Color::new(colors[1])))
1006            .overlay_color(all_colors(Color::new(colors[2])))
1007            .splash_radius(splash_radius)
1008            .material_tap_target_size(MaterialTapTargetSize::ShrinkWrap)
1009            .visual_density(VisualDensity::new(visual_density, visual_density))
1010            .shape(rounded(radius))
1011            .side(side_of_width(side_width))
1012            .mark_insets(EdgeInsets::all(mark_insets))
1013    }
1014
1015    fn resolved(property: &Option<WidgetStatePropertyRef<Option<Color>>>) -> Color {
1016        property
1017            .as_ref()
1018            .expect("a property")
1019            .resolve(&WidgetStates::new())
1020            .expect("a colour")
1021    }
1022
1023    fn assert_shape(lerped: &CheckboxThemeData, radius: f64) {
1024        let shape: &dyn ShapeBorder = lerped.shape.as_deref().expect("a shape");
1025        assert!(
1026            shape == &rounded(radius) as &dyn ShapeBorder,
1027            "{shape:?} is not of radius {radius}"
1028        );
1029    }
1030
1031    #[test]
1032    fn checkbox_theme_data_lerp_from_populated_to_null_parameters() {
1033        let theme = populated(
1034            [0xfffffff0, 0xfffffff1, 0xfffffff2],
1035            3.0,
1036            1.0,
1037            4.0,
1038            4.0,
1039            4.0,
1040        );
1041        let lerped = CheckboxThemeData::lerp(Some(&theme), None, 0.5);
1042
1043        assert!(is_same_color_as(
1044            resolved(&lerped.fill_color),
1045            Color::new(0x80fffff0)
1046        ));
1047        assert!(is_same_color_as(
1048            resolved(&lerped.check_color),
1049            Color::new(0x80fffff1)
1050        ));
1051        assert!(is_same_color_as(
1052            resolved(&lerped.overlay_color),
1053            Color::new(0x80fffff2)
1054        ));
1055        assert_eq!(lerped.splash_radius, Some(1.5));
1056        assert_eq!(lerped.material_tap_target_size, None);
1057        assert_eq!(lerped.visual_density, None);
1058        assert_shape(&lerped, 2.0);
1059        let side = lerped.side.expect("a side");
1060        assert_eq!(side.width, 2.0);
1061        assert!(is_same_color_as(side.color, Color::new(0x80000000)));
1062        assert_eq!(lerped.mark_insets, Some(EdgeInsets::all(2.0)));
1063    }
1064
1065    #[test]
1066    fn checkbox_theme_data_lerp_from_null_to_populated_parameters() {
1067        let theme = populated(
1068            [0xfffffff0, 0xfffffff1, 0xfffffff2],
1069            4.0,
1070            1.0,
1071            4.0,
1072            4.0,
1073            4.0,
1074        );
1075        let lerped = CheckboxThemeData::lerp(None, Some(&theme), 0.25);
1076
1077        assert!(is_same_color_as(
1078            resolved(&lerped.fill_color),
1079            Color::new(0x40fffff0)
1080        ));
1081        assert!(is_same_color_as(
1082            resolved(&lerped.check_color),
1083            Color::new(0x40fffff1)
1084        ));
1085        assert!(is_same_color_as(
1086            resolved(&lerped.overlay_color),
1087            Color::new(0x40fffff2)
1088        ));
1089        assert_eq!(lerped.splash_radius, Some(1.0));
1090        assert_eq!(lerped.material_tap_target_size, None);
1091        assert_eq!(lerped.visual_density, None);
1092        assert_shape(&lerped, 1.0);
1093        let side = lerped.side.expect("a side");
1094        assert_eq!(side.width, 1.0);
1095        assert!(is_same_color_as(side.color, Color::new(0x40000000)));
1096        assert_eq!(lerped.mark_insets, Some(EdgeInsets::all(1.0)));
1097    }
1098
1099    #[test]
1100    fn checkbox_theme_data_lerp_from_populated_parameters() {
1101        let theme_a = populated(
1102            [0xfffffff0, 0xfffffff1, 0xfffffff2],
1103            3.0,
1104            1.0,
1105            4.0,
1106            4.0,
1107            4.0,
1108        );
1109        let theme_b = populated(
1110            [0xfffffff3, 0xfffffff4, 0xfffffff5],
1111            9.0,
1112            2.0,
1113            1.0,
1114            3.0,
1115            2.0,
1116        );
1117        let lerped = CheckboxThemeData::lerp(Some(&theme_a), Some(&theme_b), 0.5);
1118
1119        assert!(is_same_color_as(
1120            resolved(&lerped.fill_color),
1121            Color::new(0xfffffff1)
1122        ));
1123        assert!(is_same_color_as(
1124            resolved(&lerped.check_color),
1125            Color::new(0xfffffff2)
1126        ));
1127        assert!(is_same_color_as(
1128            resolved(&lerped.overlay_color),
1129            Color::new(0xfffffff3)
1130        ));
1131        assert_eq!(lerped.splash_radius, Some(6.0));
1132        assert_eq!(
1133            lerped.material_tap_target_size,
1134            Some(MaterialTapTargetSize::ShrinkWrap)
1135        );
1136        assert_eq!(lerped.visual_density, Some(VisualDensity::new(2.0, 2.0)));
1137        assert_shape(&lerped, 2.5);
1138        assert_eq!(lerped.side, Some(AnyBorderSide::new(side_of_width(3.5))));
1139        assert_eq!(lerped.mark_insets, Some(EdgeInsets::all(3.0)));
1140    }
1141
1142    #[test]
1143    fn widget_state_border_side_properly_lerp_in_checkbox_theme_data_side() {
1144        test_widgets(|tester| {
1145            // Dart's `late ColorScheme colorScheme`, which both themes' side closures read.
1146            let primary = Rc::new(Cell::new(Colors::TRANSPARENT));
1147            let frame = |tester: &mut WidgetTester, seed_color: Color| {
1148                let color_scheme = ColorScheme::from_seed(seed_color).build();
1149                primary.set(color_scheme.primary());
1150                let primary = Rc::clone(&primary);
1151                pump_themed_with_colors(
1152                    tester,
1153                    color_scheme,
1154                    CheckboxThemeData::new().side(WidgetStateBorderSide::resolve_with(
1155                        move |_states| {
1156                            Some(BorderSide {
1157                                color: primary.get(),
1158                                width: 4.0,
1159                                ..BorderSide::default()
1160                            })
1161                        },
1162                    )),
1163                );
1164            };
1165
1166            frame(tester, Colors::RED.primary());
1167            tester.pump_and_settle();
1168            assert_paints(tester, &[PaintCall::drrect(Some(primary.get()))]);
1169
1170            frame(tester, Colors::BLUE.primary());
1171            tester.pump_by(waft_gestures::K_PRESS_TIMEOUT);
1172            assert_paints(tester, &[PaintCall::drrect(Some(primary.get()))]);
1173        });
1174    }
1175
1176    /// The last case's `MaterialApp(theme: ThemeData(colorScheme:, checkboxTheme:))`.
1177    fn pump_themed_with_colors(
1178        tester: &mut WidgetTester,
1179        color_scheme: ColorScheme,
1180        checkbox_theme: CheckboxThemeData,
1181    ) {
1182        let root = {
1183            let app = tester.cell.borrow();
1184            material_app(
1185                ThemeData::builder()
1186                    .color_scheme(color_scheme)
1187                    .checkbox_theme(checkbox_theme)
1188                    .build(&app),
1189                Scaffold::new()
1190                    .body(Checkbox::new(Some(false), ignore()))
1191                    .into_widget(),
1192            )
1193        };
1194        tester.pump_widget(root);
1195    }
1196    // Flutter's "Default CheckboxThemeData debugFillProperties".
1197    #[test]
1198    fn a_checkbox_theme_data_describes_nothing_by_default() {
1199        assert_eq!(
1200            waft_widgets::testing::describe_properties(|properties| {
1201                waft_foundation::Diagnosticable::debug_fill_properties(
1202                    &CheckboxThemeData::new(),
1203                    properties,
1204                )
1205            }),
1206            Vec::<String>::new()
1207        );
1208    }
1209
1210    // checkbox_theme_test.dart 'CheckboxThemeData implements debugFillProperties'.
1211    #[test]
1212    fn an_assigned_checkbox_theme_describes_every_property() {
1213        let theme = CheckboxThemeData::new()
1214            .mouse_cursor(Rc::new(WidgetStatePropertyAll::new(Some(
1215                SystemMouseCursors::CLICK.into(),
1216            ))))
1217            .fill_color(Rc::new(WidgetStatePropertyAll::new(Some(Color::new(
1218                0xfffffff0,
1219            )))))
1220            .check_color(Rc::new(WidgetStatePropertyAll::new(Some(Color::new(
1221                0xfffffff1,
1222            )))))
1223            .overlay_color(Rc::new(WidgetStatePropertyAll::new(Some(Color::new(
1224                0xfffffff2,
1225            )))))
1226            .splash_radius(1.0)
1227            .material_tap_target_size(MaterialTapTargetSize::ShrinkWrap)
1228            .visual_density(VisualDensity::STANDARD);
1229        let description = waft_widgets::testing::describe_properties(|properties| {
1230            waft_foundation::Diagnosticable::debug_fill_properties(&theme, properties)
1231        });
1232        let description: Vec<String> = description
1233            .iter()
1234            .map(|line| waft_rendering::testing::ignoring_hash_codes(line))
1235            .collect();
1236        assert_eq!(
1237            description,
1238            [
1239                "mouseCursor: WidgetStatePropertyAll(SystemMouseCursor(click))".to_string(),
1240                format!(
1241                    "fillColor: WidgetStatePropertyAll({})",
1242                    Color::new(0xfffffff0)
1243                ),
1244                format!(
1245                    "checkColor: WidgetStatePropertyAll({})",
1246                    Color::new(0xfffffff1)
1247                ),
1248                format!(
1249                    "overlayColor: WidgetStatePropertyAll({})",
1250                    Color::new(0xfffffff2)
1251                ),
1252                "splashRadius: 1.0".to_string(),
1253                "materialTapTargetSize: MaterialTapTargetSize.shrinkWrap".to_string(),
1254                "visualDensity: VisualDensity#00000(h: 0.0, v: 0.0)".to_string(),
1255            ]
1256        );
1257    }
1258}