flutter_lan_sync library

flutter_lan_sync — offline peer-to-peer data sync over Wi-Fi.

Quick start:

// 1. Initialise once at startup (before runApp)
await LanSync.initialize(
  LanSyncConfig(
    appSecret: 'my-app-secret',
    packageName: 'com.example.myapp',
    deviceName: 'Dr Smith',
    facilityId: 'facility-123',
    instanceType: 'production',
    requireScopedPeers: true,
    onReceive: (items) async {
      await db.saveAll(items.map(MyModel.fromJson).toList());
    },
  ),
);

// 2. Wrap your MaterialApp for global incoming-transfer alerts
LanTransferListener(navigatorKey: navigatorKey, child: MyApp())

// 3. Open the sync screen with the items you want to offer
LanSyncScreen(
  items: records.map((r) => LanSyncItem(
    id: r.id,
    displayName: r.fullName,
    data: r.toJson(),
  )).toList(),
)

Classes

IncomingTransferSheet
Bottom sheet shown when an incoming transfer arrives for approval.
LanDevice
LanPeer
A discovered LAN-sync peer.
LanPendingTransfer
LanSync
Entry point for the flutter_lan_sync package.
LanSyncConfig
Configuration passed to LanSync.initialize.
LanSyncItem
A single item to transfer over LAN sync.
LanSyncScreen
Full LAN sync management screen with Devices, Manage, and History tabs.
LanSyncService
Orchestrates the full LAN sync lifecycle.
LanSyncTheme
Internal color palette for the package UI. All UI widgets use these instead of host-app color constants — kept as a separate palette rather than importing host-app color constants, so the package stays usable across applications. Host apps can override any of these colors through LanSyncTheme.
LanTransferListener
Wrap your app tree with this widget to receive incoming transfer sheets over any screen — not only when LanSyncScreen is open.
LanTransferLog
MdnsDiscovery
Listens for MdnsAdvertiser beacons and returns discovered peers.
SyncStatus

Constants

lanSyncProtocolVersion → const int
Current wire/storage compatibility version for scoped LAN peers.