user_agent 2.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 69

user_agent #

Simple Dart user agent detection library.

Runs anywhere.

Incorporates some code from the old package:r2d2.

main() async {
    app.get('/', (req, res) async {
        var ua = new UserAgent(req.headers.value('user-agent'));

        if (ua.isChrome) {
        } else {
            // ...

Changelog #

2.0.0 #

  • Dart 2 updates.

0.0.1 #

  • Initial version, created by Stagehand


import 'package:user_agent/user_agent.dart';

void main() {
  var ua = new UserAgent(
      'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36');

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  user_agent: ^2.0.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:user_agent/user_agent.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Oct 16, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:user_agent/user_agent.dart.

Health suggestions

Fix lib/user_agent.dart. (-3.93 points)

Analysis of lib/user_agent.dart reported 8 hints, including:

line 3 col 1: Prefer using /// for doc comments.

line 176 col 3: Prefer using /// for doc comments.

line 186 col 3: Prefer using /// for doc comments.

line 196 col 3: Prefer using /// for doc comments.

line 206 col 3: Prefer using /// for doc comments.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is getting outdated. (-9.59 points)

The package was last published 57 weeks ago.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
Dev dependencies
test ^1.0.0