compressImageUrl static method

String compressImageUrl(
  1. String url, {
  2. int width = 0,
})

Implementation

static String compressImageUrl(String url, {int width = 0}) {
  try {
    if (url.startsWith('http') && width != 0) {
      if (url.endsWith('!user')) url = url.replaceAll('!user', '');
    }
    var spacing = url.contains('?') ? '&' : '?';
    return '$url${spacing}x-oss-process=image/resize,w_${width * 3}';
  } catch (e) {
    AppConfig.printLog(e);
  }
  return url;
}