draggable_floating_fab 0.1.3 copy "draggable_floating_fab: ^0.1.3" to clipboard
draggable_floating_fab: ^0.1.3 copied to clipboard

A draggable, sticky FAB overlay with a drag-to-dismiss zone for Flutter apps.

Draggable Floating FAB #

A draggable, sticky support FAB overlay with a drag-to-dismiss zone for Flutter apps.

FAB snapped to the right edge FAB drag-to-dismiss zone FAB snapped to the left edge

Wrap your app (or any subtree) to get an edge-snapping floating action button that:

  • Drags freely and snaps to the nearest left/right edge
  • Persists its position per locale via SharedPreferences
  • Shows a dismiss zone while dragging (drop to hide for the session)
  • Optionally auto-hides on configured route paths

Installation #

dependencies:
  draggable_floating_fab: ^0.1.2

Then run:

flutter pub get

Usage #

Pass the router once — no wrapper widget, no ListenableBuilder:

import 'package:draggable_floating_fab/draggable_floating_fab.dart';

MaterialApp.router(
  routerConfig: router,
  builder: (context, child) {
    return DraggableSupportFabOverlay(
      routeListenable: router.routerDelegate,

      currentPath: () => router.state.uri.path, //It points to the application's current path (screen).

      // `/` only hides the root route — safe to include.
      hiddenRoutePaths: const {'/', '/login', '/help-center'},//It points to the screen should hide the fab in

      onFabTap: () => router.push('/help-center'),
      bottomSafeInset: 88, // clear bottom nav if needed
      child: child ?? const SizedBox.shrink(),
    );
  },
);
DraggableSupportFabOverlay(
  child: child,
  onFabTap: () {
    // e.g. open your support / live-chat screen
  },
  currentPath: () => currentRouteName,
  hiddenRoutePaths: const {'/', '/onboarding', '/live-chat'},
  fabColor: Theme.of(context).colorScheme.primary,
  bottomSafeInset: 16,
)

Tips #

Parameter Notes
routeListenable e.g. GoRouter.routerDelegate — rebuilds on navigation
hiddenRoutePaths / matches root only; other paths match exact + nested (/help/help/x)
fabColor Defaults to ColorScheme.primary when omitted
fab Optional custom widget; keep fabSize in sync with it
currentPath Omit to always show the FAB (until session-dismissed)

Example #

See the example/ directory for a runnable demo:

cd example
flutter run

License #

MIT

3
likes
155
points
224
downloads
screenshot

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A draggable, sticky FAB overlay with a drag-to-dismiss zone for Flutter apps.

Repository (GitHub)
View/report issues

Topics

#flutter #fab #floating-action-button #overlay #ui

License

MIT (license)

Dependencies

flutter, shared_preferences

More

Packages that depend on draggable_floating_fab