@@ -302,9 +302,9 @@ void main() {
302302 });
303303
304304 group ('_UnreadMarker animations' , () {
305- Animation getAnimation (WidgetTester tester) {
305+ Animation getAnimation (WidgetTester tester, int messageId ) {
306306 final widget = tester.widget <FadeTransition >(find.descendant (
307- of: find.byType ( MessageItem ),
307+ of: find.byKey ( ValueKey (messageId) ),
308308 matching: find.byType (FadeTransition )));
309309 return widget.opacity;
310310 }
@@ -313,23 +313,23 @@ void main() {
313313 final message = eg.streamMessage (flags: [MessageFlag .read]);
314314 await setupMessageListPage (tester, messages: [message]);
315315
316- check (getAnimation (tester).value).equals (0 );
316+ check (getAnimation (tester, message.id ).value).equals (0 );
317317
318318 store.handleEvent (eg.updateMessageFlagsRemoveEvent (
319319 MessageFlag .read, [message]));
320320 await tester.pump (); // process handleEvent
321- check (getAnimation (tester).status).equals (AnimationStatus .forward);
321+ check (getAnimation (tester, message.id ).status).equals (AnimationStatus .forward);
322322
323323 await tester.pumpAndSettle ();
324324
325- check (getAnimation (tester).value).equals (1.0 );
325+ check (getAnimation (tester, message.id ).value).equals (1.0 );
326326 });
327327
328328 testWidgets ('from unread to read' , (WidgetTester tester) async {
329329 final message = eg.streamMessage (flags: []);
330330 await setupMessageListPage (tester, messages: [message]);
331331
332- check (getAnimation (tester).value).equals (1.0 );
332+ check (getAnimation (tester, message.id ).value).equals (1.0 );
333333
334334 store.handleEvent (UpdateMessageFlagsAddEvent (
335335 id: 1 ,
@@ -338,25 +338,16 @@ void main() {
338338 all: false ,
339339 ));
340340 await tester.pump (); // process handleEvent
341- check (getAnimation (tester).status).equals (AnimationStatus .forward);
341+ check (getAnimation (tester, message.id ).status).equals (AnimationStatus .forward);
342342
343343 await tester.pumpAndSettle ();
344344
345- check (getAnimation (tester).value).equals (0 );
345+ check (getAnimation (tester, message.id ).value).equals (0 );
346346 });
347347
348348 testWidgets ('animation state persistence' , (WidgetTester tester) async {
349349 // Check that _UnreadMarker maintains its in-progress animation
350350 // as the number of items change in MessageList.
351-
352- // TODO: pull this out into group
353- Animation getAnimation (WidgetTester tester, int messageId) {
354- final widget = tester.widget <FadeTransition >(find.descendant (
355- of: find.byKey (ValueKey (messageId)),
356- matching: find.byType (FadeTransition )));
357- return widget.opacity;
358- }
359-
360351 final message = eg.streamMessage (flags: []);
361352 await setupMessageListPage (tester, messages: [message]);
362353
0 commit comments