showSnackBar static method
void
showSnackBar({})
Implementation
static void showSnackBar(
{required BuildContext context,
required String text,
String label = 'INFO: ',
Color color = Colors.purple,
int duration = 3,
double fontSize = 15.0}) {
final snackBar = SnackBar(
backgroundColor: color,
elevation: 3,
dismissDirection: DismissDirection.endToStart,
margin: const EdgeInsets.all(20.0),
action: SnackBarAction(
label: 'OK',
onPressed: () => ScaffoldMessenger.of(context).hideCurrentSnackBar(),
textColor: Colors.white,
disabledTextColor: Colors.grey,
),
behavior: SnackBarBehavior.floating,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(10))),
padding: const EdgeInsets.all(20),
content: Text.rich(TextSpan(children: <InlineSpan>[
TextSpan(
text: label,
style: TextStyle(fontSize: fontSize, fontWeight: FontWeight.w500),
),
TextSpan(
text: text,
style: TextStyle(fontSize: fontSize),
)
])),
duration: Duration(seconds: duration),
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
}