reorder method

Future<void> reorder(
  1. String id,
  2. int from,
  3. int to
)

Implementation

Future<void> reorder(String id, int from, int to) async {
  final int index = _playlists.indexWhere((UPlaylist p) => p.id == id);
  if (index < 0) return;
  final List<String> next = List<String>.of(_playlists[index].paths);
  if (from < 0 || from >= next.length || to < 0 || to >= next.length) return;
  next.insert(to, next.removeAt(from));
  _playlists[index] = _playlists[index].copyWith(paths: next);
  await _persist();
}