ensurePage method
Declares a page idempotently — no-ops if the page already exists in the target project.
This is identical to page except that compilation silently skips the
page creation when a page with the same name already exists. Use this
to make brownfield patches safe to re-run without manual cleanup.
app.ensurePage('CreateTripPage', route: '/create-trip', body: ...);
Implementation
PageHandle ensurePage(
String name, {
String? description,
required String route,
Map<String, DslType>? params,
Map<String, DslType>? state,
List<DslAction>? onLoad,
required DslWidget body,
bool isInitial = false,
}) {
_ensureNotPendingRemoval(_pendingRemovals, name, 'page', 'removePage');
_ensureUnique(_pageNames, name, 'page');
_ensurePageNames.add(name);
final declaration = PageDeclaration(
name: name,
description: description,
route: route,
params: params,
state: state,
onLoad: onLoad,
body: body,
isInitial: isInitial,
);
_pages.add(declaration);
return PageHandle(declaration);
}