moveElementBackward<T> function

int moveElementBackward<T>(
  1. List<T> list,
  2. T element
)

Implementation

int moveElementBackward<T>(List<T> list, T element) {
  int i = list.indexOf(element);
  if (i != -1 && i < list.length - 1) {
    final tmp = list[i + 1];
    list[i + 1] = list[i];
    list[i] = tmp;
    return i + 1;
  }
  return i;
}