mhmzdev/awesome_snackbar_content

snackbar size

Closed this issue · 5 comments

How can I change the size of the snackbar according to the size of the message?"

Hello, do you mean somewhat making it like a flexible widget where the size of the message text can resize the entire widget while also maintaining a constraint of minimum width?

yes i mean that. Additionally, if possible, the message should appear where my click event is.

Alrighty then, i'll give it a shot.

The first part is doable from the package side of things with a toggle (an optional boolean, first set to the default behaviour) that'll let you choose if you want the widget to take a fixed width or a flexible one. (Gotta think of a good name for the toggle, probably bool? isWidthFixed; or something like that, set to true at first)

The second part could be done from the package side but it'd require quite a few refactoring on the package that might cause issues for other platforms. (But if the demand is high, i'm sure our community can provide either a generic solution to it or a platform specific one for each🙂). However, its much simpler to implement it on the client side, and so here's my solution for you, I'd encourage you to have a look here first and let me know if that's the type of behaviour you are looking for (except for the ctrl + clicking part, or you want that too 🤷‍♂️)

Since AwesomeSnackbarContent is a StatefulWidget it can be be nested in any other widget (unless they're of a specific type ofcourse), now i'm not sure if you can embed it in the MenuAnchor children (as it might require the children to be of specific type and I don't use so much of it myself), however i do use the Flyout widget from fluent_ui as it has much flexibility and better yet, allows you to embed any widget in it. I use it for all sorts of pop ups, like emoji pickers for chat boxes, drop down menus, etc..

Assuming you aren't using fluent_ui as your main structure, I have to point out that there are some caveats of using fluent_ui, like for example , it might be lets say "overcompensating" only using one component when its a whole library (plugin actually just like material but with windows design) and when using a component from fluent_ui, its ancestor widget has to be of type FluentTheme or AnimatedFluentTheme (although you can counter that by just wrapping the whole flyout in that widget and giving it a data property ,just make sure to have your own StatelessClass for the whole flyout thing, so as to not duplicate code all over) and i have to point out, that it also conflicts with material mostly, so you would have to do something like this import package:fluent_ui/fluent_ui.dart show FluentTheme, Flyout, oh did i also mention you have to use Flutter Stable Channel.
So yeah, its a bit of a drag if you aren't using it already but I already use fluent_ui design for my windows applications so its great for me, if you decide to use or are using fluent_ui, i'll share a code snippet for you to help you achieve the desired behaviour, but if you aren't gonna use fluent_ui, i'll look into other methods to help you achieve that in material / cupertino.

Also please keep in mind that, i'm not a maintainer nor a collaborator, yet, I have however submitted a PR addressing a major issue which basically makes your app run (caused by conflicts in the package dependencies) but unfortunately @mhmzdev is quite busy i assume and hasn't merged it yet.

Anyhow, assuming i have time on my hands, I'll create a new branch on my forked repo, test it out, and i'll let you know when i'm done with it. keep this issue open.

Edit (10 minutes later): The Original PR has been merged, thanks @mhmzdev

Sorry bro was busy with some work @JohnF17 , thanks for the PR its merged and new version has been published.
@AdemYavuzCelik did you mean the height or width of the snackbar?

is there anyway to increase the size of snackbar. in some phones its overflowing

Screenshot from 2024-02-07 16-41-52