Closed prashant-singh-maersk closed 7 months ago
Hey @prashant-singh-maersk Can you provide a simple code for better understanding?
If you want to set width to your toast via showCustom
Why you are not using SizedBox ?
Hey @prashant-singh-maersk Can you provide a simple code for better understanding?
something like
toastification.showCustom(
context: context,
alignment: position,
width: 500,
.....
);
If you want to set width to your toast via showCustom
Why you are not using SizedBox?
We can not set the width using the sized box, because the package is setting the width of the overlay entry through ToastificationConfigProvider or ToastificationConfig by default, so no matter what width we set through widgets, it will never be more than the constraint set at the parent level.
check line 196-200
you want something like this right?
example code:
toastification.showCustom(
builder: (BuildContext context, ToastificationItem holder) {
return Align(
alignment: Alignment.centerRight,
child: Container(
color: Colors.blue,
height: 100,
width: 300,
margin: const EdgeInsets.all(8),
),
);
},
);
you want something like this right?
example code:
toastification.showCustom( builder: (BuildContext context, ToastificationItem holder) { return Align( alignment: Alignment.centerRight, child: Container( color: Colors.blue, height: 100, width: 300, margin: const EdgeInsets.all(8), ), ); }, );
I understand, this would work if your width is less than 400. (The above example has a width 300) but I'll not be able to set the width to more than 400, try to give 600 width
Did you use config provider?
With the config provider, you can set the width of the whole overlay
I think this is the thing that you want
https://github.com/payam-zahedi/toastification?tab=readme-ov-file#globaldefault-configuration
@prashant-singh-maersk Maybe I need to rename itemWidth
in the config Provider to make it more readable.
@payam-zahedi I appreciate your patience. I am aware of the config provider, yes we can set the width using config provider. but wanted to know if we can give a width option in the showCustom function itself,
eg: alignment can be given in config provider and showCustom function, showCustom property one takes the priority
same way can we have a width option in showCustom function ?
I guess there is a miss understanding here
we have itemWidth in the config file that we use to set the width of the animated list that we have in our overlay
and you can use show custom and set some width to your toast
these are different
we can not change the width of the animated list every time that you want to build a toast
imagine if you could set some width in the show custom method it would change all the width of the toasts
I guess we can close this issue for now
but, feel free to ask any question about it
Describe the solution you'd like Currently we can set the width of toast item only through ToastificationConfigProvider, can we also have width argument in the show and showCustom function which would set the width of the item
Additional context I am trying to make a reusable flutter toast widget, I don't want to ask user to wrap in a ToastificationConfigProvider