createFlutterDriver method

Future<FlutterDriver> createFlutterDriver (
  1. [String dartVmServiceUrl]
)

Implementation

Future<FlutterDriver> createFlutterDriver([String dartVmServiceUrl]) async {
  final completer = Completer<FlutterDriver>();
  dartVmServiceUrl = (dartVmServiceUrl ?? _observatoryDebuggerUri) ??
      Platform.environment['VM_SERVICE_URL'];

  await runZonedGuarded(
    () async {
      if (onBeforeFlutterDriverConnect != null) {
        await onBeforeFlutterDriverConnect();
      }

      final driver = await _attemptDriverConnection(dartVmServiceUrl, 1, 3);
      if (onAfterFlutterDriverConnect != null) {
        await onAfterFlutterDriverConnect(driver);
      }

      completer.complete(driver);
    },
    (Object e, StackTrace st) {
      if (e is DriverError) {
        completer.completeError(e, st);
      }
    },
  );

  return completer.future;
}