ChromeFileBrowserHandler class
class ChromeFileBrowserHandler extends ChromeApi { static final JsObject _fileBrowserHandler = chrome['fileBrowserHandler']; ChromeFileBrowserHandler._(); bool get available => _fileBrowserHandler != null; /** * Prompts user to select file path under which file should be saved. When the * file is selected, file access permission required to use the file (read, * write and create) are granted to the caller. The file will not actually get * created during the function call, so function caller must ensure its * existence before using it. The function has to be invoked with a user * gesture. * * [selectionParams] Parameters that will be used while selecting the file. * * Returns: * Result of the method. */ Future<Map> selectFile(FileBrowserHandlerSelectFileParams selectionParams) { if (_fileBrowserHandler == null) _throwNotAvailable(); var completer = new ChromeCompleter<Map>.oneArg(mapify); _fileBrowserHandler.callMethod('selectFile', [jsify(selectionParams), completer.callback]); return completer.future; } /** * Fired when file system action is executed from ChromeOS file browser. */ Stream<OnExecuteEvent> get onExecute => _onExecute.stream; final ChromeStreamController<OnExecuteEvent> _onExecute = new ChromeStreamController<OnExecuteEvent>.twoArgs(_fileBrowserHandler, 'onExecute', _createOnExecuteEvent); void _throwNotAvailable() { throw new UnsupportedError("'chrome.fileBrowserHandler' is not available"); } }
Extends
ChromeApi > ChromeFileBrowserHandler
Properties
final bool available #
Returns true if the API is available. The common causes of an API not being avilable are:
- a permission is missing in the application's manifest.json file
- the API is defined on a newer version of Chrome then the current runtime
docs inherited from ChromeApi
bool get available => _fileBrowserHandler != null;
final Stream<OnExecuteEvent> onExecute #
Fired when file system action is executed from ChromeOS file browser.
Stream<OnExecuteEvent> get onExecute => _onExecute.stream;
Methods
Future<Map> selectFile(FileBrowserHandlerSelectFileParams selectionParams) #
Prompts user to select file path under which file should be saved. When the file is selected, file access permission required to use the file (read, write and create) are granted to the caller. The file will not actually get created during the function call, so function caller must ensure its existence before using it. The function has to be invoked with a user gesture.
selectionParams Parameters that will be used while selecting the file.
Returns: Result of the method.
Future<Map> selectFile(FileBrowserHandlerSelectFileParams selectionParams) { if (_fileBrowserHandler == null) _throwNotAvailable(); var completer = new ChromeCompleter<Map>.oneArg(mapify); _fileBrowserHandler.callMethod('selectFile', [jsify(selectionParams), completer.callback]); return completer.future; }