Coder Social home page Coder Social logo

rarescrap / flutter_badges Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yako-dev/flutter_badges

0.0 1.0 0.0 1.48 MB

A flutter package for creating badges.

Home Page: https://pub.dev/packages/badges

License: Apache License 2.0

Objective-C 3.41% Dart 93.17% Ruby 3.43%

flutter_badges's Introduction

Badges for Flutter

Pub Version

Installing:

In your pubspec.yaml

dependencies:
  badges: ^1.2.0
import 'package:badges/badges.dart';


Breaking changes:

Check prerelease on pub.dev for null safety version If you want to use badges v1.2.0 and above, you need to upgrade your flutter version at least to v1.22.0-12.0.pre..



Basic Usage:

    Badge(
      badgeContent: Text('3'),
      child: Icon(Icons.settings),
    )


Animations:

BadgeAnimationType.slide BadgeAnimationType.scale BadgeAnimationType.fade

Chips:

Sometimes you may want to use chip but it's too big, even if set padding to zero. This is where Badge comes handy.

    Chip(
      padding: EdgeInsets.all(0),
      backgroundColor: Colors.deepPurple,
      label: Text('BADGE', style: TextStyle(color: Colors.white)),
    ),
    Badge(
      toAnimate: false,
      shape: BadgeShape.square,
      badgeColor: Colors.deepPurple,
      borderRadius: BorderRadius.circular(8),
      badgeContent: Text('BADGE', style: TextStyle(color: Colors.white)),
    ),

Custom Usage

There are several options that allow for more control:

Properties Description
Widget badgeContent The content of badge. Usually Text or Icon.
Color badgeColor Background color of the badge.
Widget child The main widget. By default it's below the red badge. Usually Icon, IconButton, Text or button.
double elevation Shadow of the badge.
bool toAnimate Whether animate badge when badge content changed or not.
BadgePosition position Can be one of BadgePosition.topStart(), BadgePosition.topEnd(), BadgePosition.bottomStart(), BadgePosition.bottomEnd(). Sometimes you want to create unique badge position or create new one manually. For this use BadgePosition.topEnd(top: -12, end: -20) or BadgePosition(start, top, end, bottom).
BadgeShape shape BadgeShape.circle or BadgeShape.square. You can use borderRadius to change border radius of badge of you use square BadgeShape.square.
BorderRadiusGeometry borderRadius Border radius of badge. Applies only if BadgeShape.square is used.
EdgeInsetsGeometry padding The padding of badge content.
Duration animationDuration The duration of badge animation when badge content is changed.
BadgeAnimationType animationType Can be one of BadgeAnimationType.slide, BadgeAnimationType.scale or BadgeAnimationType.fade.
bool showBadge Hide or show badge with animation using bool flag.
AlignmentGeometry alignment Alignment of the whole widget
bool ignorePointer Enable or disable (default) ignore pointer option
BorderSide borderSide Adds a border to the badge


License

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

flutter_badges's People

Contributors

bcihanc avatar mideb avatar radvansky-tomas avatar royibernthal avatar saifallak avatar simonit avatar victoruvarov avatar worldofsites avatar yadaniyil avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.