getExtensionFromUrl property Null safety

String getExtensionFromUrl

Implementation

String get getExtensionFromUrl {
  String extensionType = "";
  int index = this.lastIndexOf('.');
  if (index != -1) {
    extensionType = this.substring(index, this.length);
    int indexQuery = extensionType.indexOf("?");
    if (indexQuery != -1) {
      extensionType = extensionType.substring(1, indexQuery);
    }
  }

  return extensionType;
}