AnimationSheetBuilder class Null safety

Records the frames of an animating widget, and later displays the frames as a grid in an animation sheet.

This class does not support Web, because the animation sheet utilizes taking screenshots, which is unsupported on the Web. Tests that use this class must be noted with skip: isBrowser. (

Using this class includes the following steps:

  • Create an instance of this class.
  • Pump frames that render the target widget wrapped in record. Every frame that has recording being true will be recorded.
  • Adjust the size of the test viewport to the sheetSize (see the documentation of sheetSize for more information).
  • Pump a frame that renders display, which shows all recorded frames in an animation sheet, and can be matched against the golden test.

The following example shows how to record an animation sheet of an InkWell being pressed then released.
testWidgets('Inkwell animation sheet', (WidgetTester tester) async {
  // Create instance
  final AnimationSheetBuilder animationSheet = AnimationSheetBuilder(frameSize: const Size(48, 24));

  final Widget target = Material(
    child: Directionality(
      textDirection: TextDirection.ltr,
      child: InkWell(
        onTap: () {},

  // Optional: setup before recording (`recording` is false)
  await tester.pumpWidget(animationSheet.record(
    recording: false,

  final TestGesture gesture = await tester.startGesture(tester.getCenter(find.byType(InkWell)));

  // Start recording (`recording` is true)
  await tester.pumpFrames(animationSheet.record(
    recording: true,
  ), const Duration(seconds: 1));

  await gesture.up();

  await tester.pumpFrames(animationSheet.record(
    recording: true,
  ), const Duration(seconds: 1));

  // Adjust view port size

  // Display
  final Widget display = await animationSheet.display();
  await tester.pumpWidget(display);

  // Compare against golden file
  await expectLater(
}, skip: isBrowser); // Animation sheet does not support browser

See also:


AnimationSheetBuilder({required Size frameSize})
Starts a session of building an animation sheet. [...]


frameSize Size
The size of the child to be recorded. [...]
hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited


display({Key? key}) Future<Widget>
Constructs a widget that renders the recorded frames in an animation sheet. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
record(Widget child, {Key? key, bool recording = true}) Widget
Returns a widget that renders a widget in a box that can be recorded. [...]
sheetSize({double maxWidth = _kDefaultTestViewportWidth}) Size
Returns the smallest size that can contain all recorded frames. [...]
toString() String
A string representation of this object. [...]


operator ==(Object other) bool
The equality operator. [...]