persistWorkspace method
Future<void>
persistWorkspace(
- String name, {
- List<
DVTabWorkspaceController> workspaces = const <DVTabWorkspaceController>[],
Saves the current window and tab layout under name.
Stored as view state through the shared store rather than a native window API, because the layout has to come back on a target that has no windows at all — a phone reopening its tabs is the same feature.
Implementation
Future<void> persistWorkspace(
String name, {
List<DVTabWorkspaceController> workspaces =
const <DVTabWorkspaceController>[],
}) async {
final layout = <DVJsonValue>[
for (final workspace in workspaces)
DVJsonMap(<String, DVJsonValue>{
'active': DVJsonNumber(workspace.activeIndex),
'tabs': DVJsonList(<DVJsonValue>[
for (final tab in workspace.tabs) DVJsonString(tab.route.path),
]),
}),
];
await shared.setReserved(_workspaceKey(name), DVJsonList(layout));
await shared.flushReserved(_workspaceKey(name));
}