An open API service indexing awesome lists of open source software.

https://github.com/yelmuratoff/draggable_panel

A versatile and customizable Draggable Panel
https://github.com/yelmuratoff/draggable_panel

draggable draggable-panel floating-button floating-panel panel

Last synced: 8 months ago
JSON representation

A versatile and customizable Draggable Panel

Awesome Lists containing this project

README

          







A versatile and customizable Draggable Panel ๐Ÿš€


DraggablePanel is a versatile and interactive widget for Flutter that allows you to create floating, draggable panels that can dock to the nearest edge of the screen. The panel is ideal for displaying additional content, actions, or tools that can be accessed on demand.

Your feedback is highly valued as it will help shape future updates and ensure the package remains relevant and useful. ๐Ÿ˜Š



Show some โค๏ธ and star the repo to support the project!


Pub
License: MIT
Pub



Pub likes
Pub points


## ๐Ÿ“œ Showcase





## ๐Ÿ“Œ Getting Started
Follow these steps to use this package

### Add dependency

```yaml
dependencies:
draggable_panel: ^1.3.1
```

### Add import package

```dart
import 'package:draggable_panel/draggable_panel.dart';
```

## Easy to use

### Instructions for use:

Simple add `DraggablePanel` to `MaterialApp`'s `builder`.

```dart
builder: (context, child) {
return DraggablePanel(
items: [
DraggablePanelItem(
enableBadge: false,
icon: Icons.color_lens,
onTap: (context) {},
description: 'Color picker',
),
DraggablePanelItem(
enableBadge: false,
icon: Icons.list,
onTap: (context) {},
),
DraggablePanelItem(
enableBadge: false,
icon: Icons.zoom_in,
onTap: (context) {},
),
DraggablePanelItem(
enableBadge: false,
icon: Icons.token,
onTap: (context) {},
),
],
buttons: [
DraggablePanelButtonItem(
icon: Icons.copy,
onTap: (context) {},
label: 'Push token',
description: 'Push token to the server',
),
],
child: child!,
);
},
```

### Using a controller (recommended for advanced control)

Create a controller once and pass it to the widget. You can preset position/state and listen to position changes.

```dart
final controller = DraggablePanelController(
initialPosition: (x: 20, y: 300),
// initialPanelState: PanelState.open, // optional: start opened
);

@override
void initState() {
super.initState();
controller.addPositionListener((x, y) {
// persist position, analytics, etc.
});
}

// In MaterialApp.builder
builder: (context, child) => DraggablePanel(
controller: controller,
onPositionChanged: (x, y) {
// Called when position settles (not during active dragging)
},
items: const [],
buttons: const [],
child: child!,
),
```

Tips:
- When the panel starts in the closed state (default), it will be docked to the nearest screen edge on first layout, so the button never โ€œfloatsโ€ mid-screen.
- The widget doesnโ€™t auto-toggle on mount. Use `controller.toggle(context)` when you need to programmatically open/close it.
- Position callbacks: use `controller.addPositionListener` for all position updates; `onPositionChanged` is fired when not dragging (settled updates).

Please, check the [example](https://github.com/yelmuratoff/draggable_panel/tree/main/example) for more details.




Thanks to all contributors of this package