Repository navigation
Architecture
Duck Share is a monorepo: a Flutter app on top of a Rust implementation of the LocalSend protocol.
| Path | What it is |
|---|---|
app/ |
The Flutter app (localsend_app): UI, providers, persistence, platform channels |
packages/localsend_isolates/ |
Dart isolate layer and flutter_rust_bridge bindings to Rust |
packages/core/ |
Rust crate localsend: protocol, HTTP server/client, crypto, WebRTC |
packages/typed_isolates/ |
Small package wrapping Dart Isolate with typed channels |
server/ |
WebSocket signaling server for WebRTC |
cli/ |
Rust CLI (localsend-cli) |
site/ |
Website and privacy policy (GitHub Pages) |
support/branding/ |
Logo source and icon export script |
support/scripts/ |
Release and packaging scripts |
fastlane/metadata/android/ |
Store description and screenshots |
Dependency direction: app → localsend_isolates → (typed_isolates, Rust plugin crate → localsend core).
- State management: Refena (
refena_flutter); providers inapp/lib/provider/. - Bootstrap:
app/lib/config/init.dart. - Networking runs in child isolates, never on the main isolate.
- The HTTPS server and client are written in Rust (
packages/core/src/http/). Only one upload session is active at a time. The app decides whether to accept a request; there is no auto-accept in the core. - Discovery uses UDP multicast (
packages/core/src/multicast/), with responses sent back over HTTP.
NFC is only the handshake; the transfer is the normal pinned-TLS register and upload session.
Native code is in app/android/app/src/main/kotlin/org/localsend/localsend_app/:
| File | Role |
|---|---|
TapShareHceService.kt |
Receiver. Host card emulation for AID F04C4F43414C53454E44. Answers SELECT, then an exchange command (CLA 0x80, INS 0x01) carrying the sender's fingerprint, with the identity JSON {v, a, f, p, h, i} + 9000. Records the tap and wakes the app. |
TapShareReader.kt |
Sender. NFC reader mode. Re-claims reader mode every second because other system components can clear it. |
TapShareState.kt |
Native source of truth: SharedPreferences file tap_share (enabled, auto_accept, identity), the single-use tap record for auto-accept (30 s, unlocked only), pending share sheet sends. Disabling also disables the HCE component. |
TapShareWakeService.kt |
Foreground service (90 s) that boots the Flutter engine headless when a tap arrives with no UI visible |
TapShareActivity.kt |
Share target: the native "Hold near another phone" sheet |
TapShareChannel.kt |
Method channel methods that work without an activity (tap share, file descriptors, notifications) |
TapShareTileService.kt |
Quick Settings tile |
TapShareFeedback.kt |
Vibration |
LocalSendApplication.kt |
Owns the single Flutter engine, so closing the UI does not stop the server |
ReceivedFileResolver.kt |
Opens a received file from its notification |
Resources: res/xml/tap_share_apdu_service.xml (AID registration), res/layout/tap_share_sheet.xml (share sheet).
Dart side:
| File | Role |
|---|---|
app/lib/provider/tap_share_provider.dart |
Tap share state, pushes identity and sender to native, TapShareSendAction, isRecentlyTappedSender
|
app/lib/model/tap_share_identity.dart |
Identity encoding; isLanAddress (only private, link-local and CGNAT addresses are dialed) |
app/lib/provider/network/server/controller/receive_controller.dart |
Auto-accepts a recently tapped sender, posts notifications |
app/lib/widget/nfc_spot_guide.dart |
"Where to touch" guide (NfcAdapter.getNfcAntennaInfo on Android 14+, estimate otherwise) |
app/lib/pages/onboarding_page.dart |
First-start onboarding |
LocalSendApplication owns the Flutter engine and MainActivity attaches to it, so closing the app does not stop the server. A tap while no UI is visible starts TapShareWakeService, which boots the engine with --headless. Headless code shows notifications instead of UI. Locked taps never wake the app.
-
app/lib/provider/device_trust_provider.dart: blocked devices, stored underls_blocked_devices. Favorites are the trusted devices. - The PIN bypass for trusted devices is in Rust (
set_trusted_fingerprints, checked inv2::prepare_upload).
Internal identifiers are kept from LocalSend to keep upstream merges small: Dart package localsend_app, Kotlin package org.localsend.localsend_app, method channel org.localsend.localsend_app/localsend, settings keys ls_*, crate names.
More detail: AGENTS.md in the repository.
Duck Share · Issues · Apache License 2.0 · Based on LocalSend by Tien Do Nam and contributors