ConditionalParentBuilder constructor
const
ConditionalParentBuilder({
- Key? key,
- required ParentBuilder builder,
- required Widget child,
A widget that allows developers to conditionally wrap the child widget with a parent widget.
In the following real-world example, we conditionally wrap the child widget tree with a context menu if the message is not deleted:
ConditionalParentBuilder(
builder: (context, child) {
if (!widget.message.isDeleted) {
return ContextMenuArea(
builder: (context) => buildContextMenu(),
child: child,
);
} else {
return child;
}
},
child: Material(...),
),
This example can be found in the stream_chat_flutter
source code under
src/message_widget/message_widget.dart
.
Implementation
const ConditionalParentBuilder({
super.key,
required this.builder,
required this.child,
});