FloatyProxyHost constructor

FloatyProxyHost()

Main-app-side proxy host that registers service providers.

The overlay can call services registered here via FloatyProxyClient. Each service exposes named methods that accept parameters and return results — all serialized as JSON through the shared data channel.

final host = FloatyProxyHost();

host.register('location', (method, params) async {
  if (method == 'getCurrentPosition') {
    final pos = await Geolocator.getCurrentPosition();
    return {'lat': pos.latitude, 'lng': pos.longitude};
  }
  return null;
});

Implementation

FloatyProxyHost() {
  FloatyChannel.registerHandler(_prefix, _onMessage);
  FloatyChannel.ensureListening();
}