import 'package:flutter/material.dart'; class ToastBar { static Future showToastBar(BuildContext context, String content, {bool error = false, String? actionLabel, Function? actionCallback}) async { SnackBar snackBar = SnackBar( action: actionLabel != "" ? SnackBarAction( label: actionLabel!, onPressed: () { if (actionCallback != null) actionCallback(); }, textColor: Theme.of(context).colorScheme.secondary) : null, backgroundColor: error == true ? Colors.red : Colors.grey[900], behavior: SnackBarBehavior.floating, duration: Duration(seconds: 5), elevation: 5.0, content: Text( content, style: TextStyle(color: Colors.white), overflow: TextOverflow.ellipsis, ), ); ScaffoldMessenger.of(context).showSnackBar(snackBar); } }