Skip to main content

InkWell

Struct InkWell 

Source
pub struct InkWell {
    pub ink_response: InkResponse,
}
Expand description

A rectangular area of a Material that responds to touch.

For a variant of this widget that does not clip splashes, see InkResponse.

The InkWell widget must have a Material widget as an ancestor. The Material widget is where the ink reactions are actually painted. This matches the Material Design premise wherein the Material is what is actually reacting to touches by spreading ink.

If a Widget uses this class directly, it should include the following line at the top of its build function to call debug_check_has_material:

debug_assert!(debug_check_has_material(app, context));

§Troubleshooting

§The ink splashes aren’t visible!

If there is an opaque graphic, e.g. painted using a Container, Image, or DecoratedBox, between the Material widget and the InkWell widget, then the splash won’t be visible because it will be under the opaque graphic. This is because ink splashes draw on the underlying Material itself, as if the ink was spreading inside the material.

The Ink widget can be used as a replacement for Image, Container, or DecoratedBox to ensure that the image or decoration also paints in the Material itself, below the ink.

If this is not possible for some reason, e.g. because you are using an opaque CustomPaint widget, alternatively consider using a second Material above the opaque widget but below the InkWell (as an ancestor to the ink well). The MaterialType::Transparency material kind can be used for this purpose.

§InkWell isn’t clipping properly

If you want to clip an InkWell or any Ink widgets you need to keep in mind that the Material that the Ink will be printed on is responsible for clipping. This means you can’t wrap the Ink widget in a clipping widget directly, since this will leave the Material not clipped (and by extension the printed Ink widgets as well).

An easy solution is to deliberately wrap the Ink widgets you want to clip in a Material, and wrap that in a clipping widget instead. See Ink for an example.

§The ink splashes don’t track the size of an animated container

If the size of an InkWell’s Material ancestor changes while the InkWell’s splashes are expanding, you may notice that the splashes aren’t clipped correctly. This can’t be avoided.

An InkWell’s splashes will not properly update to conform to changes if the size of its underlying Material, where the splashes are rendered, changes during animation. You should avoid using InkWells within Material widgets that are changing size.

See also:

  • GestureDetector, for listening for gestures without ink splashes.
  • ElevatedButton and TextButton, two kinds of buttons in Material Design.
  • InkResponse, a variant of InkWell that doesn’t force a rectangular shape on the ink reaction.

Fields§

§ink_response: InkResponse

Dart’s extends InkResponse: the fields it inherits.

Implementations§

Source§

impl InkWell

Source

pub fn new() -> InkWell

Creates an ink well; Dart’s named arguments are the setters.

Must have an ancestor Material widget in which to cause ink reactions.

Source

pub fn key(self, key: KeyRef) -> InkWell

Dart InkWell(key:).

Source

pub fn on_tap(self, on_tap: GestureTapCallback) -> InkWell

Dart InkWell(on_tap:).

Source

pub fn on_tap_down(self, on_tap_down: GestureTapDownCallback) -> InkWell

Dart InkWell(on_tap_down:).

Source

pub fn on_tap_up(self, on_tap_up: GestureTapUpCallback) -> InkWell

Dart InkWell(on_tap_up:).

Source

pub fn on_tap_cancel(self, on_tap_cancel: GestureTapCallback) -> InkWell

Dart InkWell(on_tap_cancel:).

Source

pub fn on_double_tap(self, on_double_tap: GestureTapCallback) -> InkWell

Dart InkWell(on_double_tap:).

Source

pub fn on_long_press(self, on_long_press: GestureLongPressCallback) -> InkWell

Dart InkWell(on_long_press:).

Source

pub fn on_long_press_up( self, on_long_press_up: GestureLongPressUpCallback, ) -> InkWell

Dart InkWell(on_long_press_up:).

Source

pub fn on_secondary_tap(self, on_secondary_tap: GestureTapCallback) -> InkWell

Dart InkWell(on_secondary_tap:).

Source

pub fn on_secondary_tap_up( self, on_secondary_tap_up: GestureTapUpCallback, ) -> InkWell

Dart InkWell(on_secondary_tap_up:).

Source

pub fn on_secondary_tap_down( self, on_secondary_tap_down: GestureTapDownCallback, ) -> InkWell

Dart InkWell(on_secondary_tap_down:).

Source

pub fn on_secondary_tap_cancel( self, on_secondary_tap_cancel: GestureTapCallback, ) -> InkWell

Dart InkWell(on_secondary_tap_cancel:).

Source

pub fn on_tertiary_tap_up( self, on_tertiary_tap_up: GestureTapUpCallback, ) -> InkWell

Dart InkWell(on_tertiary_tap_up:).

Source

pub fn on_tertiary_tap_down( self, on_tertiary_tap_down: GestureTapDownCallback, ) -> InkWell

Dart InkWell(on_tertiary_tap_down:).

Source

pub fn on_tertiary_tap_cancel( self, on_tertiary_tap_cancel: GestureTapCancelCallback, ) -> InkWell

Dart InkWell(on_tertiary_tap_cancel:).

Source

pub fn on_highlight_changed( self, on_highlight_changed: ValueChanged<bool>, ) -> InkWell

Dart InkWell(on_highlight_changed:).

Source

pub fn on_hover(self, on_hover: ValueChanged<bool>) -> InkWell

Dart InkWell(on_hover:).

Source

pub fn mouse_cursor(self, mouse_cursor: MouseCursorRef) -> InkWell

Dart InkWell(mouse_cursor:).

Source

pub fn radius(self, radius: f64) -> InkWell

Dart InkWell(radius:).

Source

pub fn border_radius(self, border_radius: BorderRadius) -> InkWell

Dart InkWell(border_radius:).

Source

pub fn focus_color(self, focus_color: Color) -> InkWell

Dart InkWell(focus_color:).

Source

pub fn hover_color(self, hover_color: Color) -> InkWell

Dart InkWell(hover_color:).

Source

pub fn highlight_color(self, highlight_color: Color) -> InkWell

Dart InkWell(highlight_color:).

Source

pub fn overlay_color( self, overlay_color: WidgetStatePropertyRef<Option<Color>>, ) -> InkWell

Dart InkWell(overlay_color:).

Source

pub fn splash_color(self, splash_color: Color) -> InkWell

Dart InkWell(splash_color:).

Source

pub fn splash_factory( self, splash_factory: InteractiveInkFeatureFactoryRef, ) -> InkWell

Dart InkWell(splash_factory:).

Source

pub fn on_focus_change(self, on_focus_change: ValueChanged<bool>) -> InkWell

Dart InkWell(on_focus_change:).

Source

pub fn focus_node(self, focus_node: FocusNodeRef) -> InkWell

Dart InkWell(focus_node:).

Source

pub fn states_controller( self, states_controller: Ref<MaterialStatesController>, ) -> InkWell

Dart InkWell(states_controller:).

Source

pub fn hover_duration(self, hover_duration: Duration) -> InkWell

Dart InkWell(hover_duration:).

Source

pub fn enable_feedback(self, enable_feedback: bool) -> InkWell

Dart InkWell(enable_feedback:).

Source

pub fn exclude_from_semantics(self, exclude_from_semantics: bool) -> InkWell

Dart InkWell(exclude_from_semantics:).

Source

pub fn can_request_focus(self, can_request_focus: bool) -> InkWell

Dart InkWell(can_request_focus:).

Source

pub fn autofocus(self, autofocus: bool) -> InkWell

Dart InkWell(autofocus:).

Source

pub fn child<K>(self, child: impl IntoWidget<K>) -> InkWell

Dart InkWell(child:).

Source

pub fn custom_border(self, custom_border: impl Into<ShapeBorderRef>) -> InkWell

Dart InkWell(customBorder:).

Source

pub fn override_get_rect_callback( self, get_rect_callback: impl Fn(&App, AnyRenderBox) -> Option<RectCallback> + 'static, ) -> InkWell

Dart’s override of getRectCallback in a subclass: see InkResponse::get_rect_callback.

Source

pub fn override_debug_check_context( self, debug_check_context: impl Fn(&App, BuildContext) -> bool + 'static, ) -> InkWell

Dart’s override of debugCheckContext in a subclass: see InkResponse::debug_check_context.

Dart’s method is @mustCallSuper: debug_check_context also runs InkResponse::debug_check_context.

Trait Implementations§

Source§

impl Clone for InkWell

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for InkWell

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for InkWell

Source§

fn default() -> InkWell

Returns the “default value” for a type. Read more
Source§

impl StatelessWidget for InkWell

Source§

fn key(&self) -> Option<&KeyRef>

Source§

fn build(&self, app: &mut App, context: BuildContext) -> WidgetRef

Describes the part of the user interface represented by this widget. Read more
Source§

fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )

Dart’s 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 debug_check_constructor(&self)

Dart’s constructor asserts that relate two or more arguments. Read more
Source§

fn as_preferred_size_widget( &self, ) -> Option<&(dyn PreferredSizeWidget + 'static)>

Dart’s this is PreferredSizeWidget: a widget that implements PreferredSizeWidget answers with itself, which is what a parent asking an erased child for its preferred size reads.

Auto Trait Implementations§

§

impl !RefUnwindSafe for InkWell

§

impl !Send for InkWell

§

impl !Sync for InkWell

§

impl !UnwindSafe for InkWell

§

impl Forget for InkWell

§

impl Freeze for InkWell
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze, *const RcInner<dyn Widget> is !null: Freeze, PhantomData<RcInner<dyn Widget>>: Freeze, *const RcInner<dyn Fn(&mut App)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App)>>: Freeze, NonZero<u32>: Freeze, *const (): Freeze, *const RcInner<dyn Fn(&mut App, TapDownDetails)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, TapDownDetails)>>: Freeze, *const RcInner<dyn Fn(&mut App, TapUpDetails)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, TapUpDetails)>>: Freeze, *const RcInner<dyn Fn(&mut App, bool)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, bool)>>: Freeze, *const RcInner<dyn MouseCursor> is !null: Freeze, PhantomData<RcInner<dyn MouseCursor>>: Freeze, *const RcInner<dyn ShapeBorder> is !null: Freeze, PhantomData<RcInner<dyn ShapeBorder>>: Freeze, *const RcInner<dyn WidgetStateProperty<Option<Color>>> is !null: Freeze, PhantomData<RcInner<dyn WidgetStateProperty<Option<Color>>>>: Freeze, *const RcInner<dyn InteractiveInkFeatureFactory> is !null: Freeze, PhantomData<RcInner<dyn InteractiveInkFeatureFactory>>: Freeze, &'static FocusNodeVTable: Freeze, *const RcInner<Keep> is !null: Freeze, PhantomData<RcInner<Keep>>: Freeze, PhantomData<fn() -> WidgetStatesController>: Freeze, *const RcInner<dyn Fn(&App, AnyRenderBox) -> Option<Rc<dyn Fn(&App) -> Rect>>> is !null: Freeze, PhantomData<RcInner<dyn Fn(&App, AnyRenderBox) -> Option<Rc<dyn Fn(&App) -> Rect>>>>: Freeze, *const RcInner<dyn Fn(&App, AnyElement) -> bool> is !null: Freeze, PhantomData<RcInner<dyn Fn(&App, AnyElement) -> bool>>: Freeze,

§

impl Move for InkWell

§

impl Unpin for InkWell
where Rc<dyn Key>: Unpin, Rc<dyn Widget>: Unpin, Rc<dyn Fn(&mut App)>: Unpin, NonZero<u32>: Unpin, *const (): Unpin, Rc<dyn Fn(&mut App, TapDownDetails)>: Unpin, Rc<dyn Fn(&mut App, TapUpDetails)>: Unpin, Rc<dyn Fn(&mut App, bool)>: Unpin, Rc<dyn MouseCursor>: Unpin, Rc<dyn ShapeBorder>: Unpin, Rc<dyn WidgetStateProperty<Option<Color>>>: Unpin, Rc<dyn InteractiveInkFeatureFactory>: Unpin, &'static FocusNodeVTable: Unpin, Rc<Keep>: Unpin, Rc<dyn Fn(&App, AnyRenderBox) -> Option<Rc<dyn Fn(&App) -> Rect>>>: Unpin, Rc<dyn Fn(&App, AnyElement) -> bool>: Unpin,

§

impl UnsafeUnpin for InkWell
where *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin, *const RcInner<dyn Widget> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Widget>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App)>>: UnsafeUnpin, NonZeroU32Inner: UnsafeUnpin, *const (): UnsafeUnpin, *const RcInner<dyn Fn(&mut App, TapDownDetails)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, TapDownDetails)>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, TapUpDetails)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, TapUpDetails)>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, bool)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, bool)>>: UnsafeUnpin, *const RcInner<dyn MouseCursor> is !null: UnsafeUnpin, PhantomData<RcInner<dyn MouseCursor>>: UnsafeUnpin, *const RcInner<dyn ShapeBorder> is !null: UnsafeUnpin, PhantomData<RcInner<dyn ShapeBorder>>: UnsafeUnpin, *const RcInner<dyn WidgetStateProperty<Option<Color>>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn WidgetStateProperty<Option<Color>>>>: UnsafeUnpin, *const RcInner<dyn InteractiveInkFeatureFactory> is !null: UnsafeUnpin, PhantomData<RcInner<dyn InteractiveInkFeatureFactory>>: UnsafeUnpin, &'static FocusNodeVTable: UnsafeUnpin, *const RcInner<Keep> is !null: UnsafeUnpin, PhantomData<RcInner<Keep>>: UnsafeUnpin, PhantomData<fn() -> WidgetStatesController>: UnsafeUnpin, *const RcInner<dyn Fn(&App, AnyRenderBox) -> Option<Rc<dyn Fn(&App) -> Rect>>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&App, AnyRenderBox) -> Option<Rc<dyn Fn(&App) -> Rect>>>>: UnsafeUnpin, *const RcInner<dyn Fn(&App, AnyElement) -> bool> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&App, AnyElement) -> bool>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<W> IntoWidget<StatelessKind> for W
where W: StatelessWidget,

Source§

fn into_widget(self) -> Rc<dyn Widget>

The widget as a tree node, made where this is called: its creation_location.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>