getListPathImageByExamId method

Future<List<String>> getListPathImageByExamId(
  1. String examId
)

Implementation

Future<List<String>> getListPathImageByExamId(String examId) async {
  Directory? externalDir = Platform.isAndroid
      ? await getExternalStorageDirectory() //FOR ANDROID
      : await getApplicationDocumentsDirectory(); //FOR iOS
  List<FileSystemEntity> file = Directory("${externalDir?.path}")
      .listSync(recursive: true, followLinks: false);
  List<String> listImagePath = [];
  for (var i = 0; i < file.length; i++) {
    if (file[i].path.contains('exam$examId')) {
      listImagePath.add(file[i].path);
    }
  }
  return listImagePath;
}