@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
33import '../extensions/control.dart' ;
44import '../models/control.dart' ;
55import '../utils/edge_insets.dart' ;
6+ import '../utils/keys.dart' ;
67import '../utils/misc.dart' ;
78import '../utils/mouse.dart' ;
89import '../utils/numbers.dart' ;
@@ -62,14 +63,12 @@ class _ListViewControlState extends State<ReorderableListViewControl> {
6263 var anchor = widget.control.getDouble ("anchor" , 0.0 )! ;
6364 var clipBehavior =
6465 widget.control.getClipBehavior ("clip_behavior" , Clip .hardEdge)! ;
65- var controls = _controls
66- .map ((child) => ControlWidget (key: ValueKey (child.id), control: child))
67- .toList ();
6866 var scrollDirection = horizontal ? Axis .horizontal : Axis .vertical;
6967 var header = widget.control.buildWidget ("header" );
7068 var footer = widget.control.buildWidget ("footer" );
71- var prototypeItem =
72- firstItemPrototype && controls.isNotEmpty ? controls[0 ] : null ;
69+ var prototypeItem = firstItemPrototype && _controls.isNotEmpty
70+ ? ControlWidget (key: ValueKey (_controls[0 ].id), control: _controls[0 ])
71+ : null ;
7372 var autoScrollerVelocityScalar =
7473 widget.control.getDouble ("auto_scroller_velocity_scalar" );
7574 var mouseCursor = widget.control.getMouseCursor ("mouse_cursor" );
@@ -110,7 +109,7 @@ class _ListViewControlState extends State<ReorderableListViewControl> {
110109 scrollDirection: scrollDirection,
111110 shrinkWrap: shrinkWrap,
112111 padding: padding,
113- itemCount: controls .length,
112+ itemCount: _controls .length,
114113 itemExtent: itemExtent,
115114 mouseCursor: mouseCursor,
116115 anchor: anchor,
@@ -122,7 +121,11 @@ class _ListViewControlState extends State<ReorderableListViewControl> {
122121 onReorderEnd: onReorderEnd,
123122 onReorderStart: onReorderStart,
124123 itemBuilder: (context, index) {
125- return controls[index];
124+ return ControlWidget (
125+ key: ValueKey (_controls[index].getKey ("key" )? .value ??
126+ _controls[index].id),
127+ control: _controls[index],
128+ );
126129 },
127130 )
128131 : ReorderableListView (
@@ -144,7 +147,12 @@ class _ListViewControlState extends State<ReorderableListViewControl> {
144147 onReorder: onReorder,
145148 onReorderEnd: onReorderEnd,
146149 onReorderStart: onReorderStart,
147- children: controls,
150+ children: _controls
151+ .map ((item) => ControlWidget (
152+ key: ValueKey (item.getKey ("key" )? .value ?? item.id),
153+ control: item,
154+ ))
155+ .toList (),
148156 );
149157
150158 child = ScrollableControl (
0 commit comments