initialize method

Future<void> initialize({
  1. Locale? locale,
})

Implementation

Future<void> initialize({Locale? locale}) async {
  List<DateCategory> dateCategory = [];
  for (var medium in sortAlbumMediaDates((await album.listMedia()).items)) {
    MediaFile mediaFile = MediaFile.medium(medium);
    String name = getDateCategory(mediaFile, locale: locale);
    if (dateCategory.any((element) => element.name == name)) {
      dateCategory
          .singleWhere((element) => element.name == name)
          .files
          .add(mediaFile);
    } else {
      DateTime? lastDate = mediaFile.lastModified;
      lastDate = lastDate ?? DateTime.now();
      dateCategory.add(
          DateCategory(files: [mediaFile], name: name, dateTime: lastDate));
    }
  }
  dateCategories = dateCategory;
  try {
    thumbnail = await album.getThumbnail(highQuality: true);
  } catch (e) {
    if (kDebugMode) {
      print(e);
    }
  }
}