parseToFileId static method

String parseToFileId({
  1. required dynamic data,
})

Automatic Parse Any data do file_code or file_id

Implementation

static String parseToFileId({
  required dynamic data,
}) {
  try {
    if (data is String) {
      if (RegExp("(^(http(s)?)|(/))", caseSensitive: false).hasMatch(data) ==
          false) {
        return data;
      }
      return Uri.parse(data).pathSegments.lastOrNull ?? "";
    } else if (data is Uri) {
      return data.pathSegments.lastOrNull ?? "";
    }
  } catch (e) {}
  return "";
}