user_agent 2.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 58

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 Apr 8, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Health suggestions

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

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

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

line 17 col 60: Avoid const keyword.

line 108 col 60: Avoid const keyword.

line 135 col 60: Avoid const keyword.

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

Maintenance suggestions

Package is getting outdated. (-57.26 points)

The package was last published 82 weeks ago.

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 Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
Dev dependencies
test ^1.0.0