Skip to content

Commit

Permalink
Changed IconData to Icon to have an ability to customise Icon
Browse files Browse the repository at this point in the history
  • Loading branch information
yadaniyil committed Sep 15, 2018
1 parent 5b1d98e commit 7f67f57
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A flutter package for creating badges.
In your pubspec.yaml
```yaml
dependencies:
badges: ^0.0.5
badges: ^0.0.6
```
## Example Usage:
Expand All @@ -20,7 +20,7 @@ import 'package:badges/badges.dart';

BadgeIconButton(
itemCount: _counter, // required
iconData: Icons.shopping_cart, // required
icon: Icon(Icons.shopping_cart), // required
badgeColor: Colors.green, // default: Colors.red
badgeTextColor: Colors.white, // default: Colors.white
hideZeroCount: true, // default: true
Expand Down
10 changes: 5 additions & 5 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class MyHomePage extends StatefulWidget {
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
Color _color = Colors.red;
IconData _iconData = Icons.shopping_cart;
Icon _icon = Icon(Icons.shopping_cart);

void _incrementCounter() {
setState(() {
Expand All @@ -46,10 +46,10 @@ class _MyHomePageState extends State<MyHomePage> {

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

Expand All @@ -64,7 +64,7 @@ class _MyHomePageState extends State<MyHomePage> {
itemCount: _counter,
badgeColor: _color,
badgeTextColor: Colors.white,
iconData: _iconData,
icon: _icon,
onPressed: () {}),
],
),
Expand Down
8 changes: 4 additions & 4 deletions lib/src/badge_icon_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ class BadgeIconButton extends StatefulWidget {
final int itemCount;
final Color badgeColor;
final Color badgeTextColor;
final IconData iconData;
final Icon icon;
final bool hideZeroCount;

BadgeIconButton({
Key key,
@required this.itemCount,
@required this.iconData,
@required this.icon,
this.onPressed,
this.hideZeroCount: true,
this.badgeColor: Colors.red,
Expand Down Expand Up @@ -43,7 +43,7 @@ class BadgeIconButtonState extends State<BadgeIconButton>
Widget build(BuildContext context) {
if (widget.hideZeroCount && widget.itemCount == 0) {
return IconButton(
icon: Icon(widget.iconData),
icon: widget.icon,
onPressed: widget.onPressed,
);
}
Expand All @@ -52,7 +52,7 @@ class BadgeIconButtonState extends State<BadgeIconButton>
icon: Stack(
overflow: Overflow.visible,
children: [
Icon(widget.iconData),
widget.icon,
Positioned(
top: -8.0,
right: -3.0,
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: badges
description: A flutter package for creating badges.
version: 0.0.5
version: 0.0.6
author: Daniyil Yakovlev <[email protected]>
homepage: https://github.com/yadaniil/flutter_badges
homepage: https://github.com/yadaniyil/flutter_badges

dependencies:
flutter:
Expand Down

0 comments on commit 7f67f57

Please sign in to comment.