Files
fcs/lib/widget/badge.dart
2020-05-29 07:45:27 +06:30

44 lines
1.3 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
Widget badgeCounter(int counter, {VoidCallback onPressed}) {
return InkWell(
onTap: () => onPressed(),
child: new Stack(
children: <Widget>[
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()
],
),
);
}