printCurrentPage method
Prints the current page.
To obtain the PrintJobController, use settings
argument with PrintJobSettings.handledByClient to true
.
Otherwise this method will return null
and the PrintJobController will be handled and disposed automatically by the system.
NOTE for Android: available on Android 19+.
NOTE for MacOS: PrintJobController is available on MacOS 11.0+.
NOTE for Web: this method will have effect only if the iframe has the same origin. Also, PrintJobController is always null
.
Supported Platforms/Implementations:
- Android native WebView (Official API - PrintManager.print)
- iOS (Official API - UIPrintInteractionController.present)
- MacOS (if 11.0+, Official API - WKWebView.printOperation, else Official API - NSView.printView)
- Web (Official API - Window.print)
Implementation
Future<PrintJobController?> printCurrentPage(
{PrintJobSettings? settings}) async {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent("settings", () => settings?.toMap());
String? jobId = await _channel.invokeMethod('printCurrentPage', args);
if (jobId != null) {
return PrintJobController(id: jobId);
}
return null;
}