mirror of
https://github.com/rive-app/rive-flutter.git
synced 2025-08-26 09:57:48 +08:00
Adds artboard parameter to onInit callback
This commit is contained in:
@ -21,5 +21,5 @@ export 'package:rive/src/rive_core/shapes/paint/stroke.dart';
|
||||
export 'package:rive/src/rive_core/shapes/shape.dart';
|
||||
export 'package:rive/src/rive_file.dart';
|
||||
export 'package:rive/src/runtime_artboard.dart';
|
||||
export 'package:rive/src/state_machine_controller.dart';
|
||||
export 'package:rive/src/controllers/state_machine_controller.dart';
|
||||
export 'package:rive/src/widgets/rive_animation.dart';
|
||||
|
@ -1,5 +1,3 @@
|
||||
import 'dart:ui' show VoidCallback;
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:rive/rive.dart';
|
||||
import 'package:rive/src/rive_core/artboard.dart';
|
||||
@ -10,6 +8,9 @@ enum _Source {
|
||||
network,
|
||||
}
|
||||
|
||||
/// The callback signature for onInit
|
||||
typedef OnInitCallback = void Function(Artboard);
|
||||
|
||||
/// High level widget that plays an animation from a Rive file. If artboard or
|
||||
/// animation are not specified, the default artboard and first animation fonund
|
||||
/// within it are used.
|
||||
@ -46,7 +47,7 @@ class RiveAnimation extends StatefulWidget {
|
||||
final List<RiveAnimationController> controllers;
|
||||
|
||||
/// Callback fired when Riveanimation has initialized
|
||||
final VoidCallback? onInit;
|
||||
final OnInitCallback? onInit;
|
||||
|
||||
/// Creates a new RiveAnimation from an asset bundle
|
||||
const RiveAnimation.asset(
|
||||
@ -137,7 +138,7 @@ class _RiveAnimationState extends State<RiveAnimation> {
|
||||
setState(() => _artboard = artboard);
|
||||
|
||||
// Call the onInit callback if provided
|
||||
widget.onInit?.call();
|
||||
widget.onInit?.call(_artboard!);
|
||||
}
|
||||
|
||||
@override
|
||||
|
Reference in New Issue
Block a user