Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Lecarvalho/22fc4961fd0e54a6054872a1678dc44c to your computer and use it in GitHub Desktop.
Save Lecarvalho/22fc4961fd0e54a6054872a1678dc44c to your computer and use it in GitHub Desktop.
Icon with a red dot to presume a notification
import 'package:flutter/material.dart';
class IconButtonRedDotNotificationWidget extends StatelessWidget {
final IconData icon;
final Function onTap;
IconButtonRedDotNotificationWidget(this.icon, {this.onTap});
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
IconButton(
icon: Icon(icon),
onPressed: onTap,
),
_redDot(),
],
);
}
Widget _redDot() {
return Positioned(
right: 20,
top: 15,
child: Container(
decoration: new BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(7),
),
constraints: BoxConstraints(
minWidth: 10,
minHeight: 10,
),
child: Container(
width: 1,
height: 1,
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment