After I do pub upgrade, The error says "The argument type 'File?' can't be assigned to the parameter type 'File'."
Maybe it is because
<await imagesMedia! .where((element) => element.id == id) .first .getFile()> is type 'File?'
But I'm not sure how can I change this.
await Future.forEach(selectedImagesIDs!,
(String id) async {
selectedFiles.add(await imagesMedia!
.where((element) => element.id == id)
.first
.getFile());
please help me
File?
means that this object can be eitherFile
ornull
, while theFile
type can't benull
and it will throw an error if you try to make itnull
. To solve your problem you can either change type of the parameter of your function (the function where you pass data from thisFuture
) fromFile
toFile?
or if you can guarantee that.getFile()
won't ever returnnull
, you can put anbang
operator(!)
after your function call like this: