mirror of
https://github.com/rive-app/rive-flutter.git
synced 2025-11-08 17:05:58 +08:00
Expose methods to easily get Rive state machine inputs
Our current API is quite verbose and requires casting to the relevant class types when using the current find API. These methods simplify the process. Diffs= 1460f5366 Expose methods to easily get Rive state machine inputs (#7085) Co-authored-by: Gordon <pggordonhayes@gmail.com>
This commit is contained in:
@ -19,7 +19,7 @@ class _LittleMachineState extends State<LittleMachine> {
|
||||
|
||||
Artboard? _riveArtboard;
|
||||
StateMachineController? _controller;
|
||||
SMIInput<bool>? _trigger;
|
||||
SMITrigger? _trigger;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -42,7 +42,7 @@ class _LittleMachineState extends State<LittleMachine> {
|
||||
);
|
||||
if (controller != null) {
|
||||
artboard.addController(controller);
|
||||
_trigger = controller.findInput('Trigger 1');
|
||||
_trigger = controller.getTriggerInput('Trigger 1');
|
||||
}
|
||||
setState(() => _riveArtboard = artboard);
|
||||
},
|
||||
@ -64,7 +64,7 @@ class _LittleMachineState extends State<LittleMachine> {
|
||||
_riveArtboard == null
|
||||
? const SizedBox()
|
||||
: GestureDetector(
|
||||
onTapDown: (_) => _trigger?.value = true,
|
||||
onTapDown: (_) => _trigger?.fire(),
|
||||
child: Rive(
|
||||
artboard: _riveArtboard!,
|
||||
fit: BoxFit.cover,
|
||||
|
||||
Reference in New Issue
Block a user