FlutterArtist Manual Sorting ReorderableListView
In programming, "Manual sorting" refers to the process of organizing data elements in a specific order defined by the user, rather than relying on built-in sorting functions or automated algorithms. Instead, the application allows users to rearrange elements directly through Drag & Drop interactions.
Demo49a
In this article, we will explore how to use ReorderableListView, a standard Flutter widget, in conjunction with the FlutterArtist ecosystem to implement this functionality.

- Download FlutterArtist Demo
See also similar examples, manual sorting with SortableGridView:
2. Currency49aShelf
In FlutterArtist, to enable manual reordering of ITEM(s) on the client-side, the prerequisite is setting the sorting strategy in BlockConfig to SortStrategy.manual.
No ADS
currency49a_shelf.dart
class Currency49aShelf extends Shelf {
@override
ShelfStructure defineShelfStructure() {
return ShelfStructure(
filterModels: {},
blocks: [
Currency49aBlock(
name: Currency49aBlock.blkName,
description: null,
config: BlockConfig(clientSideSortStrategy: SortStrategy.manual),
filterModelName: null,
formModel: null,
childBlocks: [],
),
],
);
}
Currency49aBlock findCurrency49aBlock() {
return findBlock(Currency49aBlock.blkName) as Currency49aBlock;
}
}See more automatic sorting examples based on SortModel:
3. Currency49aReorderableListItemsView
We use the .builder() constructor of ReorderableListView to optimize performance for long lists.
Currency49aReorderableListItemsView (**)
Widget buildContent(BuildContext context) {
List<CurrencyInfo> currencyInfos = block.items;
//
return ReorderableListView.builder(
padding: EdgeInsets.all(5.0),
itemCount: currencyInfos.length,
onReorder: _onReorder,
itemBuilder: (context, index) {
CurrencyInfo currencyInfo = currencyInfos[index];
return Currency49aListItem(
key: Key("Currency-${currencyInfo.id}"),
currencyInfo: currencyInfo,
selected: block.isCurrentItem(currencyInfo),
onCurrencyPressed: _onCurrencyPressed,
);
},
);
}
...Handling the Reorder Event
When a user drops an item into a new position, the onReorder event is triggered. Here, we need to update the item's position within the Block's data list.
onReorder
void _onReorder(int oldIndex, int newIndex) {
int newIdx = newIndex > oldIndex ? newIndex - 1 : newIndex;
block.moveItemByIndexPosition(
oldIndexPosition: oldIndex,
newIndexPosition: newIdx,
);
}No ADS
FlutterArtist
- Basic concepts in Flutter Artist
- FlutterArtist Block ex1
- FlutterArtist Filter Example
- FlutterArtist FilterModel MultiOptFilterCriterion ex1
- FlutterArtist FilterInput Example 1
- FlutterArtist Form ex1
- The idea of designing filter models in FlutterArtist
- FlutterArtist FormModel.patchFormFields() Ex1
- FlutterArtist BlockQuickItemUpdateAction Example
- FlutterArtist BlockNumberPagination Ex1
- FlutterArtist GridView Infinite Scroll Example
- FlutterArtist BlockQuickMultiItemCreationAction Example
- FlutterArtist ListView Infinite Scroll Pagination Example
- FlutterArtist Pagination
- FlutterArtist Sort DropdownSortPanel Example
- FlutterArtist Dio
- FlutterArtist BlockBackendAction Example
- FlutterArtist BackgroundWebDownloadAction Example
- FlutterArtist StorageBackendAction ex1
- FlutterArtist Block External Shelf Event Example
- FlutterArtist Filter FormBuilderMultiDropDown Ex1
- FlutterArtist Master-detail Blocks ex1
- FlutterArtist Scalar ex1
- FlutterArtist Pagination Davi table Infinite Scroll Ex1
- FlutterArtist Filter Tree FormBuilderField ex1
- FlutterArtist Filter FormBuilderRadioGroup ex1
- FlutterArtist Form Parent-child MultiOptFormProp ex1
- FlutterArtist Manual Sorting ReorderableGridView Example
- FlutterArtist Manual Sorting ReorderableListView
- FlutterArtist Scalar External Shelf Event Example
- FlutterArtist Code Flow Viewer
- FlutterArtist Log Viewer
- FlutterArtist config
- FlutterArtist StorageStructure
- FlutterArtist Debug Storage Viewer
- FlutterArtist DebugMenu
- FlutterArtist Debug UI Components Viewer
- FlutterArtist Debug Shelf Structure Viewer
- FlutterArtist Context Provider Views
- FlutterArtist FilterModelStructure ex1
- FlutterArtist FilterModelStructure ex2
- FlutterArtist FilterModelStructure ex3
- FlutterArtist Internal Shelf Event ex1
- FlutterArtist Deferring External Shelf Events Example
- FlutterArtist DropdownSortPanel
Show More

