Part of https://github.com/flutter/flutter/issues/47161
Fixes https://github.com/flutter/flutter/issues/116262