PaintingCanvas.asset constructor

PaintingCanvas.asset(
  1. String path, {
  2. required Key key,
  3. bool? scalable,
  4. bool? showColorPicker,
  5. Widget? placeholderWidget,
  6. Function? save,
  7. List<Color>? colors,
  8. VoidCallback? onUpdate,
  9. Widget? undoIcon,
  10. Widget? colorIcon,
  11. required Size imageSize,
  12. required ThemeData theme,
  13. required I18n i18n,
  14. required ImageEditorTheme imageEditorTheme,
  15. required ImageEditorIcons icons,
  16. required ImageEditorDesignModeE designMode,
  17. required PaintEditorConfigs configs,
})

Create a PaintingCanvas widget with an image loaded from an asset.

Use this factory method to create a PaintingCanvas widget for painting on an image loaded from an asset. Customize the appearance and behavior of the widget using the provided parameters.

Parameters:

  • path: The asset path of the image (required).
  • key: A required Key to uniquely identify this widget in the widget tree.
  • imageSize: The size of the image (required).
  • theme: The theme configuration for the editor (required).
  • designMode: The design mode of the editor (material or custom, required).
  • i18n: The internationalization (i18n) configuration for the editor (required).
  • imageEditorTheme: The theme configuration specific to the image editor (required).
  • icons: Icons used in the editor (required).
  • configs: The configuration options for the paint editor (required).
  • onUpdate: A callback function called when the painting is updated.

Returns: A PaintingCanvas widget configured with the provided parameters and the image loaded from the asset.

Example Usage:

final String assetPath = 'assets/image.png'; // Provide the asset path.
final painter = PaintingCanvas.asset(
  assetPath,
  key: GlobalKey(),
  theme: ThemeData.light(),
  i18n: I18n(),
  imageEditorTheme: ImageEditorTheme(),
  icons: ImageEditorIcons(),
  designMode: ImageEditorDesignMode.material,
);

Implementation

factory PaintingCanvas.asset(
  String path, {
  required Key key,
  bool? scalable,
  bool? showColorPicker,
  Widget? placeholderWidget,
  Function? save,
  List<Color>? colors,
  VoidCallback? onUpdate,
  Widget? undoIcon,
  Widget? colorIcon,
  required Size imageSize,
  required ThemeData theme,
  required I18n i18n,
  required ImageEditorTheme imageEditorTheme,
  required ImageEditorIcons icons,
  required ImageEditorDesignModeE designMode,
  required PaintEditorConfigs configs,
}) {
  return PaintingCanvas._(
    key: key,
    assetPath: path,
    onUpdate: onUpdate,
    configs: configs,
    theme: theme,
    imageSize: imageSize,
    i18n: i18n,
    imageEditorTheme: imageEditorTheme,
    icons: icons,
    designMode: designMode,
  );
}