ShakeDetector
        Inherits: Service
Properties
- 
          minimum_shake_count(int) –Number of shakes required before shake is triggered. 
- 
          shake_count_reset_time_ms(int) –Time, in milliseconds, before shake count resets. 
- 
          shake_slop_time_ms(int) –Minimum time between shakes, in milliseconds. 
- 
          shake_threshold_gravity(Number) –Shake detection threshold, in Gs. 
Events
- 
          on_shake(ControlEventHandler[ShakeDetector] | None) –Called when a shake is detected. 
Examples#
Basic Example#
import flet as ft
def main(page: ft.Page):
    page.services.append(
        ft.ShakeDetector(
            minimum_shake_count=2,
            shake_slop_time_ms=300,
            shake_count_reset_time_ms=1000,
            on_shake=lambda _: page.add(ft.Text("Shake detected!")),
        )
    )
    page.add(ft.Text("Shake your device!"))
ft.run(main)
Properties#
class-attribute
      instance-attribute
  
#
minimum_shake_count: int = 1
Number of shakes required before shake is triggered.
class-attribute
      instance-attribute
  
#
shake_count_reset_time_ms: int = 3000
Time, in milliseconds, before shake count resets.
class-attribute
      instance-attribute
  
#
shake_slop_time_ms: int = 500
Minimum time between shakes, in milliseconds.
class-attribute
      instance-attribute
  
#
shake_threshold_gravity: Number = 2.7
Shake detection threshold, in Gs.
Events#
class-attribute
      instance-attribute
  
#
on_shake: ControlEventHandler[ShakeDetector] | None = None
Called when a shake is detected.