For some reason when I was trying to show an alert dialog which needs a cubit created previously the cubit is not found.
As mentioned before when i am trying to provide a cubit with BlocProvider.value(value: context.read()), child: ...; to an alertDialog it wont find it...
SlidableAction(
backgroundColor: block.sperrgrund != null ? Colors.orange : Colors.green,
icon: block.sperrgrund != null ? Icons.lock : Icons.lock_open,
onPressed: block.sperrgrund == null ? (context) {
showDialog(
context: context,
builder: (context) {
return BlocProvider.value(
value: context.read<DropdownCubit<Sperrgrund>>(),
child: SperrenPopup(
block: block as ZinkScan,
cubit: this.cubit!,
),
);
}
);
} : null
)
Try this instead:
So, instead of the
contextprovided bybuilderit will be using thecontextof its parent to scope the blockProvider and wrapSlidableActionwithBuilderif you have defined theBlockProviderinside the same build method from where you are trying to show the dialog.