error

>

message

);

You should now be able to run the application on Linux.
If your device doesn’t have a battery,
it displays ‘Battery level not available’.

Typesafe platform channels using Pigeon

The previous example uses MethodChannel
to communicate between the host and client,
which isn’t typesafe. Calling and receiving
messages depends on the host and client declaring
the same arguments and datatypes in order for messages to work.
You can use the Pigeon package as
an alternative to MethodChannel
to generate code that sends messages in a
structured, typesafe manner.

With Pigeon, the messaging protocol is defined
in a subset of Dart that then generates messaging
code for Android or iOS. You can find a more complete
example and more information on the pigeon
page on pub.dev.