Flutter Rive Event Listeners - Subscribe to Rive Events in Flutter Runtime

Flutter Rive Event Listeners - Subscribe to Rive Events in Flutter Runtime

The Motion Magic

54 года назад

503 Просмотров

Learn how to add event listeners to your Rive animations in Flutter with this quick guide!

Rive Flutter Course - https://themotionmagic.com/p/flutter-rive-animations

⏳ Timestamps
00:00 Intro
00:55 State Machine Controller
01:50 Add Event Listener
03:55 Event Properties
05:35 setState

🛎️ What are Rive events?

With Rive events, you have the ability to subscribe to meaningful signals that get reported from animations, state machines, and Rive listeners, all created at design time from the Rive editor. These signals can be subscribed to at runtime and have a specific name, type, and various custom metadata that may accompany the event to help inform the context surrounding its meaning.

🎯 Adding an Event Listener

After setting up a state machine controller, use the addEventListener and provide a callback to subscribe to Rive events. The provided callback receives a RiveEvent object, containing details like event name, time delay, and custom properties. You can use removeEventListener to remove the listener as well.

🚀 RiveEvent Types

You have to two event types RiveOpenURLEvent and RiveGeneralEvent. The RiveOpenURLEvent has additional fields like, url and target (enum of type OpenUrlTarget).

⚙️ setState inside Callback

Remember to schedule a setState call on the next frame using WidgetsBinding.instance.postFrameCallback to avoid exceptions during frame updates.

Тэги:

#rive_flutter #rive_flutter_animation #rive_events
Ссылки и html тэги не поддерживаются


Комментарии: