onFile method

Future<bool> onFile(
  1. File file
)

Implementation

Future<bool> onFile(FILE.File file) async
{
    busy = true;

    // save file reference
    if ((scope?.files != null) && (file.url != null))  scope!.files[file.url!] = file;

    // build the data
    Data data = Data();
    Map<dynamic, dynamic> map = Map<dynamic, dynamic>();
    map['file'] = file.url;
    map['name'] = file.name;
    map['type'] = file.mimeType;
    map['extension'] = ".${file.name}".split('.').last;
    map['size'] = file.size;

    if (WidgetModel.isBound(this, "$id.data.text"))
    {
      await file.read();
      map['text'] = "";
      if (file.bytes != null) map["text"] = utf8.decode(file.bytes!);
    }

    // add map
    data.add(map);

    // notify listeners
    onSuccess(data);

  return true;
}