getPackageFromUri method Null safety

Future<Package?> getPackageFromUri(
  1. Uri? uri
)

Implementation

Future<Package?> getPackageFromUri(Uri? uri) async {
  if (uri == null) {
    return null;
  }
  if (uri.scheme == "package") {
    final segments = uri.pathSegments;
    return (await packageConfig)[segments.first]!;
  } else if (!uri.isAbsolute) {
    throw ArgumentError("'uri' must be absolute or a package URI");
  }
  return null;
}