record method

Widget record(
  1. Widget child,
  2. {Key? key,
  3. bool recording = true}
)

Returns a widget that renders a widget in a box that can be recorded.

The returned widget wraps child in a box with a fixed size specified by frameSize. The key is also applied to the returned widget.

The frame is only recorded if the recording argument is true, or during a procedure that is wrapped within recording. In either case, the painted result of each frame will be stored and later available for collate. If neither condition is met, the frames are not recorded, which is useful during setup phases.

See also:

Implementation

Widget record(Widget child, {
  Key? key,
  bool recording = true,
}) {
  return _AnimationSheetRecorder(
    key: key,
    size: frameSize,
    allLayers: allLayers,
    handleRecorded: !recording ? null : (Future<ui.Image> futureImage) {
      _recordedFrames.add(_AsyncImage(() async {
        final ui.Image image = await futureImage;
        assert(image.width == frameSize.width && image.height == frameSize.height,
          'Unexpected size mismatch: frame has (${image.width}, ${image.height}) '
          'while `frameSize` is $frameSize.'
        );
        return image;
      }()));
    },
    child: child,
  );
}