getValue<T> method
dynamic
getValue<
T>( - BuildContext context,
- T ifTrue(),
- T ifFalse(),
- int loop,
- dynamic inputValue,
)
Implementation
dynamic getValue<T>(
BuildContext context,
T Function() ifTrue,
T Function() ifFalse,
int loop,
dynamic inputValue,
) {
final conditions = <bool>[];
conditions.add(
_getValue(
context,
() => true,
() => false,
loop,
inputValue,
),
);
for (final e in subConditions) {
conditions.add(
e._getValue(
context,
() => true,
() => false,
loop,
inputValue,
),
);
}
if (conditions.isEmpty) {
return ifFalse(); // or ifTrue(), depending on your default behavior
}
bool result = conditions.first;
for (var i = 0; i < subConditions.length; i++) {
final operator = subConditions[i].operator;
if (operator == SubConditionOperator.and) {
result = and(result, conditions[i + 1]);
} else if (operator == SubConditionOperator.or) {
result = or(result, conditions[i + 1]);
}
}
if (result) {
return ifTrue();
} else {
return ifFalse();
}
}