@@ -253,6 +253,32 @@ void main() {
253253 expect (findState (const Key ('A' )).checked, true );
254254 });
255255
256+ testWidgets ('Preserves child elements when rebuilt' , (WidgetTester tester) async {
257+ Widget build () {
258+ return MaterialApp (
259+ home: Directionality (
260+ textDirection: TextDirection .ltr,
261+ child: SizedBox (
262+ width: 100 ,
263+ height: 100 ,
264+ child: ReorderableListView (
265+ children: [
266+ SizedBox (key: Key ('key' ), width: 10 , height: 10 ),
267+ ],
268+ onReorder: (_, __) {},
269+ ),
270+ ),
271+ ),
272+ );
273+ }
274+
275+ await tester.pumpWidget (build ());
276+ var e0 = tester.element (find.byKey (Key ('key' )));
277+ await tester.pumpWidget (build ());
278+ var e1 = tester.element (find.byKey (Key ('key' )));
279+ expect (e0, equals (e1));
280+ });
281+
256282 testWidgets ('Uses the PrimaryScrollController when available' , (WidgetTester tester) async {
257283 final ScrollController primary = ScrollController ();
258284 final Widget reorderableList = ReorderableListView (
@@ -771,6 +797,32 @@ void main() {
771797 expect (findState (const Key ('A' )).checked, true );
772798 });
773799
800+ testWidgets ('Preserves child elements when rebuilt' , (WidgetTester tester) async {
801+ Widget build () {
802+ return MaterialApp (
803+ home: Directionality (
804+ textDirection: TextDirection .ltr,
805+ child: SizedBox (
806+ width: 100 ,
807+ height: 100 ,
808+ child: ReorderableListView (
809+ children: [
810+ SizedBox (key: Key ('key' ), width: 10 , height: 10 ),
811+ ],
812+ onReorder: (_, __) {},
813+ ),
814+ ),
815+ ),
816+ );
817+ }
818+
819+ await tester.pumpWidget (build ());
820+ var e0 = tester.element (find.byKey (Key ('key' )));
821+ await tester.pumpWidget (build ());
822+ var e1 = tester.element (find.byKey (Key ('key' )));
823+ expect (e0, equals (e1));
824+ });
825+
774826 group ('Accessibility (a11y/Semantics)' , () {
775827 Map <CustomSemanticsAction , VoidCallback > getSemanticsActions (int index) {
776828 final Semantics semantics = find.ancestor (
0 commit comments