syncFromWidget method

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

Implementation

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

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

  final registry = merged.values.toList();
  final flowPages = _pagesFromRegistry(registry);
  final activeKey = _resolveActiveKey(
    merged: merged,
    initialPaneKey: initialPaneKey,
    forceInitialPane: forceInitialPane,
  );

  if (forceInitialPane || !state.isInitialized) {
    _resetPageFlow(activeKey, flowPages);
  } else {
    _ensurePageFlow(initialPaneKey);
    _pageFlow!.attach(flowPages);
    if (state.paneByKey(_pageFlow!.currentKey) == null) {
      _pageFlow!.replace(activeKey);
    }
  }

  state = VoDashboardState(
    dockPanes: List<VoDashboardPane>.unmodifiable(dockPanes),
    drawerPanes: List<VoDashboardPane>.unmodifiable(drawerPanes),
    endDrawerPanes: List<VoDashboardPane>.unmodifiable(endDrawerPanes),
    registry: List<VoDashboardPane>.unmodifiable(registry),
    flowPages: List<VoPage>.unmodifiable(flowPages),
    isInitialized: true,
  );
  _syncCurrentPaneFromPageFlow();
}