flutter_badged 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 70

flutter_badge #

Badge for showing with icon

How to use #

This widget can be used anywhere, but example will be with bottom navigation.

Different cases of usage:

FlutterBadge(
          icon: Icon(Icons.message),
          borderRadius: 20.0,
          itemCount: 3,
        )
FlutterBadge(
          icon: Image.asset("assets/ic_message.png"),
          hideZeroCount: false,
          badgeColor: Colors.greenAccent,
          itemCount: 15,
        )
FlutterBadge(
          icon: Icon(Icons.home),
          badgeColor: Colors.greenAccent,
          badgeTextColor: Colors.red,
          position: BadgePosition.bottomLeft(),
          itemCount: 231,
        )

[1.0.1] - 03.06.2020 #

  • Added example and improved documentation

[1.0.0] - 10.02.2020 #

  • Created library

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_badged/flutter_badge.dart';
import 'package:flutter_badged/badge_position.dart';

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'FlutterBadged Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'FlutterBadged Demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text(widget.title),
        actions: [
          IconButton(
            icon: FlutterBadge(
              icon: Icon(Icons.photo_library),
              itemCount: 2,
            ),
            onPressed: (){},
          )
        ],
      ),
      body: Container(),
      bottomNavigationBar: BottomNavigationBar(
        items: [
          BottomNavigationBarItem(
            title: Text("Home"),
              icon: FlutterBadge(
                icon: Icon(Icons.home),
                itemCount: 3,
                borderRadius: 20.0,
              )),
          BottomNavigationBarItem(
              title: Text("Messages"),
              icon: FlutterBadge(
                icon: Icon(Icons.message),
                itemCount: 33,
                badgeColor: Colors.green,
                position: BadgePosition.topLeft(),
                borderRadius: 20.0,
              )),
          BottomNavigationBarItem(
              title: Text("Favorites"),
              icon: FlutterBadge(
                icon: Icon(Icons.favorite_border),
                itemCount: 333,
                badgeColor: Colors.orange,
                hideZeroCount: false,
                borderRadius: 20.0,
              )),
        ],
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_badged: ^1.0.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support 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:flutter_badged/badge_position.dart';
import 'package:flutter_badged/badge_positioned.dart';
import 'package:flutter_badged/flutter_badge.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
39
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
70
Learn more about scoring.

We analyzed this package on Jul 9, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • flutter_badged that is a package requiring null.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.1
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test