pub struct Feedback;Expand description
Provides platform-specific acoustic and/or haptic feedback for certain actions.
For example, to play the Android-typically click sound when a button is
tapped, call for_tap. For the Android-specific vibration when long pressing
an element, call for_long_press. Alternatively, you can also wrap your
GestureDetector.on_tap or GestureDetector.on_long_press callback in
wrap_for_tap or wrap_for_long_press to achieve the same.
All methods in this class are usually called from within a
StatelessWidget::build method or from a State’s methods as you have to
provide a BuildContext.
Implementations§
Source§impl Feedback
impl Feedback
Sourcepub fn for_tap(app: &App, _context: BuildContext)
pub fn for_tap(app: &App, _context: BuildContext)
Provides platform-specific feedback for a tap.
On Android the click system sound is played. On iOS this is a no-op.
See also:
wrap_for_tapto trigger platform-specific feedback before executing aGestureTapCallback.
Sourcepub fn wrap_for_tap(
callback: Option<GestureTapCallback>,
context: BuildContext,
) -> Option<GestureTapCallback>
pub fn wrap_for_tap( callback: Option<GestureTapCallback>, context: BuildContext, ) -> Option<GestureTapCallback>
Wraps a GestureTapCallback to provide platform specific feedback for a
tap before the provided callback is executed.
On Android the platform-typical click system sound is played. On iOS this is a no-op as that platform usually doesn’t provide feedback for a tap.
See also:
for_tapto just trigger the platform-specific feedback without wrapping aGestureTapCallback.
Sourcepub fn for_long_press(app: &App, _context: BuildContext)
pub fn for_long_press(app: &App, _context: BuildContext)
Provides platform-specific feedback for a long press.
On Android the platform-typical vibration is triggered. On iOS a heavy-impact haptic feedback is triggered alongside the click system sound, which was observed to be the default behavior on a physical iPhone 15 Pro running iOS version 17.5.
See also:
wrap_for_long_pressto trigger platform-specific feedback before executing aGestureLongPressCallback.
Sourcepub fn wrap_for_long_press(
callback: Option<GestureLongPressCallback>,
context: BuildContext,
) -> Option<GestureLongPressCallback>
pub fn wrap_for_long_press( callback: Option<GestureLongPressCallback>, context: BuildContext, ) -> Option<GestureLongPressCallback>
Wraps a GestureLongPressCallback to provide platform specific feedback
for a long press before the provided callback is executed.
On Android the platform-typical vibration is triggered. On iOS a heavy-impact haptic feedback is triggered alongside the click system sound, which was observed to be the default behavior on a physical iPhone 15 Pro running iOS version 17.5.
See also:
for_long_pressto just trigger the platform-specific feedback without wrapping aGestureLongPressCallback.