badges 0.0.6

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 86

Badges for Flutter

A flutter package for creating badges.

Package on Pub

Installing:

In your pubspec.yaml

dependencies:
  badges: ^0.0.6

Example Usage:

import 'package:badges/badges.dart';

BadgeIconButton(
                itemCount: _counter, // required
                icon: Icon(Icons.shopping_cart), // required
                badgeColor: Colors.green, // default: Colors.red
                badgeTextColor: Colors.white, // default: Colors.white
                hideZeroCount: true, // default: true
                onPressed: _increment),
                

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details

[0.0.1] - TODO: Add release date.

  • TODO: Describe initial release.

example/lib/main.dart

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: _buildTheme(),
      home: MyHomePage(),
    );
  }
}

ThemeData _buildTheme() {
  final ThemeData base = ThemeData.light();
  return base.copyWith(
      primaryIconTheme: base.iconTheme.copyWith(color: Colors.black));
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;
  Color _color = Colors.red;
  Icon _icon = Icon(Icons.shopping_cart);

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  void _changeBadgeColor() {
    setState(() {
      if (_color == Colors.red)
        _color = Colors.blue;
      else
        _color = Colors.red;
    });
  }

  void _changeIcon() {
    setState(() {
      if (_icon.icon == Icons.shopping_cart)
        _icon = Icon(Icons.email, color: Colors.deepOrange);
      else
        _icon = Icon(Icons.shopping_cart);
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('Badge Demo', style: TextStyle(color: Colors.black)),
          backgroundColor: Colors.white,
          actions: <Widget>[
            BadgeIconButton(
                itemCount: _counter,
                badgeColor: _color,
                badgeTextColor: Colors.white,
                icon: _icon,
                onPressed: () {}),
          ],
        ),
        body: Column(
          children: <Widget>[
            incrementButton,
            changeColorButton,
            changeIconButton,
          ],
        ));
  }

  Widget get changeColorButton {
    return Padding(
      padding: const EdgeInsets.all(8.0),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          RaisedButton(
            onPressed: _changeBadgeColor,
            child: Text('Change badge color'),
          )
        ],
      ),
    );
  }

  Widget get changeIconButton {
    return Padding(
      padding: const EdgeInsets.all(8.0),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          RaisedButton(
            onPressed: _changeIcon,
            child: Text('Change icon'),
          )
        ],
      ),
    );
  }

  Widget get incrementButton {
    return Padding(
      padding: const EdgeInsets.all(8.0),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          RaisedButton(
            child: Text('Increment'),
            onPressed: _incrementCounter,
          ),
        ],
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  badges: ^0.0.6

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


import 'package:badges/badges.dart';
  
Version Uploaded Documentation Archive
0.0.6 Sep 15, 2018 Go to the documentation of badges 0.0.6 Download badges 0.0.6 archive
0.0.5 Aug 12, 2018 Go to the documentation of badges 0.0.5 Download badges 0.0.5 archive
0.0.4 Aug 2, 2018 Go to the documentation of badges 0.0.4 Download badges 0.0.4 archive
0.0.3 Aug 2, 2018 Go to the documentation of badges 0.0.3 Download badges 0.0.3 archive
0.0.2 Aug 2, 2018 Go to the documentation of badges 0.0.2 Download badges 0.0.2 archive
0.0.1 Aug 2, 2018 Go to the documentation of badges 0.0.1 Download badges 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
84
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
86
Learn more about scoring.

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

  • Dart: 2.0.0
  • pana: 0.12.4
  • Flutter: 0.9.5

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/badges.dart.

Run flutter format to format lib/badges.dart.

Maintenance suggestions

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Package is pre-v0.1 release. (-10 points)

While there is nothing inherently wrong with versions of 0.0.*, it usually means that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test