flutter_golden_animation 0.1.1 copy "flutter_golden_animation: ^0.1.1" to clipboard
flutter_golden_animation: ^0.1.1 copied to clipboard

Animation golden testing for Flutter. Captures widget animation frames as lossless APNG golden files.

example/example.dart

// ignore_for_file: depend_on_referenced_packages
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter_golden_animation/flutter_golden_animation.dart';

void main() {
  // Register the APNG golden comparator
  setupGoldenAnimationCompare();

  testWidgets('my widget animation', (tester) async {
    // 1. Pump a widget wrapped in RepaintBoundary
    await tester.pumpWidget(
      MaterialApp(
        home: RepaintBoundary(
          child: ElevatedButton(
            onPressed: () {},
            child: const Text('Press me'),
          ),
        ),
      ),
    );

    // 2. Create a recorder
    final recorder = AnimationRecorder(tester);

    // 3. Record the animation (interaction fires first, then frames are captured)
    await recorder.record(
      interaction: () => tester.tap(find.byType(ElevatedButton)),
      duration: const Duration(milliseconds: 300),
      frameRate: 10, // 10 fps = one frame every 100ms
    );

    // 4. Compare against the golden APNG
    // First run: use `flutter test --update-goldens` to generate it
    await recorder.compareWithGolden('goldens/my_widget_animation.apng');
  });
}
3
likes
160
points
117
downloads

Documentation

API reference

Publisher

verified publisherbasdevaan.nl

Weekly Downloads

Animation golden testing for Flutter. Captures widget animation frames as lossless APNG golden files.

Repository (GitHub)
View/report issues

Topics

#testing #golden-test #animation #screenshot #apng

License

MIT (license)

Dependencies

flutter, flutter_test

More

Packages that depend on flutter_golden_animation