import 'package:flutter/material.dart'; class IconBadge extends StatefulWidget { final IconData icon; final double size; final Color color; IconBadge({Key key, @required this.icon, this.size, this.color}) : super(key: key); @override _IconBadgeState createState() => _IconBadgeState(); } class _IconBadgeState extends State { int counter = 0; @override void initState() { super.initState(); } @override Widget build(BuildContext context) { return Stack( children: [ Icon( widget.icon, size: widget.size, color: widget.color ?? null, ), Positioned( right: 0.0, top: 0.0, child: Container( padding: EdgeInsets.all(1), decoration: BoxDecoration( color: Theme.of(context).primaryColor, borderRadius: BorderRadius.circular(6), ), height: 12.0, width: 12.0, child: Container( padding: EdgeInsets.all(1), decoration: BoxDecoration( color: Colors.red[300], borderRadius: BorderRadius.circular(6), ), height: 7.0, width: 7.0, ), ), ), ], ); } }