addFile method

void addFile(
  1. MediaFile file, {
  2. Locale? locale,
})

Implementation

void addFile(MediaFile file, {Locale? locale}) {
  String name = getDateCategory(file, locale: locale);
  if (dateCategories.any((element) => element.name == name)) {
    dateCategories
        .singleWhere((element) => element.name == name)
        .files
        .add(file);
  } else {
    DateTime? lastDate = file.lastModified;
    lastDate = lastDate ?? DateTime.now();
    dateCategories
        .add(DateCategory(files: [file], name: name, dateTime: lastDate));
  }
}