Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we shrink snackbar to wrap its content or to some custom width? #18

Closed
rasitayaz opened this issue Dec 18, 2021 · 3 comments
Closed

Comments

@rasitayaz
Copy link

rasitayaz commented Dec 18, 2021

I want the snackbar to be placed on top center of my application and not to expand through screen width. I tried wrapping my custom snackbar with a Row widget but it throws bunch of following exceptions:

Assertion failed:
!_debugDuringDeviceUpdate
is not true
@vizhan-lanars
Copy link
Collaborator

You could try this

Material(
      color: Colors.transparent,
      child: Center(
        child: Container(
          width: MediaQuery.of(context).size.shortestSide,
          decoration: BoxDecoration(
            color: color,
            borderRadius: BorderRadius.all(Radius.circular(4)),
          ),
          child: Text(
            message,
            style: ThemeProvider.robotoRegular14,
            textAlign: TextAlign.center,
          ),
        ),
      ),
    )
    ```

@rasitayaz
Copy link
Author

I just resolved this by wrapping my custom snackbar with a Row and giving following properties:

mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,

@Kerimkullov
Copy link

Just wrap parent container with Center widget

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants