syncFromWidget method

void syncFromWidget({
  1. required List<FxPane> dockPanes,
  2. List<FxPane> drawerPanes = const [],
  3. List<FxPane> endDrawerPanes = const [],
  4. required String initialPaneKey,
})

Implementation

void syncFromWidget({
  required List<FxPane> dockPanes,
  List<FxPane> drawerPanes = const [],
  List<FxPane> endDrawerPanes = const [],
  required String initialPaneKey,
}) {
  final merged = FxPane.mergeRegistry(
    dockPanes: dockPanes,
    drawerPanes: drawerPanes,
    endDrawerPanes: endDrawerPanes,
  );

  if (merged.isEmpty) {
    state = const FxShellState();
    return;
  }

  final registry = merged.values.toList();
  final initial = merged[state.currentPaneKey ?? initialPaneKey] ?? registry.first;

  state = FxShellState(
    dockPanes: List<FxPane>.unmodifiable(dockPanes),
    drawerPanes: List<FxPane>.unmodifiable(drawerPanes),
    endDrawerPanes: List<FxPane>.unmodifiable(endDrawerPanes),
    registry: List<FxPane>.unmodifiable(registry),
    currentPane: initial,
    history: [initial.key],
  );
}