pub struct Radio<T: Clone + PartialEq + 'static> {Show 22 fields
pub key: Option<KeyRef>,
pub value: T,
pub group_value: Option<T>,
pub on_changed: Option<ValueChanged<Option<T>>>,
pub mouse_cursor: Option<MouseCursorRef>,
pub toggleable: bool,
pub active_color: Option<Color>,
pub fill_color: Option<WidgetStatePropertyRef<Option<Color>>>,
pub material_tap_target_size: Option<MaterialTapTargetSize>,
pub visual_density: Option<VisualDensity>,
pub focus_color: Option<Color>,
pub hover_color: Option<Color>,
pub overlay_color: Option<WidgetStatePropertyRef<Option<Color>>>,
pub splash_radius: Option<f64>,
pub focus_node: Option<FocusNodeRef>,
pub autofocus: bool,
pub use_cupertino_checkmark_style: bool,
pub group_registry: Option<RadioGroupRegistryRef<T>>,
pub enabled: Option<bool>,
pub background_color: Option<WidgetStatePropertyRef<Option<Color>>>,
pub side: Option<AnyBorderSide>,
pub inner_radius: Option<WidgetStatePropertyRef<Option<f64>>>,
/* private fields */
}Expand description
A Material Design radio button.
This widget builds a RawRadio with a material UI.
Used to select between a number of mutually exclusive values. When one radio
button in a group is selected, the other radio buttons in the group cease to
be selected. The values are of type T, the type parameter of the Radio
class. Enums are commonly used for this purpose.
This widget typically has a RadioGroup ancestor, which takes in a
RadioGroup::group_value, and the Radio under it with matching value
will be selected.
Requires one of its ancestors to be a Material widget.
See also:
RadioListTile, which combines this widget with aListTileso that you can give the radio button a label.Slider, for selecting a value in a range.CheckboxandSwitch, for toggling a particular value on or off.- https://material.io/design/components/selection-controls.html#radio-buttons
Fields§
§key: Option<KeyRef>§value: TThe value represented by this radio button.
group_value: Option<T>The currently selected value for a group of radio buttons.
This radio button is considered selected if its value matches the
group_value.
This is deprecated, use RadioGroup to manage group value instead.
on_changed: Option<ValueChanged<Option<T>>>Called when the user selects this radio button.
The radio button passes value as a parameter to this callback. The
radio button does not actually change state until the parent widget rebuilds the radio
button with the new group_value.
If null, the radio button will be displayed as disabled.
The provided callback will not be invoked if this radio button is already selected and
toggleable is not set to true.
If the toggleable is set to true, tapping a already selected radio
will invoke this callback with null as value.
The callback provided to on_changed should update the state of the
parent StatefulWidget using the State::set_state method, so that the parent gets
rebuilt.
This is deprecated, use RadioGroup to handle value change instead.
mouse_cursor: Option<MouseCursorRef>The cursor for a mouse pointer when it enters or is hovering over the widget.
If mouse_cursor is a WidgetStateMouseCursor,
WidgetStateProperty::resolve is used for the following WidgetStates:
If null, the value of RadioThemeData::mouse_cursor is used. If that is
also null, WidgetStateMouseCursor::adaptive_clickable is used.
toggleable: boolSet to true if this radio button is allowed to be returned to an indeterminate state by selecting it again when selected.
To indicate returning to an indeterminate state, RadioGroup::on_changed of the
RadioGroup above the widget tree will be called with null.
If true, RadioGroup::on_changed is called with value when selected
while RadioGroup::group_value != value, and with null when selected
again while RadioGroup::group_value == value.
If false, RadioGroup::on_changed will be called with value when it
is selected while RadioGroup::group_value != value, and only by
selecting another radio button in the group (i.e. changing the value of
RadioGroup::group_value) can this radio button be unselected.
The default is false.
active_color: Option<Color>The color to use when this radio button is selected.
Defaults to ColorScheme::secondary.
If fill_color returns a non-null color in the
WidgetState::Selected state, it will be used instead of this color.
fill_color: Option<WidgetStatePropertyRef<Option<Color>>>The color that fills the radio button, in all WidgetStates.
Resolves in the following states:
If null, then the value of active_color is used in the selected
state. If that is also null, then the value of RadioThemeData::fill_color is used.
If that is also null and ThemeData::use_material3 is false, then
ThemeData::disabled_color is used in the disabled state, ColorScheme::secondary
is used in the selected state, and ThemeData::unselected_widget_color is used in the
default state; if ThemeData::use_material3 is true, then ColorScheme::on_surface
is used in the disabled state, ColorScheme::primary is used in the
selected state and ColorScheme::on_surface_variant is used in the default state.
material_tap_target_size: Option<MaterialTapTargetSize>Configures the minimum size of the tap target.
If null, then the value of RadioThemeData::material_tap_target_size is used.
If that is also null, then the value of ThemeData::material_tap_target_size
is used.
See also:
MaterialTapTargetSize, for a description of how this affects tap targets.
visual_density: Option<VisualDensity>Defines how compact the radio’s layout will be.
If null, then the value of RadioThemeData::visual_density is used. If that
is also null, then the value of ThemeData::visual_density is used.
See also:
ThemeData::visual_density, which specifies thevisual_densityfor all widgets within aTheme.
focus_color: Option<Color>The color for the radio’s Material when it has the input focus.
If overlay_color returns a non-null color in the
WidgetState::Focused state, it will be used instead.
If null, then the value of RadioThemeData::overlay_color is used in the
focused state. If that is also null, then the value of
ThemeData::focus_color is used.
hover_color: Option<Color>The color for the radio’s Material when a pointer is hovering over it.
If overlay_color returns a non-null color in the
WidgetState::Hovered state, it will be used instead.
If null, then the value of RadioThemeData::overlay_color is used in the
hovered state. If that is also null, then the value of
ThemeData::hover_color is used.
overlay_color: Option<WidgetStatePropertyRef<Option<Color>>>The color for the radio’s Material.
Resolves in the following states:
If null, then the value of active_color with alpha
K_RADIAL_REACTION_ALPHA, focus_color and
hover_color is used in the pressed, focused and hovered state. If
that is also null, the value of RadioThemeData::overlay_color is used. If that is
also null, then in Material 2, the value of ColorScheme::secondary with alpha
K_RADIAL_REACTION_ALPHA, ThemeData::focus_color and ThemeData::hover_color
is used in the pressed, focused and hovered state. In Material3, the default
values are:
- selected
- pressed - Theme.colorScheme.onSurface(0.1)
- hovered - Theme.colorScheme.primary(0.08)
- focused - Theme.colorScheme.primary(0.1)
- pressed - Theme.colorScheme.primary(0.1)
- hovered - Theme.colorScheme.onSurface(0.08)
- focused - Theme.colorScheme.onSurface(0.1)
splash_radius: Option<f64>The splash radius of the circular Material ink response.
If null, then the value of RadioThemeData::splash_radius is used. If that
is also null, then K_RADIAL_REACTION_RADIUS is used.
focus_node: Option<FocusNodeRef>An optional focus node to use as the focus node for this widget.
If one is not supplied, then one will be automatically allocated, owned, and managed by
this widget. The widget will be focusable even if a focus_node is not supplied. If
supplied, the given focus_node will be hosted by this widget, but not owned.
autofocus: boolTrue if this widget will be selected as the initial focus when no other node in its scope is currently focused.
use_cupertino_checkmark_style: boolControls whether the checkmark style is used in an iOS-style radio.
Only usable under the Radio::adaptive constructor. If set to true, on
Apple platforms the radio button will appear as an iOS styled checkmark.
Controls the CupertinoRadio through CupertinoRadio::use_checkmark_style.
Defaults to false.
group_registry: Option<RadioGroupRegistryRef<T>>The registry this radio registers to.
Unless provided, the BuildContext will be used to look up the ancestor
RadioGroupRegistry.
enabled: Option<bool>Whether this widget is interactive.
If not provided, this widget will be interactable if one of the following is true:
- A
on_changedis provided. - Having a
RadioGroupwith the same type T above this widget. - A
group_registryis provided.
If this is set to true, one of the above condition must also be true. Otherwise, an assertion error is thrown.
background_color: Option<WidgetStatePropertyRef<Option<Color>>>The color of the background of the radio button, in all WidgetStates.
Resolves in the following states:
If null, then the ambient RadioThemeData::background_color is used.
If that is also null the default value is transparent in all states.
side: Option<AnyBorderSide>The side for the circular border of the radio button, in all
WidgetStates.
This property can be a BorderSide or a WidgetStateBorderSide to leverage
widget state resolution.
Resolves in the following states:
If null, then the ambient RadioThemeData::side is used. If that is
also null, the default value is a border using the fill color.
inner_radius: Option<WidgetStatePropertyRef<Option<f64>>>The radius of the inner circle of the radio button, in all WidgetStates.
Resolves in the following states:
If null, then the ambient RadioThemeData::inner_radius is used.
If that is also null, the default value is 4.5 in all states.
Implementations§
Source§impl<T: Clone + PartialEq + 'static> Radio<T>
impl<T: Clone + PartialEq + 'static> Radio<T>
Sourcepub fn new(value: T) -> Radio<T>
pub fn new(value: T) -> Radio<T>
Creates a Material Design radio button.
This widget typically has a RadioGroup ancestor, which takes in a
RadioGroup::group_value, and the Radio under it with matching
value will be selected.
The value is required.
Sourcepub fn adaptive(value: T) -> Radio<T>
pub fn adaptive(value: T) -> Radio<T>
Creates an adaptive Radio based on whether the target platform is iOS
or macOS, following Material design’s
Cross-platform guidelines.
On iOS and macOS, this constructor creates a CupertinoRadio, which has
matching functionality and presentation as Material checkboxes, and are the
graphics expected on iOS. On other platforms, this creates a Material
design Radio.
If a CupertinoRadio is created, the following parameters are ignored:
mouse_cursor, fill_color,
hover_color, overlay_color,
splash_radius,
material_tap_target_size,
visual_density.
use_cupertino_checkmark_style is used only if a
CupertinoRadio is created.
The target platform is based on the current Theme: ThemeData::platform.
Sourcepub fn group_value(self, group_value: T) -> Radio<T>
👎Deprecated: Use a RadioGroup ancestor to manage group value instead. This feature was deprecated after v3.32.0-0.0.pre.
pub fn group_value(self, group_value: T) -> Radio<T>
Use a RadioGroup ancestor to manage group value instead. This feature was deprecated after v3.32.0-0.0.pre.
Dart Radio(groupValue:).
Sourcepub fn on_changed(self, on_changed: ValueChanged<Option<T>>) -> Radio<T>
👎Deprecated: Use RadioGroup to handle value change instead. This feature was deprecated after v3.32.0-0.0.pre.
pub fn on_changed(self, on_changed: ValueChanged<Option<T>>) -> Radio<T>
Use RadioGroup to handle value change instead. This feature was deprecated after v3.32.0-0.0.pre.
Dart Radio(onChanged:).
Sourcepub fn mouse_cursor(self, mouse_cursor: MouseCursorRef) -> Radio<T>
pub fn mouse_cursor(self, mouse_cursor: MouseCursorRef) -> Radio<T>
Dart Radio(mouseCursor:).
Sourcepub fn toggleable(self, toggleable: bool) -> Radio<T>
pub fn toggleable(self, toggleable: bool) -> Radio<T>
Dart Radio(toggleable:).
Sourcepub fn active_color(self, active_color: Color) -> Radio<T>
pub fn active_color(self, active_color: Color) -> Radio<T>
Dart Radio(activeColor:).
Sourcepub fn fill_color(
self,
fill_color: WidgetStatePropertyRef<Option<Color>>,
) -> Radio<T>
pub fn fill_color( self, fill_color: WidgetStatePropertyRef<Option<Color>>, ) -> Radio<T>
Dart Radio(fillColor:).
Sourcepub fn focus_color(self, focus_color: Color) -> Radio<T>
pub fn focus_color(self, focus_color: Color) -> Radio<T>
Dart Radio(focusColor:).
Sourcepub fn hover_color(self, hover_color: Color) -> Radio<T>
pub fn hover_color(self, hover_color: Color) -> Radio<T>
Dart Radio(hoverColor:).
Sourcepub fn overlay_color(
self,
overlay_color: WidgetStatePropertyRef<Option<Color>>,
) -> Radio<T>
pub fn overlay_color( self, overlay_color: WidgetStatePropertyRef<Option<Color>>, ) -> Radio<T>
Dart Radio(overlayColor:).
Sourcepub fn splash_radius(self, splash_radius: f64) -> Radio<T>
pub fn splash_radius(self, splash_radius: f64) -> Radio<T>
Dart Radio(splashRadius:).
Sourcepub fn material_tap_target_size(
self,
material_tap_target_size: MaterialTapTargetSize,
) -> Radio<T>
pub fn material_tap_target_size( self, material_tap_target_size: MaterialTapTargetSize, ) -> Radio<T>
Dart Radio(materialTapTargetSize:).
Sourcepub fn visual_density(self, visual_density: VisualDensity) -> Radio<T>
pub fn visual_density(self, visual_density: VisualDensity) -> Radio<T>
Dart Radio(visualDensity:).
Sourcepub fn focus_node(self, focus_node: FocusNodeRef) -> Radio<T>
pub fn focus_node(self, focus_node: FocusNodeRef) -> Radio<T>
Dart Radio(focusNode:).
Sourcepub fn use_cupertino_checkmark_style(
self,
use_cupertino_checkmark_style: bool,
) -> Radio<T>
pub fn use_cupertino_checkmark_style( self, use_cupertino_checkmark_style: bool, ) -> Radio<T>
Dart Radio.adaptive(useCupertinoCheckmarkStyle:); only a radio made by
Radio::adaptive reads it.
Sourcepub fn group_registry(
self,
group_registry: RadioGroupRegistryRef<T>,
) -> Radio<T>
pub fn group_registry( self, group_registry: RadioGroupRegistryRef<T>, ) -> Radio<T>
Dart Radio(groupRegistry:).
Sourcepub fn background_color(
self,
background_color: WidgetStatePropertyRef<Option<Color>>,
) -> Radio<T>
pub fn background_color( self, background_color: WidgetStatePropertyRef<Option<Color>>, ) -> Radio<T>
Dart Radio(backgroundColor:).
Sourcepub fn side(self, side: impl Into<AnyBorderSide>) -> Radio<T>
pub fn side(self, side: impl Into<AnyBorderSide>) -> Radio<T>
Dart Radio(side:).
Sourcepub fn inner_radius(
self,
inner_radius: WidgetStatePropertyRef<Option<f64>>,
) -> Radio<T>
pub fn inner_radius( self, inner_radius: WidgetStatePropertyRef<Option<f64>>, ) -> Radio<T>
Dart Radio(innerRadius:).
Trait Implementations§
Source§impl<T: Clone + PartialEq + 'static> StatefulWidget for Radio<T>
impl<T: Clone + PartialEq + 'static> StatefulWidget for Radio<T>
Source§type State = RadioState<T>
type State = RadioState<T>
Source§fn create_state(&self) -> RadioState<T>
fn create_state(&self) -> RadioState<T>
Source§fn debug_fill_properties(
&self,
_app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )
debugFillProperties: the properties a dump shows for this widget, in Dart’s
order. Dart’s Widget base only sets the dense tree style, which the framework does.Source§fn as_preferred_size_widget(
&self,
) -> Option<&(dyn PreferredSizeWidget + 'static)>
fn as_preferred_size_widget( &self, ) -> Option<&(dyn PreferredSizeWidget + 'static)>
Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
Widget::type_name. A stateful form another widget kind becomes (an animated or
status transition widget) names the widget it wraps.Auto Trait Implementations§
impl<T> !RefUnwindSafe for Radio<T>
impl<T> !Send for Radio<T>
impl<T> !Sync for Radio<T>
impl<T> !UnwindSafe for Radio<T>
impl<T> Forget for Radio<T>
impl<T> Freeze for Radio<T>where
*const RcInner<dyn Key> is !null: Freeze,
PhantomData<RcInner<dyn Key>>: Freeze,
T: Freeze,
*const RcInner<dyn Fn(&mut App, Option<T>)> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&mut App, Option<T>)>>: Freeze,
*const RcInner<dyn MouseCursor> is !null: Freeze,
PhantomData<RcInner<dyn MouseCursor>>: Freeze,
*const RcInner<dyn WidgetStateProperty<Option<Color>>> is !null: Freeze,
PhantomData<RcInner<dyn WidgetStateProperty<Option<Color>>>>: Freeze,
NonZero<u32>: Freeze,
&'static FocusNodeVTable: Freeze,
*const RcInner<Keep> is !null: Freeze,
PhantomData<RcInner<Keep>>: Freeze,
&'static RadioGroupRegistryVTable<T>: Freeze,
*const RcInner<dyn BorderSideExtension> is !null: Freeze,
PhantomData<RcInner<dyn BorderSideExtension>>: Freeze,
*const RcInner<dyn WidgetStateProperty<Option<f64>>> is !null: Freeze,
PhantomData<RcInner<dyn WidgetStateProperty<Option<f64>>>>: Freeze,
impl<T> Move for Radio<T>
impl<T> Unpin for Radio<T>where
T: Unpin,
Rc<dyn Key>: Unpin,
Rc<dyn Fn(&mut App, Option<T>)>: Unpin,
Rc<dyn MouseCursor>: Unpin,
Rc<dyn WidgetStateProperty<Option<Color>>>: Unpin,
NonZero<u32>: Unpin,
&'static FocusNodeVTable: Unpin,
Rc<Keep>: Unpin,
&'static RadioGroupRegistryVTable<T>: Unpin,
Rc<dyn BorderSideExtension>: Unpin,
Rc<dyn WidgetStateProperty<Option<f64>>>: Unpin,
impl<T> UnsafeUnpin for Radio<T>where
*const RcInner<dyn Key> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Key>>: UnsafeUnpin,
T: UnsafeUnpin,
*const RcInner<dyn Fn(&mut App, Option<T>)> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut App, Option<T>)>>: UnsafeUnpin,
*const RcInner<dyn MouseCursor> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn MouseCursor>>: UnsafeUnpin,
*const RcInner<dyn WidgetStateProperty<Option<Color>>> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn WidgetStateProperty<Option<Color>>>>: UnsafeUnpin,
NonZeroU32Inner: UnsafeUnpin,
&'static FocusNodeVTable: UnsafeUnpin,
*const RcInner<Keep> is !null: UnsafeUnpin,
PhantomData<RcInner<Keep>>: UnsafeUnpin,
&'static RadioGroupRegistryVTable<T>: UnsafeUnpin,
*const RcInner<dyn BorderSideExtension> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn BorderSideExtension>>: UnsafeUnpin,
*const RcInner<dyn WidgetStateProperty<Option<f64>>> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn WidgetStateProperty<Option<f64>>>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
impl<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.