Window class

A comprehensive windowing system for creating desktop-like window interfaces.

EXPERIMENTAL COMPONENT - This component is in active development and APIs may change.

Provides a complete window management solution with draggable, resizable windows that support minimizing, maximizing, and snapping to screen edges. Designed for desktop-style applications requiring multiple simultaneous content areas.

Core Features:

  • Window Management: Create, control, and destroy floating windows
  • Interactive Behaviors: Drag, resize, minimize, maximize, close operations
  • Snapping System: Intelligent edge snapping and window positioning
  • Layering Control: Always-on-top and z-order management
  • Constraint System: Size and position limits with validation
  • Theme Integration: Full shadcn_flutter theme and styling support

Architecture:

  • Window: Immutable window configuration and factory
  • WindowController: Reactive state management for window properties
  • WindowWidget: Stateful widget that renders the actual window
  • WindowNavigator: Container managing multiple windows

The system supports both controlled (external state management) and uncontrolled (internal state management) modes for different use cases.

Usage Patterns:

  1. Simple Window: Basic window with default behaviors
  2. Controlled Window: External state management with WindowController
  3. Window Navigator: Multiple windows with shared management

Example:

// Simple window
final window = Window(
  title: Text('My Window'),
  content: MyContent(),
  bounds: Rect.fromLTWH(100, 100, 800, 600),
  resizable: true,
  draggable: true,
);

// Controlled window
final controller = WindowController(initialState);
final controlledWindow = Window.controlled(
  controller: controller,
  title: Text('Controlled Window'),
  content: MyContent(),
);

Constructors

Window({Widget? title, Widget? actions = const WindowActions(), Widget? content, bool resizable = true, bool draggable = true, bool closable = true, bool maximizable = true, bool minimizable = true, bool enableSnapping = true, required Rect? bounds, Rect? maximized, bool minimized = false, bool alwaysOnTop = false, BoxConstraints constraints = kDefaultWindowConstraints})
Creates a window with explicit state and configuration.
Window.controlled({Widget? title, Widget? actions = const WindowActions(), Widget? content, required WindowController? controller})
Creates a controlled window with behavior managed by a WindowController.

Properties

actions Widget?
Custom action widgets displayed in the title bar (e.g., minimize, maximize, close buttons).
final
alwaysOnTop bool?
Whether the window should always appear on top of other windows.
final
bounds Rect?
Initial bounds (position and size) of the window.
final
closable bool?
Whether the window can be closed via the close button.
final
closed ValueNotifier<bool>
Notifier that indicates whether the window has been closed.
final
constraints BoxConstraints?
Size constraints for the window (min/max width and height).
final
content Widget?
Main content widget displayed in the window body.
final
controller WindowController?
Controller for programmatic window management (position, size, state).
final
draggable bool?
Whether the window can be dragged by its title bar.
final
enableSnapping bool?
Whether window snapping is enabled (snap to edges or other windows).
final
handle WindowHandle
Gets a handle to the window's internal state.
no setter
hashCode int
The hash code for this object.
no setterinherited
maximizable bool?
Whether the window can be maximized.
final
maximized Rect?
Bounds when window is in maximized state.
final
minimizable bool?
Whether the window can be minimized.
final
minimized bool?
Whether the window starts in minimized state.
final
mounted bool
Indicates whether the window is currently mounted in the widget tree.
no setter
resizable bool?
Whether the window can be resized by dragging edges.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
title Widget?
Title widget displayed in the window's title bar.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited