@@ -302,9 +302,9 @@ void main() {
302
302
});
303
303
304
304
group ('_UnreadMarker animations' , () {
305
- Animation getAnimation (WidgetTester tester) {
305
+ Animation getAnimation (WidgetTester tester, int messageId ) {
306
306
final widget = tester.widget <FadeTransition >(find.descendant (
307
- of: find.byType ( MessageItem ),
307
+ of: find.byKey ( ValueKey (messageId) ),
308
308
matching: find.byType (FadeTransition )));
309
309
return widget.opacity;
310
310
}
@@ -313,23 +313,23 @@ void main() {
313
313
final message = eg.streamMessage (flags: [MessageFlag .read]);
314
314
await setupMessageListPage (tester, messages: [message]);
315
315
316
- check (getAnimation (tester).value).equals (0 );
316
+ check (getAnimation (tester, message.id ).value).equals (0 );
317
317
318
318
store.handleEvent (eg.updateMessageFlagsRemoveEvent (
319
319
MessageFlag .read, [message]));
320
320
await tester.pump (); // process handleEvent
321
- check (getAnimation (tester).status).equals (AnimationStatus .forward);
321
+ check (getAnimation (tester, message.id ).status).equals (AnimationStatus .forward);
322
322
323
323
await tester.pumpAndSettle ();
324
324
325
- check (getAnimation (tester).value).equals (1.0 );
325
+ check (getAnimation (tester, message.id ).value).equals (1.0 );
326
326
});
327
327
328
328
testWidgets ('from unread to read' , (WidgetTester tester) async {
329
329
final message = eg.streamMessage (flags: []);
330
330
await setupMessageListPage (tester, messages: [message]);
331
331
332
- check (getAnimation (tester).value).equals (1.0 );
332
+ check (getAnimation (tester, message.id ).value).equals (1.0 );
333
333
334
334
store.handleEvent (UpdateMessageFlagsAddEvent (
335
335
id: 1 ,
@@ -338,25 +338,16 @@ void main() {
338
338
all: false ,
339
339
));
340
340
await tester.pump (); // process handleEvent
341
- check (getAnimation (tester).status).equals (AnimationStatus .forward);
341
+ check (getAnimation (tester, message.id ).status).equals (AnimationStatus .forward);
342
342
343
343
await tester.pumpAndSettle ();
344
344
345
- check (getAnimation (tester).value).equals (0 );
345
+ check (getAnimation (tester, message.id ).value).equals (0 );
346
346
});
347
347
348
348
testWidgets ('animation state persistence' , (WidgetTester tester) async {
349
349
// Check that _UnreadMarker maintains its in-progress animation
350
350
// 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
-
360
351
final message = eg.streamMessage (flags: []);
361
352
await setupMessageListPage (tester, messages: [message]);
362
353
0 commit comments