Adds artboard parameter to onInit callback

This commit is contained in:
matt Sullivan
2021-06-18 11:02:53 -07:00
parent e589a121d6
commit 794bb90147
9 changed files with 67 additions and 8 deletions

View File

@ -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';

View File

@ -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