Implemented new custom sort and separated the sorted view for each car
This commit is contained in:
22
lib/feature/delivery/util.dart
Normal file
22
lib/feature/delivery/util.dart
Normal file
@ -0,0 +1,22 @@
|
||||
List<String> reorderList(List<String> old, int oldIndex, int newIndex) {
|
||||
List<String> tmp = [...old];
|
||||
|
||||
int newIndexCalc = newIndex - 1;
|
||||
|
||||
if (newIndex < oldIndex) {
|
||||
newIndexCalc = newIndex;
|
||||
}
|
||||
|
||||
if (newIndex == old.length) {
|
||||
newIndexCalc = old.length - 1;
|
||||
}
|
||||
|
||||
if (newIndex == 0) {
|
||||
newIndexCalc = 0;
|
||||
}
|
||||
|
||||
String oldItem = tmp.removeAt(oldIndex);
|
||||
tmp.insert(newIndexCalc, oldItem);
|
||||
|
||||
return tmp;
|
||||
}
|
||||
Reference in New Issue
Block a user