checkMaterialSurface function

void checkMaterialSurface(
  1. Map<String, List<double>> inputs
)

Throws ArgumentError unless inputs answers every name in kMaterialInputs, with the right number of components.

A backend calls this once, where it can be seen, rather than discovering a missing input at whichever fragment first reads it.

Implementation

void checkMaterialSurface(Map<String, List<double>> inputs) {
  for (final input in kMaterialInputs) {
    final value = inputs[input.name];
    if (value == null) {
      throw ArgumentError('The surface has no "${input.name}".');
    }
    if (value.length != input.type.components) {
      throw ArgumentError(
        '"${input.name}" is a ${input.type} and was given ${value.length} '
        'components.',
      );
    }
  }
}