file_system_access_api 0.1.0 copy "file_system_access_api: ^0.1.0" to clipboard
file_system_access_api: ^0.1.0 copied to clipboard

A Dart library to expose the File System Access Api from web platform.

example/example.dart

import 'dart:html';

import 'package:file_system_access_api/file_system_access_api.dart';

import 'light_storage.dart';
import 'view.dart';

extension HtmlElementState on HtmlElement {
  void show() {
    style.display = "";
  }

  void hide() {
    style.display = "none";
  }
}

final view = View();

void main() async {
  if (!FileSystemAccess.supported || !LightStorage.supported) {
    view.$unsupported.show();
    return;
  }
  view.$unsupported.remove();
  view.$header.show();
  view.$about.show();

  LightStorage db = LightStorage();

  await db.open();
  await view.init(db);

  view.redirectTab();
}

/// Return true when permission is granted on [handle] with [mode] access, false otherwise.
Future<bool> verifyPermission(FileSystemHandle handle, {PermissionMode mode = PermissionMode.read}) async {
  var permission = await handle.queryPermission(mode: mode);

  if (permission == PermissionState.granted) {
    return true;
  }
  permission = await handle.requestPermission(mode: mode);
  return permission == PermissionState.granted;
}
20
likes
0
pub points
76%
popularity

Publisher

verified publisherlouispoirier.io

A Dart library to expose the File System Access Api from web platform.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

js

More

Packages that depend on file_system_access_api