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