onPrintRequest property

  1. @SupportedPlatforms.new(platforms: [AndroidPlatform(), IOSPlatform(), MacOSPlatform(), WebPlatform(), LinuxPlatform(note: 'Intercepted via JavaScript window.print() override.')], parameterPlatforms: {'printJobController' : [AndroidPlatform(), IOSPlatform(), MacOSPlatform()]})
FutureOr<bool?> Function(T controller, WebUri? url, PlatformPrintJobController? printJobController)? onPrintRequest
final

Event fired when window.print() is called from JavaScript side. Return true if you want to handle the print job. Otherwise return false, so the PlatformPrintJobController will be handled and disposed automatically by the system.

url represents the url on which is called.

printJobController represents the controller of the print job created.

Officially Supported Platforms/Implementations:

  • Android WebView
  • iOS WKWebView
  • macOS WKWebView
  • Web <iframe> but requires same origin
  • Linux WPE WebKit:
    • Intercepted via JavaScript window.print() override.

Parameters - Officially Supported Platforms/Implementations:

  • url: all platforms
  • printJobController:
    • Android WebView
    • iOS WKWebView
    • macOS WKWebView

Use the PlatformWebViewCreationParams.isPropertySupported method to check if this property is supported at runtime.

Implementation

@SupportedPlatforms(
  platforms: [
    AndroidPlatform(),
    IOSPlatform(),
    MacOSPlatform(),
    WebPlatform(),
    LinuxPlatform(
      note: 'Intercepted via JavaScript window.print() override.',
    ),
  ],
  parameterPlatforms: {
    'printJobController': [AndroidPlatform(), IOSPlatform(), MacOSPlatform()],
  },
)
final FutureOr<bool?> Function(
  T controller,
  WebUri? url,
  PlatformPrintJobController? printJobController,
)?
onPrintRequest;