@@ -22,7 +22,7 @@ class _RecordingNotificationService extends NotificationService {
2222 /// Value returned from [show] — set to `false` to simulate a notification
2323 /// that could not be displayed (no permission / dismissed / platform throw).
2424 final bool result;
25- final List <({String ? category, String ? payload})> shown = [];
25+ final List <({int id, String ? category, String ? payload})> shown = [];
2626
2727 @override
2828 Future <bool > show ({
@@ -32,7 +32,7 @@ class _RecordingNotificationService extends NotificationService {
3232 String ? payload,
3333 String ? category,
3434 }) async {
35- shown.add ((category: category, payload: payload));
35+ shown.add ((id : id, category: category, payload: payload));
3636 return result;
3737 }
3838}
@@ -362,4 +362,43 @@ void main() {
362362 expect (find.text ('Approve' ), findsNothing);
363363 },
364364 );
365+
366+ testWidgets (
367+ 'notification id is deterministic per requestId and differs across requests' ,
368+ (tester) async {
369+ final (transport, notifications, _) = await pumpHandler (tester);
370+ tester.binding.handleAppLifecycleStateChanged (AppLifecycleState .paused);
371+ await tester.pump ();
372+
373+ Envelope confirm (String id) => Envelope (
374+ t: MsgType .srvRequest,
375+ id: id,
376+ body: {
377+ 'kind' : 'confirmAction' ,
378+ 'action' : 'rm -rf build/' ,
379+ 'sessionId' : 's1' ,
380+ },
381+ );
382+
383+ // Same env.id dispatched twice → same notification id (OS dedup).
384+ transport.emit (confirm ('req-same' ));
385+ await tester.pump ();
386+ await tester.pump ();
387+ transport.emit (confirm ('req-same' ));
388+ await tester.pump ();
389+ await tester.pump ();
390+
391+ // Different env.id → different notification id.
392+ transport.emit (confirm ('req-other' ));
393+ await tester.pump ();
394+ await tester.pump ();
395+
396+ expect (notifications.shown, hasLength (3 ));
397+ final firstId = notifications.shown[0 ].id;
398+ final secondId = notifications.shown[1 ].id;
399+ final otherId = notifications.shown[2 ].id;
400+ expect (secondId, firstId);
401+ expect (otherId, isNot (firstId));
402+ },
403+ );
365404}
0 commit comments