WindowController class

Defines behavior of the browser APIs (such as navigation events).

Example

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

Future<void> main() async {
  final controller = WindowController();
  await controller.openHttp(
    method: 'GET',
    uri: Uri.parse('https://www.ietf.org/'),
  );
  final document = controller.window.document;
  // ...
}

Testing

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

void main() {
  setUp(() {
    WindowController.instance = WindowController();
  });

  test('test #1', () {
    // ...
  });

  test('test #2', () {
    // ...
  });
}

Constructors

WindowController()

Properties

defaultHttpClient HttpClient
Default HttpClient.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
isTopLevelWindowInsideBrowser bool
Returns true if this controller for the top-level window inside a browser.
no setter
onChooseHttpClient HttpClient Function(Uri uri)
Chooses HTTP client that will be used for the URL.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
window Window
Gets window controlled by this WindowController.
getter/setter pair
windowBehavior WindowBehavior
Behavior of the window.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
openContent(String content, {ContentType? contentType}) → void
Opens the content.
openFile(File file) Future<void>
Opens the file.
openHttp({String method = 'GET', required Uri uri, ContentType? contentType, void onRequest(HttpClientRequest request)?, void onResponse(HttpClientResponse response)?}) Future<void>
Loads content using HTTP client.
openUri(Uri uri) Future<void>
Loads content from a file or network URI.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

instance WindowController
Zone-local, mutable WindowController.
getter/setter pair
topLevel WindowController
Old alias for instance.
getter/setter pair

Static Methods

newZone() Zone
Enables zone-local WindowController instances.
newZoneWith(WindowController windowController) Zone
Returns a new Zone with the given windowController.