floaty_chatheads 1.5.0
floaty_chatheads: ^1.5.0 copied to clipboard
Floating chathead plugin for Android & iOS with draggable bubbles, expandable content panels, theming, snap-to-edge physics, and bidirectional app-overlay messaging.
Changelog #
1.5.0 #
โจ Widget-Based Icons #
-
Any Flutter widget as the chathead icon. Pass
iconWidgettoshowChatHead()and the widget is rendered to a PNG image via an offscreen pipeline (separateRenderView/PipelineOwner/BuildOwner-- does not block the main widget tree).await FloatyChatheads.showChatHead( entryPoint: 'overlayMain', iconWidget: const CircleAvatar(child: Text('JD')), ); -
Animated widget icons. Pass
iconBuilder(receives a 0.0 -- 1.0 animation value) and setanimateIcon: true. Frames are rendered at configurable FPS and pushed to the native layer as raw RGBA bytes. Control playback withstartIconAnimation()/stopIconAnimation().await FloatyChatheads.showChatHead( entryPoint: 'overlayMain', iconBuilder: (v) => Transform.rotate( angle: v * 2 * 3.14159, child: const Icon(Icons.sync, size: 50), ), animateIcon: true, ); -
Widget-based close icons.
closeIconWidgetandcloseBackgroundWidgetlet you replace the default close target with any Flutter widget. On Android, widget-rendered close icons are scaled to the full close-target size (64 dp) instead of the small 28 dp default. -
New parameters on
showChatHead():iconWidget,iconBuilder,closeIconWidget,closeBackgroundWidget,animateIcon,iconAnimationFps,iconSize,iconPixelRatio,iconAnimationDuration. -
addChatHead()now acceptsiconWidget. Additional bubbles can also use widget-based icons. -
New public API:
AnimatedWidgetIcon,widgetToIconSource(),renderWidgetToImage(),renderWidgetToBytes(),renderWidgetToRgbaByteData(),renderWidgetToPngByteData(),updateChatHeadIcon(),isIconAnimating,startIconAnimation(),stopIconAnimation().
โก Performance #
- Android: Eliminated bitmap allocations in
onDraw()(ChatHead). The circular-crop + shadow pipeline ran on every frame (~240 allocations/second during 60 fps drag). Processed bitmaps are now cached and only recomputed when the source icon reference changes. - Android: Cached close-target resource bitmap (Close).
BitmapFactory.decodeResource()was called on every spring animation frame. The source bitmap is now decoded once at construction and scaled from cache. - Dart: Optimised
updateShouldNotifyinFloatyScopeandFloatyOverlayScope. Changed from unconditionaltrueto!identical()identity checks, avoiding unnecessary widget rebuilds when the data object has not changed. - Dart: Parallelised independent dispose futures with
Future.wait. Sequential awaits inFloatyMessenger, both Kit classes,FloatyOverlayScope, andFakeOverlayDataSourcenow run concurrently.
๐ก๏ธ Robustness #
- Dart: Added
mountedguards to all stream listeners inFloatyScope. PreventssetState-after-dispose crashes if a stream event fires between unmount and subscription cancellation. - Android: Fixed potential
velocityTracker!!crash (ChatHeads). Replaced force-unwrap with safe?: returnto guard against null velocity tracker onACTION_UP. - Android: Added
@Volatileto thread-shared bitmap properties (OverlayConfig). Icon bitmaps written fromDispatchers.IOare now guaranteed visible to the main-threadonDraw(). - Android: Replaced
getString()!!with safe defaults (ConfigPersistence).SharedPreferences.getString()can returnnulleven with a non-null default on some OEM ROMs; three restore calls now use?: "DEFAULT"fallbacks.
๐งน Code Quality #
- Dart: Replaced
unawaited()antipattern with properasync/await. All non-widget dispose methods (FloatyActionRouter,FloatyStateChannel,FloatyMessenger,FloatyProxyStream,FloatyHostKit,FloatyOverlayKit,FakeOverlayDataSource) now returnFuture<void>and properly await their cleanup futures. Reduced from 25 scatteredunawaited()calls to 9 at unavoidable sync framework boundaries (State.dispose(), constructors, lifecycle callbacks). - Android: Removed dead
getRunningServiceInfo()(ChatHeads) and unusedregistrarproperty (iOS plugin). - iOS: Extracted channel name constant and changed
bubbleSizetolet.
๐ Bug Fixes #
- Fixed icon animation not stopping on native close. When the
chathead was dismissed via the drag-to-close gesture, the animation
timer continued running. The
onClosedhandler now callsstopIconAnimation()automatically.
๐ฆ Dependencies #
- Bumped
floaty_chatheads_platform_interfaceto^1.0.5. - Bumped
floaty_chatheads_androidto^1.1.0. - Bumped
floaty_chatheads_iosto^1.1.6.
1.4.0+1 #
๐ฆ Metadata #
- Upgraded package version for meta to 1.18.
- Upgraded package version for pigeon to 26.3.3
1.4.0 #
โจ Enhancements #
- Added
autoLaunchOnBackgroundparameter. Whentrue, the chathead is automatically shown when the app moves to the background and dismissed when the app returns to the foreground. Useful for music players, call UIs, or any overlay that should appear while the user is in another app. (Android only.) - Added
persistOnAppCloseparameter. Whentrue, the foreground service usesSTART_STICKYand persists its configuration so the overlay survives app death and is recreated by the system. Whenfalse(the default), the service usesSTART_NOT_STICKYand stops itself when the main app disconnects. (Android only.) - New example: Auto-Launch & Persist โ demonstrates both parameters with toggle switches and step-by-step instructions.
โก Performance #
- Android: Migrated native plugin to Kotlin Coroutines. Icon loading
and all async operations now use structured concurrency with
Dispatchers.IO, eliminating main-thread blocking. - iOS: Migrated native plugin to Swift Concurrency (
@MainActor). Compile-time main-actor isolation replaces runtime GCD dispatch.
๐ Bug Fixes #
- Fixed chathead freeze on both platforms.
- Android:
showChatHeadandaddChatHeadare now async Pigeon methods. The DartFutureresolves only after the overlay window is fully created, preventing the half-initialized state caused by the coroutine race condition. - iOS: The
@MainActorgesture handler was routing through the actor executor instead of firing synchronously. Now usesnonisolated+MainActor.assumeIsolatedfor zero-overhead drag.
- Android:
๐ฆ Dependencies #
- Bumped
floaty_chatheads_platform_interfaceto^1.0.4. - Bumped
floaty_chatheads_androidto^1.0.7. - Bumped
floaty_chatheads_iosto^1.1.5.
1.3.2 #
๐ Bug Fixes #
FloatyProxyStreamnow throwsStateErroron duplicate names. Creating a second stream with the samenamewithout disposing the first previously caused silent overwrites and broken dispose semantics. A clear error message now guides the developer.
๐งช Tests #
- Added duplicate-name guard tests for
FloatyProxyStream. - Added 3 message-buffering tests for
FloatyChannel(replay on handler registration, max-pending overflow, no buffering for previously-removed handlers) โfloaty_channel.dartis now at 100% line coverage.
1.3.1 #
โจ Enhancements #
- Added
FloatyProxyStream<T>. A typed, reactive, unidirectional stream that pushes values from the main app to the overlay. The overlay subscribes once and receives automatic updates โ useful for GPS coordinates, sensor data, or any high-frequency state.
๐งช Tests #
- Added 9 tests for
FloatyProxyStream.
1.3.0 #
โจ Enhancements #
- Added
FloatyChatheads.onClosedstream. A broadcast stream that emits the chathead ID when the overlay is closed by the native drag-to-close gesture or from the overlay itself. This lets the main app update its UI state without pollingisActive(). - Added
NotificationConfig.description. Custom body text for the Android foreground-service notification. When set, the notification displays a separate title and body instead of the default"<title> is running"format. - Added
FloatyChannelmessage buffering for reconnection reliability. System messages arriving before their handler is registered are now buffered (up to 200 per prefix) and replayed in order when the handler attaches. A_everRegisteredset ensures messages for intentionally-removed handlers still flow to the raw stream. - New examples: Grouping, Move Tracking, Notification Actions, Resizable Panel, and Todo Survival examples added to the gallery app. The Todo Survival example demonstrates add / toggle / remove actions, optimistic local updates, proxy fallback, and full queue-flush reliability after app death.
๐ Bug Fixes #
- Fixed queued actions lost on reconnection. When the main app
restarted, the overlay flushed its action queue before the Dart side
had registered channel handlers, silently dropping every message.
FloatyChannelnow buffers system messages for not-yet-registered prefixes and replays them in order whenregisterHandler()is called. Bumpedfloaty_chatheads_androidto^1.0.5. - Fixed counter survival replaying all queued increments as a single value. Buffered actions are now stored as individual objects and replayed one-by-one with per-action log entries.
- Fixed chathead close crash when GPS is streaming (Android). The
overlay
FlutterViewwas removed from its parent while the engine was still processing GPS data, causing an orphaned rendering window. Bumpedfloaty_chatheads_androidto^1.0.5. - Fixed foreground service persisting after chathead close
(Android). The service teardown now completes before the overlay
engine is destroyed. Bumped
floaty_chatheads_androidto^1.0.5. - Fixed example UI state not updating on drag-to-close. All
example screens now listen to
FloatyChatheads.onClosedto update_chatheadActivewhen the chathead is dismissed via the native close gesture.
1.2.3 #
๐ Bug Fixes #
- Fixed overlay โ main app communication broken on Android. The
overlay
FlutterEngineauto-registers all plugins, which overwrote the sharedactiveInstanceinFloatyChatheadsPluginwith the overlay's instance. Messages sent from the overlay viashareData()looped back to the overlay instead of reaching the main app'sonDatastream. This affected all examples using rawFloatyOverlay.shareData/FloatyChatheads.onDatacommunication (basic chathead, messenger, mini player, etc.). Bumpedfloaty_chatheads_androidto^1.0.4.
๐ฆ Metadata #
- Added
example/example.mdfor the pub.dev example tab.
1.2.2 #
โจ Enhancements #
- Upgraded Pigeon to 26.2.3. Regenerated overlay Pigeon bindings across all platform packages. No API surface changes.
- Updated Android demo GIF in the media folder.
๐ Bug Fixes #
- Fixed survival overlay counter adding +1 on every reconnection. The overlay's manual re-dispatch logic fired even though the framework's automatic queue flush already delivered the queued actions, causing every increment to be applied twice. Removed the redundant re-dispatch โ the queue flush is reliable on its own.
- Fixed counter race condition on app restart. Queued actions
arriving via auto-flush before
SharedPreferencesrestore could increment from zero instead of the persisted value. Increment actions are now buffered until the counter is restored.
1.2.1 #
โจ Enhancements #
- Debug logs are now optional and silent by default (Android). All
native logcat output from the plugin is gated behind
debugMode. SetdebugMode: trueinshowChatHead()to enable verbose logging during development; production builds produce zero log noise.
๐ Bug Fixes #
- Fixed content panel rendering fullscreen on subsequent launches
(Android). When the foreground service had not started yet,
showChatHead()only saved the entry point to SharedPreferences, omitting content dimensions. On service startup,restoreConfig()then overwrote the in-memory values withnull, causing the panel to fall back toMATCH_PARENT. The plugin now persists the full config and the service guards against overwriting values that the plugin already set. - Fixed content panel dimensions leaking between chathead sessions on Android. Switching from a larger overlay (e.g. 300x400) to a smaller one (e.g. 220x220) no longer inherits the previous session's size.
- Fixed missing touch interaction on the content panel after switching
between chathead sessions. The plugin now explicitly recreates the
overlay window with fresh dimensions instead of relying on
onStartCommand(), which could skip recreation when a stale window from aSTART_STICKYrestart was still present. - Fixed iOS content size not resetting between sessions โ dimensions now default to 300x400 before applying the new config.
1.2.0 #
๐งฉ Higher-Level Convenience Widgets #
-
Added
FloatyDataBuilder<T>โ a reactive builder for the main app side that subscribes toFloatyChatheads.onData, reduces incoming messages into typed state via a(T current, Object? raw) โ Treducer, and rebuilds automatically. Eliminates manualStreamSubscription,setState, anddisposeboilerplate. -
Added
FloatyOverlayBuilder<T>โ a zero-boilerplate builder for the overlay side that handlesFloatyOverlay.setUp(), stream subscriptions,mountedguards, andFloatyOverlay.dispose()automatically. SupportsonDatareducer, optionalonTappedreducer, andonInitcallback. Turns overlay widgets intoStatelessWidgetdeclarations. -
Added
FloatyOverlayApp.runScoped()โ a variant ofrun()that wraps the child inFloatyScope, soFloatyScope.of(context)works everywhere inside the overlay without manual wiring. -
Added
builderparameter toFloatyControllerWidgetโ accepts aWidget Function(BuildContext, FloatyController)callback with reactive re-rendering viaListenableBuilder. Thechildparameter is now optional whenbuilderis provided.
๐ฆ Grouped Configuration Objects #
- Added
ChatHeadAssetsโ groups chathead icon, close icon, and close background into a single object. Old flat parameters are deprecated. - Added
NotificationConfigโ groups notification title, icon, and visibility into a single object. Old flat parameters are deprecated. - Added
SnapConfigโ groups snap edge, margin, and position persistence into a single object. Old flat parameters are deprecated. - Added
IconSourceโ polymorphic icon source withIconSource.asset(),IconSource.network(), andIconSource.bytes()constructors for flexible icon loading from assets, URLs, or raw byte data.
โจ Simplified Examples #
- Simplified all 14 overlay entry points from verbose 6-line blocks to
single-line
FloatyOverlayApp.run()calls (84 โ 14 lines total). - Rewrote
NotificationCounterOverlayusingFloatyOverlayBuilder<int>โ now aStatelessWidgetwith zero lifecycle code. - Rewrote
QuickActionOverlayusingFloatyOverlayBuilder<bool>โ now aStatelessWidgetwith tap-to-toggle expand/collapse. - Rewrote
QuickActionExampleusingFloatyDataBuilder<List<LogEntry>>โ incoming actions accumulate into a log via reducer, no manual subscription.
๐งช Tests #
- Added 10 new tests for
FloatyDataBuilder(5) andFloatyOverlayBuilder(5).
1.1.0 #
๐ iOS Feature Parity #
- iOS now supports entrance animations, snap-to-edge, position persistence, badge counter, theming, expand/collapse, drag events, and VoiceOver accessibility.
- Removed "Android only" notes from platform interface docs.
- Bumped
floaty_chatheads_iosdependency to^1.1.0.
๐ Shared State Channel #
- Added
FloatyStateChannel<T>โ a generic, type-safe channel for synchronizing arbitrary state between the main app and the overlay. - Supports partial updates via
update()and full replacements viaset(). - Provides a reactive
streamof state changes and synchronousstateaccess. - Works with any serializable Dart model, not limited to a specific domain.
๐ฐ๏ธ Bidirectional Action Routing #
- Added
FloatyActionRouterโ a typed, extensible action bus for dispatching structured commands between app and overlay. - Register strongly-typed handlers with
on<A>()and send actions withsend(). - Actions implement
FloatyActionwithtypeandtoJson()for automatic serialization over the platform channel.
๐ช Overlay Proxy #
- Added
FloatyProxyโ lets the overlay call app-side services (e.g. APIs, databases, repositories) without direct dependencies. FloatyProxyHostregisters named service handlers in the main app.FloatyProxyClientinvokes them from the overlay and receivesFuture-based responses.- Enables clean separation of concerns between the overlay UI and app-side business logic.
๐ก๏ธ Overlay Survival After App Death (Android) #
- The Android
FloatyContentJobServicenow owns the Flutter engine lifecycle. The overlay survives when the main app is killed and automatically restores from persisted config on service restart. - Added
FloatyConnectionStateโ overlay-side utility that tracks whether the main app is connected, with a reactive stream and synchronous getter. FloatyActionRouternow queues dispatched actions while the main app is disconnected and flushes them in order on reconnection. ConfigurablemaxQueueSizeandQueueOverflowStrategy.FloatyProxyClientfails fast withFloatyProxyDisconnectedExceptionwhen the main app is unavailable, with an optionalfallbackparameter to provide default values instead of throwing.FloatyScopeDataexposesisMainAppConnectedfor reactive overlay UI updates.- The plugin automatically reconnects to an existing overlay when the main app restarts (hot-restart or cold launch).
1.0.1 #
- Added Android and iOS demo GIFs to README.
- Fixed foreground notification on service reuse.
- Documentation and metadata updates.
1.0.0 #
๐ Initial Release โ Complete Rewrite #
A ground-up rewrite of the floating chathead plugin, inspired by flutter_overlay_window.
Platform Support
- Android โ
SYSTEM_ALERT_WINDOWoverlay with foreground service, Facebook Rebound spring physics, and fullFlutterEnginecontent panels. - iOS โ
UIWindow-based PiP overlay at.alert + 1window level. No special permissions required. Supports iOS 13+.
Core Features
- Floating chathead bubbles rendered as system-level overlays.
- Expand / collapse Flutter widget content panels.
- Bidirectional data messaging between the main app and overlay isolate
via
BasicMessageChannel. - Drag-and-drop with spring-animated snap-to-edge.
- Close target with magnetic snap and animated reveal.
- Badge counter on chathead bubbles.
- Multi-bubble support โ add / remove individual chatheads by ID.
Theming API
ChatHeadThememodel with badge colors, bubble border, shadow color, close tint, and overlay color palette.- Automatic palette delivery to overlay isolate on engine start.
FloatyOverlay.paletteandonPaletteChangedstream for overlay-side consumption.
Size Presets
ContentSizePresetenum:compact,card,halfScreen,fullScreen.- Preset dimensions resolved before passing to the native layer.
Debug Inspector
debugModeflag onChatHeadConfig.DebugOverlayView(Android) with bounds rectangles, position labels, spring velocity HUD, and FPS counter.- Pigeon message log (circular buffer, 50 entries).
FloatyOverlay.getDebugInfo()for Dart-side debug panels.
Accessibility (Android)
- Full TalkBack support with content descriptions, state announcements, and accessibility actions on all interactive views.
- Focus management: content panel receives focus on expand, bubble receives focus on collapse.
ACTION_CLICK("Expand / Collapse chat") andACTION_DISMISS("Close chat bubble") custom actions.AccessibilityLiveRegion.POLITEon close target for automatic announcements.
Snap & Animation
SnapEdgeenum:left,right,nearest,none.- Configurable snap margin in dp.
persistPositionโ remembers last bubble position across sessions.EntranceAnimationenum:none,slideInFromLeft,slideInFromRight,fadeIn.
Developer Experience
- Federated plugin architecture (main โ platform_interface โ android / ios).
- Pigeon-generated type-safe Dart โ Kotlin / Swift communication.
- VGV-style
{@template}/{@macro}documentation across all packages. FloatyPermissionGatewidget for declarative permission handling.- 12 runnable example screens in the gallery app.
Architecture
floaty_chatheadsโ app-facing APIfloaty_chatheads_platform_interfaceโ abstract contract + modelsfloaty_chatheads_androidโ Kotlin + Pigeon implementationfloaty_chatheads_iosโ Swift + Pigeon implementation