draggable_floating_fab 0.1.3
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.
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 #
GoRouter (recommended) #
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(),
);
},
);
Navigator 1.0 #
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
