Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.
/ browser_detector Public archive

Dart browser detector library. Detects popular browsers, engines and platforms by analyzing the user agent string.

License

Notifications You must be signed in to change notification settings

aicantar/browser_detector

Repository files navigation

browser_detector

Dart

Dart browser detector library. Detects popular browsers, engines and platforms by analyzing the user agent string. Safe to use with Flutter Native.

Usage

Basic usage:

import 'package:browser_detector/browser_detector.dart';

if (BrowserDetector().browser.isSafari) {
    // do something if the browser is safari
}

Custom user agent string:

import 'package:browser_detector/browser_detector.dart';

final firefoxUserAgent = '...';
print(BrowserDetector(firefoxUserAgent).browser.isFirefox); // true

Using with dependency injection/service locator libraries (GetIt example):

final getIt = GetIt.instance;

getIt.registerLazySingleton(
    () => BrowserDetector(),
);

final detector = getIt.get<BrowserDetector>();

Flutter Native

This library can be safely used with Flutter Native and won't produce any compilation errors. All isUnknown tests will return true when running in native mode.

If this library is used with a Flutter Web project, all objects (browser, platform and engine) will be detected properly.

Mentions

Some regular expressions are taken from the lancedickson/bowser library. Check it out if you need the same thing but in pure JS.

About

Dart browser detector library. Detects popular browsers, engines and platforms by analyzing the user agent string.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages