ContentBuilder<T extends ContentItem> class
A builder for configuring and managing content types and their layouts.
Content builders are responsible for:
- Registering content types with the content system
- Managing layout configurations for content types
- Initializing content descriptors
- Building content widgets
Each content type should have its own ContentBuilder that defines:
- The content type descriptor
- The default layout
- Additional layout options
Example:
class BlogPost extends ContentItem {
static const schemaName = 'blog.post';
static final typeDescriptor = TypeDescriptor(
schemaType: schemaName,
fromJson: BlogPost.fromJson,
title: 'Blog Post',
);
static final contentBuilder = ContentBuilder(
content: typeDescriptor,
defaultLayout: BlogPostLayout(),
defaultLayoutDescriptor: BlogPostLayout.typeDescriptor,
);
}
Constructors
-
ContentBuilder.new({required TypeDescriptor<
T> content, required LayoutConfiguration<T> defaultLayout, required TypeDescriptor<LayoutConfiguration< defaultLayoutDescriptor})T> > - Creates a new content builder.
Properties
-
content
→ TypeDescriptor<
T> -
The type descriptor for the content type
T
.final -
defaultLayout
→ LayoutConfiguration<
T> -
no setter
-
defaultLayoutDescriptor
→ TypeDescriptor<
LayoutConfiguration< T> > -
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
-
layouts
→ List<
TypeDescriptor< LayoutConfiguration< >ContentItem> > -
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sourceFeature → String?
-
no setter
Methods
-
build(
BuildContext context, T content) → Widget - Builds a widget for the given content item.
-
init(
List< ContentDescriptor> descriptors) → void - Initializes this content builder with the given descriptors.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerDescriptors<
U> (Iterable< TypeDescriptor< descriptors, {bool checkUnique = false}) → voidU> > - Registers a list of type descriptors with the content system.
-
setDefaultLayout(
LayoutConfiguration< T> layout, {required FromJsonConverter<LayoutConfiguration< fromJson, String? sourceFeatureName}) → dynamicT> > - Sets the default layout for this content builder.
-
setSourceFeature(
String? featureName) → dynamic - Updates the source feature for this builder and its layouts.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited