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.
  • Acquire the output image with collate and compare against the golden file.

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));

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

See also:


AnimationSheetBuilder({required Size frameSize, bool allLayers = false})
Starts a session of building an animation sheet.


allLayers bool
Whether the captured image comes from the entire tree, or only the subtree of record.
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


collate(int cellsPerRow) Future<Image>
Returns an result image by putting all frames together in a table.
display({Key? key}) Future<Widget>
Constructs a widget that renders the recorded frames in an animation sheet.
@Deprecated('Use AnimationSheetBuilder.collate instead. ' 'This feature was deprecated after v2.3.0-13.0.pre.')
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.
@Deprecated('The `sheetSize` is only useful for `display`, which should be migrated to `collate`. ' 'This feature was deprecated after v2.3.0-13.0.pre.')
toString() String
A string representation of this object.


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