warning static method

void warning(
  1. dynamic message, {
  2. int? duration,
  3. bool showIcon = true,
})

Implementation

static void warning(dynamic message, {int? duration, bool showIcon = true}) {
  final snackBar = SnackBar(
    content: HStack([
      if (showIcon == true) Icon(Icons.info, color: Colors.orange[800]),
      12.widthBox,
      '$message'
          .text
          .color(Colors.black)
          .overflow(TextOverflow.ellipsis)
          .maxLines(3)
          .make()
          .expand(),
    ]).p12(),
    padding: EdgeInsets.all(0),
    backgroundColor: Colors.orange[50],
    behavior: SnackBarBehavior.floating,
    duration: Duration(seconds: duration ?? 2),
    shape: RoundedRectangleBorder(
      borderRadius: BorderRadius.circular(8),
      side: BorderSide(color: Colors.orange[800]!),
    ),
  );
  ScaffoldMessenger.of(Get.context!)
      .showSnackBar(snackBar)
      .closed
      .then((value) => ScaffoldMessenger.of(Get.context!).clearSnackBars());
}