routeIdentifier<T> static method

String routeIdentifier<T>(
  1. [dynamic value]
)

Resolves identifier for given route Type and name. Similar to ControlFactory.keyOf, but also accepts String as valid value key. This method is mainly used by framework to determine identifier of ControlRoute stored in RouteStore.

Returned identifier is formatted as path -> '/name'.

Implementation

static String routeIdentifier<T>([dynamic value]) {
  if (value == null && T != dynamic) {
    value = T;
  }

  String? id;

  if (value is String) {
    id = value;
  } else if (value is Type) {
    id = value.toString();
  } else if (value != null) {
    id = value.runtimeType.toString();
  }

  String key = id ?? UnitId.nextId();

  if (!key.startsWith('/')) {
    key = '/$key';
  }

  return key;
}