You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In such cases, I am unsure what the benefit of menuBuilder would be. Can you provide a more elaborate example of what you are trying to achieve?
Speculation zone
I am not familiar with the bloc and my memory of provider is a bit skewed, but I assume you want to pass MyCubit down to a menu's route so that it can be accessed inside the menu items.
It is not needed IMO since the context provided by PullDownButton.itemBuilder is the context of the widget itself, not of the menu's route. So even if you could theoretically pass it with the menuBuilder, it would not have the desired effect.
You're better off just context.read/watch() directly in the required menu item's parameters.
Something like this has worked out pretty nicely for me with riverpod (adapted to bloc):
Widgetbuild(BuildContext context {
final filter = context.watch<MyCubit>();
// inside itemBuilder
(context) => [
for (final year in_someFuncThatReturnsAllowedYears())
PullDownMenuItem.selectable(
title:MaterialLocalizations.of(context).formatYear(DateTime(year)),
selected: year == filter.year,
onTap: () => context.read<MyCubit>().updateYear(year),
),
]
}
The text was updated successfully, but these errors were encountered: