This PR is inspired by [the suggestion made here](https://github.com/flutter/engine/pull/47961#discussion_r1406581284).