openWindow function

Future<int> openWindow(
  1. Widget childBuilder(
    1. BuildContext context,
    2. int publicId
    ), {
  2. WindowOptions? options,
  3. BuildContext? parentContext,
})

Opens a new OS window showing childBuilder.

Returns the public view id of the new window when creation finishes.

Convenience wrapper around MultiViewDesktop.addWindow. Can be called from anywhere (timers, isolates callbacks, services) without a BuildContext.

ElevatedButton(
  onPressed: () => openWindow(
    (context, viewId) => const SettingsPage(),
    options: WindowOptions(title: 'Settings'),
  ),
  child: const Text('Open settings'),
)

Implementation

Future<int> openWindow(
  Widget Function(BuildContext context, int publicId) childBuilder, {
  WindowOptions? options,
  BuildContext? parentContext,
}) => MultiViewDesktop.addWindow(childBuilder, options: options, parent: parentContext);