0

My Goal

I want to display the Flutter's default SnackBar with a ListTile as content.

The problem

For some reason, the Snackbar is almost three times higher than I wanted and seems there is no parameter in the Snackbar to set height.

I checked similar questions, didn't find a working example.

The SnackBar

void showSuccessSnackBar({BuildContext context, String message}) {
  Scaffold.of(context).showSnackBar(
    SnackBar(
      content: Container(
        child: ListTile(
            leading: _successIcon(),
            dense: true,
            title: Text(
              message,
              textAlign: TextAlign.center,
              style: TextStyle(
                color: HATheme.HOPAUT_PINK,
                fontWeight: FontWeight.bold
              ),
            )),
      ),
      behavior: SnackBarBehavior.floating,
      duration: Duration(seconds: 3),
      backgroundColor: Colors.white));
}

Widget _successIcon() {
  return Image.asset(
    'assets/icons/success.png',
    // resizing this doesn't help
    height: 30,
    width: 30,
  );
}

The size I want:

enter image description here

The actual size:

enter image description here

Gicu Mironica
  • 585
  • 8
  • 22

1 Answers1

1

you can add height to that container and your problem will be fixed

 Container(
    height: 10
    child: ListTile(
        leading: _successIcon(),
        dense: true,
        title: Text(
          message,
          textAlign: TextAlign.center,
          style: TextStyle(
            color: HATheme.HOPAUT_PINK,
            fontWeight: FontWeight.bold
          ),
        )
Ardeshir ojan
  • 1,914
  • 1
  • 13
  • 36