WindowWidget.controlled constructor

const WindowWidget.controlled({
  1. Key? key,
  2. Widget? title,
  3. Widget? actions,
  4. Widget? content,
  5. required WindowController controller,
  6. double? titleBarHeight,
  7. double? resizeThickness,
})

Creates a window with controller-based state management.

State is managed entirely through the provided controller. All state properties from the default constructor are unavailable and must be controlled via the controller instead.

This pattern is recommended when you need:

  • Programmatic control over window state
  • To listen to state changes
  • To share state across multiple widgets
  • More reactive state updates

Parameters:

  • controller: The window controller (required)
  • title: Title bar content
  • actions: Action buttons area content
  • content: Main window content
  • titleBarHeight: Custom title bar height (optional)
  • resizeThickness: Custom resize border thickness (optional)

Example:

final controller = WindowController(
  bounds: Rect.fromLTWH(100, 100, 800, 600),
);

// Later, programmatically control:
controller.minimized = true;
controller.bounds = Rect.fromLTWH(200, 200, 900, 700);

Implementation

const WindowWidget.controlled({
  super.key,
  this.title,
  this.actions,
  this.content,
  required WindowController this.controller,
  this.titleBarHeight,
  this.resizeThickness,
})  : bounds = null,
      maximized = null,
      minimized = null,
      resizable = null,
      draggable = null,
      closable = null,
      maximizable = null,
      minimizable = null,
      enableSnapping = null,
      constraints = null;