Tilt with controller
Use the controller to tilt the widget
If you want to control the tilt programmatically, you can see the following:
Configure Tilt.tiltController
...
final tiltController = TiltController();
void dispose() {
tiltController.dispose();
super.dispose();
}
...
Tilt(
tiltController: tiltController,
...
),
...
Using the controller
Handle the move input event.
Should be used together with leave to indicate the end of the gesture.
position is the current trigger position, It will have the tilt effect of the corresponding position.
For example:
There is a widget size, width: 10, height: 10,
- Offset(0, 0): Maximum tilt top left.
- Offset(10, 10): Maximum tilt bottom right.
tiltController.move(position: Offset(xx, xx));
Handle the leave input event.
Stop using the current gesture.
tiltController.leave(position: Offset(xx, xx));
More
You can also see an example: Example - TiltStreamController.
For more information, see: Tilt widget - TiltController.