<p dir="auto">In <a href="https://github.com/flutter/engine/blob/master/lib/ui/window.dart#L219"><code class="notranslate">ui.window.sendPlatformMessage</code></a>, we should have a way to pass an error callback.</p>
<p dir="auto">Once we had that, in <a href="https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/services/platform_messages.dart#L49"><code class="notranslate">PlatformMessages._sendPlatformMessage</code></a>, we could wire it up so as to call <code class="notranslate">Completer.completeError()</code></p>
<p dir="auto"><a href="https://docs.flutter.io/flutter/services/HostMessages-class.html" rel="nofollow">https://docs.flutter.io/flutter/services/HostMessages-class.html</a></p>
<p dir="auto">We can use the <a href="https://www.dartlang.org/articles/libraries/futures-and-error-handling" rel="nofollow">Futures error handling</a> API for this. Throwing a native exception crashes the app (on Android), so it's not a good way of handling errors.</p>
<p dir="auto">The HostMessages API should complete with an error if you send a message to native code and a handler isn't installed. (Right now on Android it completes with null and on iOS it never completes.)</p>