uriString property

String get uriString

Implementation

String get uriString {
  // serialize
  MutableMapping dict = _wrapper.toMap();
  // check 'URL'
  Uri? remote = url;
  if (remote != null) {
    int count = dict.length;
    if (count == 1) {
      // this PNF info contains 'URL' only,
      // so return the URI string here.
      return remote.toString();
    } else if (count == 2 && containsKey('filename')) {
      // ignore 'filename'
      return remote.toString();
    }
    // this PNF info contains other params,
    // cannot serialize it as a string.
    return '';
  }
  // check data
  String? text = getString('data');
  if (text != null && text.startsWith('data:')) {
    int count = dict.length;
    if (count == 1) {
      // this PNF info contains 'data' only,
      // and it is a data URI,
      // so return the URI string here.
      return text;
    } else if (count == 2) {
      // check filename
      String? filename = getString('filename');
      if (filename != null && filename.isNotEmpty) {
        // TODO: add 'filename' to data URI
        return text;
      }
    }
    // this PNF info contains other params,
    // cannot serialize it as a string.
    return '';
  }
  // the file data was saved into local storage,
  // so there is just a 'filename' here,
  // cannot build URI string
  return '';
}