showSnackBar function

void showSnackBar(
  1. BuildContext context,
  2. dynamic widget, {
  3. Duration? duration,
  4. double? containerHeight,
})

Implementation

void showSnackBar(BuildContext context, dynamic widget, {Duration? duration, double? containerHeight}) {
  ScaffoldMessenger.of(context).removeCurrentSnackBar();
  ScaffoldMessenger.of(context).showSnackBar(SnackBar(
    backgroundColor: canvasColor(context),
    duration: duration != null ? Duration(days: 1) : Duration(minutes: 1),
    content: widget.runtimeType == String
        ? Text(widget.toString(),
            style: TextStyle( fontWeight: FontWeight.bold))
        : duration == null
            ? Container(
                constraints: containerHeight != null
                    ? null
                    : BoxConstraints(
                        maxWidth: width(context),
                        maxHeight: (height(context) / 4),
                      ),
                height: containerHeight != null ? containerHeight : double.infinity,
                child: Column(
                  children: [
                    Container(
                      width: width(context),
                      child: Icon(Icons.drag_handle_rounded),
                    ),
                    widget
                  ],
                ),
              )
            : widget,
  ));
}