filePathToCamelIdentifierWithExt function

String filePathToCamelIdentifierWithExt(
  1. String filePath
)

Converts a file path to a camelCase identifier, including the file extension as a suffix.

Example: assets/images/cat.pngassetsImagesCatPng

Implementation

String filePathToCamelIdentifierWithExt(String filePath) {
  final withoutExtension = p.withoutExtension(filePath);
  final ext = p.extension(filePath).replaceFirst('.', '');
  if (ext.isEmpty) return toCamelIdentifier(withoutExtension);
  return toCamelIdentifier('${withoutExtension}_$ext');
}