[Flutter] ReorderableListView - 위치 변경 ListView

박철영·2021년 7월 27일
0
post-thumbnail
ReorderableListView(
  children: <Widget>[
    for (int index = 0; index < _items.length; index++)
      ListTile(
        key: Key('$index'),
        title: Container(
          padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
            color: Colors.white,
            child: Text('Item ${_items[index]}')
        ),
      ),
  ],
  onReorder: (int oldIndex, int newIndex) {
    setState(() {
      if (oldIndex < newIndex) {
        newIndex -= 1;
      }
      final int item = _items.removeAt(oldIndex);
      _items.insert(newIndex, item);
    });
  },

),

1개의 댓글

comment-user-thumbnail
2023년 5월 10일

tkx ur solution

답글 달기