updateOrderBrackets method
void
updateOrderBrackets(})
Updates or attaches Take Profit and/or Stop Loss brackets to an order.
Implementation
void updateOrderBrackets(
String orderId, {
double? takeProfitPrice,
double? stopLossPrice,
bool clearTakeProfit = false,
bool clearStopLoss = false,
}) {
final index = _orders.indexWhere((o) => o.id == orderId);
if (index >= 0) {
final existing = _orders[index];
final updated = existing.copyWith(
takeProfitPrice: clearTakeProfit
? () => null
: (takeProfitPrice != null ? () => takeProfitPrice : null),
stopLossPrice: clearStopLoss
? () => null
: (stopLossPrice != null ? () => stopLossPrice : null),
);
_orders[index] = updated;
onOrderModified?.call(updated);
notifyListeners();
}
}