isImageExtenstion method

bool isImageExtenstion({
  1. List<String> imgExt = const <String>['png', 'jpg', 'jpeg', 'gif'],
})

Checks if the string has an image file extension.

imgExt is the list of valid image extensions.

Implementation

bool isImageExtenstion(
    {List<String> imgExt = const <String>['png', 'jpg', 'jpeg', 'gif']}) {
  if (!contains('.')) return false;

  final ext = substring(lastIndexOf('.') + 1).toString();
  return imgExt.contains(ext);
}