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 = getBaseName(filePath);
  final a =
      begType.isEmpty ? true : fileName.startsWith('${begType.toLowerCase()}_');
  final b =
      endType.isEmpty ? true : fileName.endsWith('.$endType'.toLowerCase());
  final c = a && b;
  return (status: c, fileName: fileName);
}