@@ -355,5 +355,57 @@ void main() {
355
355
..value.equals (0.0 )
356
356
..status.equals (AnimationStatus .completed);
357
357
});
358
+
359
+ testWidgets ('animation state persistence' , (WidgetTester tester) async {
360
+ // Check that _UnreadMarker maintains its in-progress animation
361
+ // as the number of items changes in MessageList. See
362
+ // findChildIndexCallback on StickyHeaderListView.builder for
363
+ //
364
+ final message = eg.streamMessage (flags: []);
365
+ await setupMessageListPage (tester, messages: [message]);
366
+ check (getAnimation (tester, message.id))
367
+ ..value.equals (1.0 )
368
+ ..status.equals (AnimationStatus .dismissed);
369
+
370
+ store.handleEvent (UpdateMessageFlagsAddEvent (
371
+ id: 0 ,
372
+ flag: MessageFlag .read,
373
+ messages: [message.id],
374
+ all: false ,
375
+ ));
376
+ await tester.pump (); // process handleEvent
377
+ check (getAnimation (tester, message.id))
378
+ ..value.equals (1.0 )
379
+ ..status.equals (AnimationStatus .forward);
380
+
381
+ // run animation partially
382
+ await tester.pump (const Duration (milliseconds: 30 ));
383
+ check (getAnimation (tester, message.id))
384
+ ..value.isGreaterThan (0.0 )
385
+ ..value.isLessThan (1.0 )
386
+ ..status.equals (AnimationStatus .forward);
387
+
388
+ // introduce new message
389
+ final newMessage = eg.streamMessage (flags: [MessageFlag .read]);
390
+ store.handleEvent (MessageEvent (id: 0 , message: newMessage));
391
+ await tester.pump (); // process handleEvent
392
+ check (find.byType (MessageItem ).evaluate ()).length.equals (2 );
393
+ check (getAnimation (tester, message.id))
394
+ ..value.isGreaterThan (0.0 )
395
+ ..value.isLessThan (1.0 )
396
+ ..status.equals (AnimationStatus .forward);
397
+ check (getAnimation (tester, newMessage.id))
398
+ ..value.equals (0.0 )
399
+ ..status.equals (AnimationStatus .dismissed);
400
+
401
+ final frames = await tester.pumpAndSettle ();
402
+ check (frames).isGreaterThan (1 );
403
+ check (getAnimation (tester, message.id))
404
+ ..value.equals (0.0 )
405
+ ..status.equals (AnimationStatus .completed);
406
+ check (getAnimation (tester, newMessage.id))
407
+ ..value.equals (0.0 )
408
+ ..status.equals (AnimationStatus .dismissed);
409
+ });
358
410
});
359
411
}
0 commit comments