discontinuedPackage pubspec2 has been discontinued and replaced by pubspec_manager.

getKnownType function

String getKnownType(
  1. Iterable<String> keys
)

The dependency type by convention is the first key however there is no require that it is the first so we need to search the map of keys to see if a know type exits.

Implementation

String getKnownType(Iterable<String> keys) {
  if (keys.contains('path')) {
    return 'path';
  }
  if (keys.contains('git')) {
    return 'git';
  }
  if (keys.contains('hosted')) {
    return 'hosted';
  }
  if (keys.contains('sdk')) {
    return 'sdk';
  }

  return '';
}