renderPage method
String
renderPage(
- PageRegistry registry,
- String component, {
- Object? props = const <String, dynamic>{},
- FlintComponent missingPage(
- String component
Renders a registered page component to HTML.
Implementation
String renderPage(
PageRegistry registry,
String component, {
Object? props = const <String, dynamic>{},
FlintComponent Function(String component)? missingPage,
}) {
final normalizedProps = switch (props) {
FlintProps typed => typed.toJson(),
Map<String, dynamic> map => map,
Map map => map.map((key, value) => MapEntry(key.toString(), value)),
_ => const <String, dynamic>{},
};
final builder = registry[component];
final page = builder?.call(normalizedProps) ??
missingPage?.call(component) ??
_MissingServerPage(component);
return render(page);
}