relativeImport static method

String relativeImport({
  1. required String from,
  2. required String to,
})

Returns the relative import path from one file to another.

Path separators are normalized to forward slashes.

Implementation

static String relativeImport({
  required String from,
  required String to,
}) {
  final fromDir = p.dirname(from);

  return p.relative(to, from: fromDir).replaceAll('\\', '/');
}