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.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:web_browser_detect/web_browser_detect.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    // final browser = Browser(); // throws exception if not on web platform

    final browser = Browser.detectOrNull(); // return null if not on web platform

    // You provide your own userAgent & vendor, works crossplatform
    // final browser = Browser.detectFrom(userAgent: window.navigator.userAgent, vendor: window.navigator.vendor, appVersion: window.navigator.appVersion);

    return MaterialApp(
      title: 'web_browser_detect Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: Material(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text('The browser is ${browser?.browser ?? 'Wrong platform'}'),
            Text('Browser version is ${browser?.version ?? 'Wrong platform'}'),
          ],
        ),
      ),
    );
  }
}
16
likes
160
points
15k
downloads

Publisher

verified publishertomas-chyly.com

Weekly Downloads

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