parent property
- @Deprecated('Will be removed in 3.0.0. See https://github.com/rrousselGit/riverpod/issues/3261#issuecomment-1973514033')
final
Explicitly override the parent ProviderContainer that this ProviderScope would be a descendant of.
A common use-case is to allow modals to access scoped providers, as they would otherwise be unable to since they would be in a different branch of the widget tree.
That can be achieved with:
ElevatedButton(
onTap: () {
final container = ProviderScope.containerOf(context);
showDialog(
context: context,
builder: (context) {
return ProviderScope(parent: container, child: MyModal());
},
);
},
child: Text('show modal'),
)
The parent variable must never change.
Implementation
@Deprecated(
'Will be removed in 3.0.0. See https://github.com/rrousselGit/riverpod/issues/3261#issuecomment-1973514033',
)
final ProviderContainer? parent;