isMatchingFileName function

({String fileName, bool status}) isMatchingFileName(
  1. String filePath,
  2. String begType,
  3. String endType
)

Checks if the file name extracted from filePath matches the specified beginning type begType and ending type endType.

Returns a tuple with the match status and the file name.

Implementation

({bool status, String fileName}) isMatchingFileName(
  String filePath,
  String begType,
  String endType,
) {
  final fileName = PathUtility.i.localBaseName(filePath);
  final lcFileName = fileName.toLowerCase();
  final a = begType.isEmpty
      ? true
      : lcFileName.startsWith('${begType.toLowerCase()}_');
  final b =
      endType.isEmpty ? true : lcFileName.endsWith('.${endType.toLowerCase()}');
  final c = a && b;
  return (status: c, fileName: fileName);
}