record method
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:
- WidgetTester.pumpFrames, which renders a widget in a series of frames with a fixed time interval.
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,
);
}