floating_palette library
Floating Palette - Native floating panels for Flutter desktop apps.
Quick Start
- Define palettes with code generation:
// palette_setup.dart
@FloatingPaletteApp(palettes: [
Palette(id: 'menu', widget: MyMenu, preset: PalettePreset.menu),
])
class PaletteSetup {}
- Initialize and use:
// main.dart
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Palettes.init();
runApp(const MyApp());
}
// Show the palette
Palettes.menu.show();
- Build palette widgets:
class MyMenu extends StatelessWidget {
Widget build(BuildContext context) {
return ListView(
children: items.map((item) => ListTile(
title: Text(item.name),
onTap: () {
Palette.of(context).emit(ItemSelected(item.id));
Palette.of(context).hide();
},
)).toList(),
);
}
}
Advanced Usage
For power users who need direct access to services, bridge, FFI, etc.,
import floating_palette_advanced.dart instead.
Classes
- ActiveAppInfo
- Information about the active (frontmost) application window.
- AnimatedGradientBorder
- An animated gradient border that flows around its child like LED strips.
- AutoSnapConfig
- Per-palette auto-snap configuration.
- Capabilities
- Platform capabilities detected at runtime.
- GlassEffectService
- High-level service for applying glass blur effects to palette windows.
- Palette
- Simplified static API for palette-side operations.
- PaletteAnimation
- Animation configuration for palette show/hide transitions.
- PaletteAppearance
- Visual appearance configuration for a palette.
- PaletteBehavior
- Behavior configuration for a palette.
- PaletteConfig
- Complete configuration for a palette.
- PaletteContext
- Provides access to the current palette from within a palette widget.
-
PaletteController<
TArgs> - Controller for a single palette window.
- PaletteEvent
- Base class for palette events.
- PaletteGroup
- Defines a group of palettes where at most one can be visible at a time.
- PaletteHost
- Central dependency injection container for floating palettes.
- PaletteKeyboard
- Keyboard handling configuration for a palette.
- PaletteKeyEvent
- Key event data received from native.
- PaletteKeyReceiver
- Provides access to key events routed to this palette.
- PaletteMessenger
- Messenger for palette-to-host communication.
- PalettePosition
- Position configuration for a palette.
- PaletteScaffold
- A scaffold widget for palette content.
- PaletteSelf
- Query methods for a palette to get information about itself.
- PaletteSize
- Size configuration for a palette.
- PaletteSizeConfig
- Size configuration for a palette, queryable at runtime.
- PaletteWindow
- Utility for palettes to control their own window.
- ScreenRect
- A rectangle in screen coordinates with anchor point helpers.
- SizeReporter
- A widget that reports its size to native and resizes the window.
- SnapConfig
- Configuration for snap behavior.
- SnapDetached
- Emitted when a snap binding is removed.
- SnapDragEnded
- Emitted when user releases a dragged snapped follower.
- SnapDragging
- Emitted during dragging of a snapped follower (throttled).
- SnapDragStarted
- Emitted when user starts dragging a snapped follower.
- SnapEvent
- Base class for snap-related events from native.
- SnapProximityEntered
- Emitted when a dragged palette enters a snap zone of another palette.
- SnapProximityExited
- Emitted when a dragged palette exits a snap zone.
- SnapProximityUpdated
- Emitted during drag while in snap proximity (distance changes).
- SnapSnapped
- Emitted when a follower is snapped to a target.
Enums
- Anchor
- How the palette anchors to its target.
- ClickOutsideBehavior
- Behavior when user clicks outside the palette.
- FocusPolicy
- How focus is handled when showing a palette.
- FocusRestoreMode
- What happens to focus when a palette is hidden.
- GlassAnimationCurve
- Animation curve types for native glass interpolation. Must match native GlassAnimationCurve enum.
- GlassMaterial
- Material types for the glass blur effect.
- PaletteLifecycle
- When the palette's Flutter view is created.
- PalettePreset
- Pre-configured palette types for common use cases.
- PaletteShadow
- Shadow presets for palettes.
- SnapAlignment
- Alignment along the snapped edge.
- SnapEdge
- Which edge of the window to snap.
- SnapMode
- Mode for snap relationships.
- Target
- What the palette positions relative to.
- UnsupportedBehavior
- How to handle unsupported platform features.
Extensions
- PalettePresetConfig on PalettePreset
- Extension to get PaletteConfig from a preset.
- RectToScreenRect on Rect
- Extension on Rect for quick conversion to ScreenRect.
- ScreenOffset on Offset
- Extension on Offset for platform-aware directional offsets.
Functions
-
initPaletteEngine(
Map< String, Widget Function()> builders, {void registerEvents()?}) → void - Initialize palette engine with generated builders.
Exceptions / Errors
- UnknownEventError
- Exception thrown when deserializing an unknown event type.