Screenshot class
A PNG of the app's screen, or of one ScreenshotArea.
// The whole screen as the user sees it, dialogs and sheets included.
final Screenshot shot = await Screenshot.capture();
await shot.store('reports/checkout.png');
// One part of the screen, wrapped in a ScreenshotArea.
final Screenshot receipt = await Screenshot.area('receipt');
await receipt.store('order-1042.png', disk: 'public');
Captures work in every build mode, so they can power app features like
sharing a receipt or attaching the screen to a bug report. Metro's
screenshot command uses the same code.
Constructors
- Screenshot({required Uint8List bytes, required int width, required int height})
-
Creates a screenshot from
bytes, a PNG ofwidthbyheightphysical pixels.const
Properties
Methods
-
forStore(
ScreenshotStore store, {bool frame = false, String? caption, Color? background}) → Future< Screenshot> -
This screenshot at the exact size
storeasks for. -
framed(
{String? caption, Color? background}) → Future< Screenshot> -
This screenshot drawn in a plain phone outline on
background, undercaption, at its own size. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
store(
String path, {String? disk}) → Future< String> -
Saves the PNG to
pathondisk, or on the default disk, and returnspath. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
-
areas
→ List<
String> -
The names of the ScreenshotAreas on screen.
no setter
-
overlayKey
→ GlobalKey<
OverlayState> -
The overlay above rootKey, for things drawn over the app that stay
out of captures, like a playbook's finger and captions.
final
-
rootKey
→ GlobalKey<
State< StatefulWidget> > -
The boundary around the app's screen, which
NyAppplaces in itsMaterialApp.builderthrough ScreenshotRoot.final
Static Methods
-
area(
String name, {double? pixelRatio, bool settle = true, String? locale, String? theme}) → Future< Screenshot> -
Captures the ScreenshotArea called
name. -
capture(
{double? pixelRatio, bool settle = true, String? locale, String? theme}) → Future< Screenshot> - Captures the whole screen, dialogs and sheets included.
-
settleAnimations(
{Duration timeout = const Duration(seconds: 1)}) → Future< void> -
Waits for the next frame, then for running animations, like a theme
fading in, to finish, for at most
timeout. -
widget(
Widget child, {Size? size, double? pixelRatio, BuildContext? context, Duration delay = Duration.zero}) → Future< Screenshot> -
Captures
childwithout showing it, e.g. a share card built just for the image.