register method

void register(
  1. ModalRoute route,
  2. GlassNavBarRegistration registration, {
  3. BuildContext? registrant,
})

Registers or updates route's pinned chrome.

Implementation

void register(
  ModalRoute<dynamic> route,
  GlassNavBarRegistration registration, {
  BuildContext? registrant,
}) {
  final entries = _registry[route];
  if (entries == null) {
    _registry[route] = <_RegistrantEntry>[
      _RegistrantEntry(registrant: registrant, registration: registration),
    ];
    _listenTo(route.animation);
    _listenTo(route.secondaryAnimation);
    final listener =
        _clockListeners[route] = (status) => _onRouteStatus(route, status);
    route.animation?.addStatusListener(listener);
  } else {
    final index = entries
        .indexWhere((entry) => identical(entry.registrant, registrant));
    if (index >= 0) {
      entries[index].registration = registration;
    } else {
      entries.add(
        _RegistrantEntry(registrant: registrant, registration: registration),
      );
    }
  }
  _scheduleNotify();
}