Spec-Zone.ru › Dart 2

dart:developer

Метод controlWebServer

Future<ServiceProtocolInfo> controlWebServer(
  1. {bool enable = false,
  2. bool? silenceOutput}
)

Управляет веб-сервером, через который происходит доступ к протоколу службы. enable используется в качестве переключателя для включения или выключения веб-сервера, обрабатывающего запросы. Если silenceOutput предоставлен и имеет значение true, сервер не будет выводить информацию в консоль.

Реализация

static Future<ServiceProtocolInfo> controlWebServer(
    {bool enable = false, bool? silenceOutput}) async {
  // TODO: When NNBD is complete, delete the following line.
  ArgumentError.checkNotNull(enable, 'enable');
  // Port to receive response from service isolate.
  final RawReceivePort receivePort =
      new RawReceivePort(null, 'Service.controlWebServer');
  final Completer<String?> completer = new Completer<String?>();
  receivePort.handler = (String? uriString) => completer.complete(uriString);
  // Request the information from the service isolate.
  _webServerControl(receivePort.sendPort, enable, silenceOutput);
  // Await the response from the service isolate.
  String? uriString = await completer.future;
  Uri? uri = uriString == null ? null : Uri.parse(uriString);
  // Close the port.
  receivePort.close();
  return new ServiceProtocolInfo(uri);
}

© 2012 the Dart project authors
Licensed under the BSD 3-Clause "New" or "Revised" License.
https://api.dart.dev/stable/2.18.5/dart-developer/Service/controlWebServer.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API