resolveBindings function

String resolveBindings(
  1. String template,
  2. Map<String, String> state
)

Substitutes {{key}} bindings from state.

An unknown key becomes an empty string rather than an error: a model that binds to a key it forgot to declare should render a blank, not refuse the whole screen.

Implementation

String resolveBindings(String template, Map<String, String> state) =>
    template.replaceAllMapped(_binding, (m) => state[m.group(1)] ?? '');