tryAdaptValidated static method

ValidatedChartTypeSwitchResult tryAdaptValidated(
  1. Map<String, dynamic> json,
  2. ChartType targetType, {
  3. bool force = false,
  4. bool registeredOnly = true,
  5. bool deep = true,
  6. bool requireRegisteredType = true,
})

Non-throwing switch plus post-switch validation.

Use this before building a runtime-selected chart when invalid payloads should be reported instead of surfacing from KChart.build.

Implementation

static ValidatedChartTypeSwitchResult tryAdaptValidated(
  Map<String, dynamic> json,
  ChartType targetType, {
  bool force = false,
  bool registeredOnly = true,
  bool deep = true,
  bool requireRegisteredType = true,
}) {
  final result = tryAdapt(
    json,
    targetType,
    force: force,
    registeredOnly: registeredOnly,
  );
  return ValidatedChartTypeSwitchResult(
    switchResult: result,
    validation: _validateSwitchedPayload(
      result.payload,
      deep: deep,
      requireRegisteredType: requireRegisteredType,
    ),
  );
}