openPrintTemplateDesigner function

Future<PrintTemplate?> openPrintTemplateDesigner(
  1. BuildContext context,
  2. PrintTemplate template
)

Opens the drag-and-drop designer on template and returns the template with the edited layout, paper format and app settings, or null when the user leaves without applying them.

Uses the library and data provider of the PrintScope above context.

Implementation

Future<PrintTemplate?> openPrintTemplateDesigner(
  BuildContext context,
  PrintTemplate template,
) {
  final scope = PrintScope.of(context);
  return Navigator.of(context).push<PrintTemplate>(
    MaterialPageRoute(
      fullscreenDialog: true,
      // The new route is not below the print center: it gets its own scope.
      builder: (_) => PrintScope(
        library: scope.library,
        dataProvider: scope.dataProvider,
        child: _TemplateDesignerPage(template: template),
      ),
    ),
  );
}