max property
Get the maximum of two numbers.
Implementation
static final max = DartBlockNativeFunction(
name: 'max',
returnType: DartBlockDataType.doubleType,
parameters: [
DartBlockVariableDefinition('a', DartBlockDataType.doubleType),
DartBlockVariableDefinition('b', DartBlockDataType.doubleType),
],
implementation: (arbiter, args) {
final a = args[0].getValue(arbiter) as num;
final b = args[1].getValue(arbiter) as num;
return DartBlockAlgebraicExpression.fromConstant(
a > b ? a.toDouble() : b.toDouble(),
);
},
category: DartBlockNativeFunctionCategory.math,
type: DartBlockNativeFunctionType.max,
description: 'Get the maximum of two numbers.',
);