browser_launcher 1.1.3 copy "browser_launcher: ^1.1.3" to clipboard
browser_launcher: ^1.1.3 copied to clipboard

Provides a standardized way to launch web browsers for testing and tools.

example/main.dart

// Copyright (c) 2024, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:browser_launcher/browser_launcher.dart';

const _googleUrl = 'https://www.google.com/';
const _googleImagesUrl = 'https://www.google.com/imghp?hl=en';

Future<void> main() async {
  // Launches a chrome browser with two tabs open to [_googleUrl] and
  // [_googleImagesUrl].
  await Chrome.start([_googleUrl, _googleImagesUrl]);
  print('launched Chrome');

  // Pause briefly before opening Chrome with a debug port.
  await Future<void>.delayed(const Duration(seconds: 3));

  // Launches a chrome browser open to [_googleUrl]. Since we are launching with
  // a debug port, we will use a variety of different launch configurations,
  // such as launching in a new browser.
  final chrome = await Chrome.startWithDebugPort([_googleUrl], debugPort: 8888);
  print('launched Chrome with a debug port');

  // When running this dart code, observe that the browser stays open for 3
  // seconds before we close it.
  await Future<void>.delayed(const Duration(seconds: 3));

  await chrome.close();
  print('closed Chrome');
}
14
likes
160
pub points
98%
popularity

Publisher

verified publishertools.dart.dev

Provides a standardized way to launch web browsers for testing and tools.

Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

logging, path, webkit_inspection_protocol

More

Packages that depend on browser_launcher