withIcon static method
void
withIcon({})
A floating toast with a leading icon.
textThe message to display.iconThe icon shown to the left of the text.iconColorColor of the icon.colorBackground color.textColorColor of the message text.widthWidth of the snackbar. Defaults to 300.durationHow long the toast is visible. Defaults to 1200 ms.
Implementation
static void withIcon({
required BuildContext context,
required String text,
required IconData icon,
required Color iconColor,
required Color color,
required Color textColor,
double width = 300,
Duration duration = const Duration(milliseconds: 1200),
}) {
_show(
context,
SnackBar(
clipBehavior: Clip.antiAliasWithSaveLayer,
elevation: 0.5,
shape: const OutlineInputBorder(borderSide: BorderSide.none),
width: width,
behavior: SnackBarBehavior.floating,
duration: duration,
backgroundColor: color,
content: Row(
children: [
Container(
height: 32,
width: 32,
decoration: BoxDecoration(
color: color.withAlpha(60),
borderRadius: BorderRadius.circular(6),
),
child: Icon(icon, size: 20, color: iconColor),
),
const SizedBox(width: 12),
Expanded(
child: Text(text, style: TextStyle(color: textColor)),
),
],
),
),
);
}