getParamValue function
- GetGeneratorDetailResponseModel response,
- int piid
Returns the numerical value of the parameter matching the given piid
within the response's list of parameters.
Returns null if the parameter with the given piid does not exist. Also
returns null if the underlying display value is 'NA', which implies that
the value is invalid.
Implementation
double? getParamValue(
GetGeneratorDetailResponseModel response,
int piid,
) {
final param =
response.parameters?.firstWhereOrNull((element) => element.pdiid == piid);
if (param?.displayvalue?.trim().toUpperCase() == 'NA') return null;
return double.tryParse(param?.$value ?? 'x');
}