reorderRule method

void reorderRule(
  1. int from,
  2. int to
)

Reorder rule.

Implementation

void reorderRule(int from, int to) {
  final value = selected;
  if (value == null || from == to || from < 0 || to < 0 || from >= value.responseRules.length || to >= value.responseRules.length) {
    return;
  }
  final rules = List<NmResponseRule>.of(value.responseRules);
  final item = rules.removeAt(from);
  rules.insert(to, item);
  _update(value.copyWith(responseRules: [for (var i = 0; i < rules.length; i++) rules[i].copyWith(priority: i)]));
}