deviceClassPath function

String deviceClassPath(
  1. String path,
  2. DeviceClass deviceClass
)

path with deviceClass put before its extension: chair.f3d becomes chair.phone.f3d, crypt.json becomes crypt.phone.json.

The one spelling both sides use — the build writes this name and the loader asks for it — so it lives in one function rather than in two packages that would have to agree.

Implementation

String deviceClassPath(String path, DeviceClass deviceClass) {
  final slash = path.lastIndexOf('/');
  final dot = path.lastIndexOf('.');
  return dot > slash
      ? '${path.substring(0, dot)}.${deviceClass.name}${path.substring(dot)}'
      : '$path.${deviceClass.name}';
}