flutter_watch_link library

WatchConnectivity for Flutter companion apps — one Dart API that works unchanged on both the iPhone and the Apple Watch.

WatchConnectivity is the only transport Apple provides between a phone and its watch. This package puts both halves of a WCSession behind a single WatchLink, over dart:ffi on both platforms — the phone and the watch compile the same native source, so there is one implementation rather than two to keep in step. Inbound payloads are pushed into Dart from the delegate queue; neither side polls.

import 'package:flutter_watch_link/flutter_watch_link.dart';

final WatchLink link = WatchLink.instance;
await link.activate();
link.messages.listen((WatchLinkMessage m) => merge(m.payload, m.tier));
await link.sendMessage(<String, Object?>{'checked': 'milk'});

The three send methods map onto WatchConnectivity's three transports, which differ in latency, ordering, and whether delivery survives the counterpart app closing. WatchLink documents how to choose between them.

Classes

Registers the watchOS implementation.
One WatchConnectivity session, with the same API on both devices.
WatchLinkBackend
The native half of a WatchLink, behind an interface so tests can substitute a fake without a native binary present.
WatchLinkFfiBackend
The session backend — unavailable on web.
WatchLinkFfiBindings
Raw FFI bindings — unavailable on web.
WatchLinkFile
A file that arrived from the counterpart device.
WatchLinkMessage
A payload that arrived from the counterpart device, tagged with the transport that carried it.
WatchLinkState
A snapshot of the session's connection state.

Enums

WatchLinkTier
Which WatchConnectivity transport delivered a payload.

Typedefs

SignalNative = void Function(int)
Signature of the native→Dart wake signal.
WatchLinkResponder = Future<void> Function(Map<String, Object?> reply)
Answers a message whose sender is waiting for a reply.

Exceptions / Errors

WatchLinkException
Thrown when the underlying WCSession refuses an operation.