web_browser_detect 2.1.0 copy "web_browser_detect: ^2.1.0" to clipboard
web_browser_detect: ^2.1.0 copied to clipboard

Flutter Web browser detection package. This package allows you to detect which browser and its version is in use.

web_browser_detect #

FlutterWeb browser detection package. This package helps you to detect current browser and version of the browser.

Warning: Remember that browser detection using UserAgent is never completely reliable. Therefore if you have some other way to do what you want to do, then do not use this package.

Contents #

Installation #

In your project's pubspec.yaml add:

dependencies:
  web_browser_detect: ^2.1.0
copied to clipboard

How to Use #

  1. If your IDE does not autoImport, add manually:
import 'package:web_browser_detect/web_browser_detect.dart';
copied to clipboard
  1. Create Browser object and then you can access detected values.
import 'package:web_browser_detect/web_browser_detect.dart';

void main() {
  final browser = Browser();

  print('${browser.browser} ${browser.version}');
}
copied to clipboard

Or you can use alternative method, which does not throw Exception when you are on other platforms then web, this way you get null, if you are not on web.

import 'package:web_browser_detect/web_browser_detect.dart';

void main() {
  final browser = Browser.detectOrNull();

  print('${browser?.browser ?? 'Wrong platform'} ${browser?.version ?? 'Wrong platform'}');
}
copied to clipboard

If you want to detect Browser on other platform from your own provided userAgent, vendor & appVersion.

import 'package:web_browser_detect/web_browser_detect.dart';

void main() {
  final browser = Browser.detectFrom(userAgent: userAgent, vendor: vendor, appVersion: appVersion);

  print('${browser.browser} ${browser.version}');
}
copied to clipboard

Important Notes #

Obviously this package supports only Flutter Web platform, it will not work on others. Additionally it does not support all current or past browsers, but PRs to add more are welcome.

16
likes
160
points
17.3k
downloads

Publisher

verified publishertomas-chyly.com

Weekly Downloads

2024.09.26 - 2025.04.10

Flutter Web browser detection package. This package allows you to detect which browser and its version is in use.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, web

More

Packages that depend on web_browser_detect