HapticFeedback
Examples#
Basic Example#
import flet as ft
def main(page: ft.Page):
page.overlay.append(hf := ft.HapticFeedback())
page.add(
ft.ElevatedButton("Heavy impact", on_click=lambda _: hf.heavy_impact()),
ft.ElevatedButton("Medium impact", on_click=lambda _: hf.medium_impact()),
ft.ElevatedButton("Light impact", on_click=lambda _: hf.light_impact()),
ft.ElevatedButton("Vibrate", on_click=lambda _: hf.vibrate()),
)
ft.run(main)
HapticFeedback
#
Bases: Service
Allows access to the haptic feedback interface on the device.
It is non-visual and should be added to
Page.services
list before it can be used.
page
#
The page (of type Page
or PageView
) to which this control belongs to.
parent
#
parent: BaseControl | None
The direct ancestor(parent) of this control.
It defaults to None
and will only have a value when this control is mounted (added to the page tree).
The Page
control (which is the root of the tree) is an exception - it always has parent=None
.
before_update
#
This method is called every time when this control is being updated.
Note
Make sure not to call/request an update()
here.
heavy_impact
#
Provides a haptic feedback corresponding a collision impact with a heavy mass.
heavy_impact_async
#
Provides a haptic feedback corresponding a collision impact with a heavy mass.
light_impact
#
Provides a haptic feedback corresponding a collision impact with a light mass.
light_impact_async
#
Provides a haptic feedback corresponding a collision impact with a light mass.
medium_impact
#
Provides a haptic feedback corresponding a collision impact with a medium mass.
medium_impact_async
#
Provides a haptic feedback corresponding a collision impact with a medium mass.
vibrate_async
#
Provides vibration haptic feedback to the user for a short duration.