build method

  1. @override
Widget build(
  1. BuildContext context
)
override

Builds the widget tree for the Lava animation view.

This method creates an AnimatedBuilder that listens to the controller for frame changes and updates the display accordingly. If no animation asset is loaded yet, it displays an empty SizedBox.

Implementation

@override
Widget build(BuildContext context) {
  return AnimatedBuilder(
    animation: controller,
    builder: (context, _) {
      final asset = controller.asset;
      final frameIndex = controller.frameIndex;

      if (asset == null) {
        return const SizedBox();
      }

      return CustomPaint(
        painter: LavaPainter(
          asset: asset,
          frameIndex: frameIndex,
        ),
      );
    },
  );
}