flutter ReorderableListView 포커스 상태에서 reorder 시 예외처리

ENOOSOFT·2022년 7월 9일
0

flutter ReorderableListView 안에 TextFormField 같이 포커스노드를 지원하는 위젯을 사용하는 경우,
포커스 상태에서 reorder(Long press) 시 아래와 같은 오류가 발생한다.

LeaderLayer anchor must come before FollowerLayer in paint order, but the reverse was true.

TextFormField(FollowerLayer)가 paint 중이라서 ListTile(LeaderLayer) 을 그릴 수 없다는 말로 이해했다.

이런 경우 ReorderableListView 에서 onReorderStart 할 때 새로 포커스하면 해결할 수 있다.

FocusScope.of(context).requestFocus(new FocusNode());

코드 예시)

...
ReorderableListView(
	padding: EdgeInsets.zero,
	primary: false,
	shrinkWrap: true,
	scrollDirection: Axis.vertical,
	onReorderStart: (_) {
		log('reorder start...');
		FocusScope.of(context).requestFocus(new FocusNode());
	},
	onReorder: (int oldIndex, int newIndex) {
...
profile
Tiny coder

1개의 댓글

comment-user-thumbnail
2023년 7월 3일

바로 찾았네요~ 감사합니다!

답글 달기