'Check if dependency exists programmatically

I am developing a federated library with a custom runner.

I want to check if library X exists (specified in pubspec.yaml) but could not find a clean way to do that.

I came across this library: https://pub.dev/packages/resource. My idea is to check if package:foo/foo.dart exist. Unfortunately, this package is discontinued now.

Is there a way to check dependencies? (no flutter, only dart)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source