import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; Widget badgeCounter(int counter, {VoidCallback onPressed}) { return InkWell( onTap: () => onPressed(), child: new Stack( children: [ new IconButton( padding: EdgeInsets.only(top: 10), icon: Icon(Icons.notifications), onPressed: () { onPressed(); }), counter != 0 ? new Positioned( right: 11, top: 11, child: new Container( padding: EdgeInsets.all(2), decoration: new BoxDecoration( color: Colors.blue, borderRadius: BorderRadius.circular(6), ), constraints: BoxConstraints( minWidth: 14, minHeight: 14, ), child: Text( '+${counter > 99 ? 99 : counter}', style: TextStyle( color: Colors.white, fontSize: 10, ), textAlign: TextAlign.center, ), ), ) : new Container() ], ), ); }