Testing an accessibility announcement in Flutter

What does SemanticsService do?

SemanticsService manages the communication between Flutter and the OS using Platform Channels.

Sample Code

A code sample using SemanticsService.announce

Semantics Announcement Demo

Turn on your volume to hear the announcement

Testing Semantic Announcement in Flutter

To test this if we’re making the correct announcement we need a way to intercept the announcement.

Introducing semantic_announcement_tester

I’ve published a tiny package called semantic_announcement_tester, which makes testing Semantic announcements made using SemanticsService.announce dead simple by providing some matchers.


  1. Create an object for MockSemanticAnnouncements in your widget test.
  2. Write the test code as usual.
  3. Use one of the matchers: hasOneAnnouncement, hasNAnnouncements or hasZeroAnnouncements to assert.

Sample Tests

To test one announcement:




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store