openFile method

Future<void> openFile(
  1. File file
)

Opens the file.

Throws StateError if called inside a browser.

Example

import 'dart:io';
import 'package:universal_html/controller.dart';

void main() {
  final controller = WindowController();
  controller.openFile(File('index.html'));
}

Implementation

Future<void> openFile(File file) async {
  if (isTopLevelWindowInsideBrowser) {
    throw StateError('Failed to mutate the main window inside a browser');
  }
  final content = await file.readAsString();
  return openContent(content);
}