dataFor method

String? dataFor(
  1. T component, {
  2. Object? encode(
    1. Object?
    )?,
})

Returns the params of component encoded as JSON for its client component marker, or null if this target has no params.

The encode function converts values that JSON can't encode directly, such as a component passed as a server component.

Implementation

String? dataFor(T component, {Object? Function(Object?)? encode}) {
  if (params == null) return null;
  return const DomValidator().escapeMarkerText(jsonEncode(params!(component), toEncodable: encode));
}