WidgetToImage class
Renders a Flutter widget to a PNG off-screen. Pair with a
NotificationMessage.fromPluginTemplate's heroImage to put
live-generated content in a toast.
final path = await WidgetToImage.toPngFile(
widget: MyRichToastCard(user: user),
size: const Size(364, 180),
);
Toast hero images are sized 364 x 180 DIPs. For crisp output on high-DPI
displays, pass a higher pixelRatio.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
toPng(
{required Widget widget, required Size size, double pixelRatio = 2.0, Duration waitBeforeCapture = Duration.zero, ThemeData? theme}) → Future< Uint8List> -
waitBeforeCapturegives async work in the widget (network images, etc.) a chance to land before capture. -
toPngFile(
{required Widget widget, required Size size, double pixelRatio = 2.0, Duration waitBeforeCapture = Duration.zero, ThemeData? theme, String? filePath}) → Future< String> -
filePathis where to write the PNG. If null, writes under the OS temp root; stale files accumulate until cleaned up by the caller.