dispenseNewDynamicRoutesInstance method

  1. @override
DynamicRoutesNavigator dispenseNewDynamicRoutesInstance({
  1. required List<Widget> participatorWidgets,
  2. required Widget initiatorWidget,
})
inherited

A static DynamicRoutes manager that dispenses a scoped DynamicRoutes singleton bound to the lifeCycle of the StatefulWidget page it is attached to.

Implementation

@override
DynamicRoutesNavigator dispenseNewDynamicRoutesInstance({
  required List<Widget> participatorWidgets,
  required Widget initiatorWidget,
}) {
  final newDynamicRoutesInstance = DynamicRoutesNavigatorImpl();

  // Bind all widgets in the array to this newDynamicRoutesInstance
  for (final widget in participatorWidgets) {
    assert(
        _dynamicRoutesInstances[widget.hashCode] == null,
        "The participator instance ${widget.hashCode} is already bound to a "
        "navigation scope. Participator widgets and cannot be assigned again "
        "until the their current navigation scope is disposed.");
    _dynamicRoutesInstances[widget.hashCode] = newDynamicRoutesInstance;

    _participatorAndInitiatorMap[widget.hashCode] = initiatorWidget;
  }

  // Save reference for the disposition of all references to widgets in the
  // array from this manager
  _initiatorAndParticipatorsMap[initiatorWidget.hashCode] =
      participatorWidgets;

  return newDynamicRoutesInstance;
}