dvSsrFirstLayout function

String dvSsrFirstLayout(
  1. String html,
  2. Map<String, Object?> capture, {
  3. Map<String, List<DVLayoutFont>> fonts = const <String, List<DVLayoutFont>>{},
})

html laid out from capture: {"widths": [{"width", "height", "light", "dark", "controls"}]}, light and dark being paint snapshots. fonts is FontManifest.json by family. Unchanged when capture has no width.

Implementation

String dvSsrFirstLayout(
  String html,
  Map<String, Object?> capture, {
  Map<String, List<DVLayoutFont>> fonts = const <String, List<DVLayoutFont>>{},
}) {
  final List<_Width> widths = <_Width>[
    for (final Object? entry
        in (capture['widths'] as List<Object?>? ?? const <Object?>[]))
      if (entry is Map) _Width.fromJson(entry.cast<String, Object?>()),
  ]..sort((_Width a, _Width b) => a.width.compareTo(b.width));
  if (widths.isEmpty) return html;
  return _Layout(widths, fonts).run(html);
}