getFiles method

  1. @visibleForTesting
Future<List<XFile>> getFiles({
  1. String? accept,
  2. String? capture,
  3. bool multiple = false,
})

Injects a file input with the specified accept+capture attributes, and returns a list of XFile that the user selected locally.

capture is only supported in mobile browsers.

multiple can be passed to allow for multiple selection of files. Defaults to false.

See https://caniuse.com/#feat=html-media-capture

Implementation

@visibleForTesting
Future<List<XFile>> getFiles({
  String? accept,
  String? capture,
  bool multiple = false,
}) {
  html.FileUploadInputElement input = createInputElement(
    accept,
    capture,
    multiple: multiple,
  ) as html.FileUploadInputElement;
  _injectAndActivate(input);

  return _getSelectedXFiles(input);
}