enableTimeline method

  1. @visibleForTesting
Future<void> enableTimeline({
  1. List<String> streams = const <String>['all'],
  2. @visibleForTesting VmService? vmService,
  3. @visibleForTesting HttpClient? httpClient,
})

Initialize the vm.VmService settings for the timeline.

Implementation

@visibleForTesting
Future<void> enableTimeline({
  List<String> streams = const <String>['all'],
  @visibleForTesting vm.VmService? vmService,
  @visibleForTesting HttpClient? httpClient,
}) async {
  assert(streams.isNotEmpty);
  if (vmService != null) {
    _vmService = vmService;
  }
  if (_vmService == null) {
    final developer.ServiceProtocolInfo info = await developer.Service.getInfo();
    assert(info.serverUri != null);
    final String address = 'ws://localhost:${info.serverUri!.port}${info.serverUri!.path}ws';
    try {
      _vmService = await _vmServiceConnectUri(address, httpClient: httpClient);
    } on SocketException catch (e, s) {
      throw StateError(
        'Failed to connect to VM Service at $address.\n'
        'This may happen if DDS is enabled. If this test was launched via '
        '`flutter drive`, try adding `--no-dds`.\n'
        'The original exception was:\n'
        '$e\n$s',
      );
    }
  }
  await _vmService!.setVMTimelineFlags(streams);
}