PortableTextConfig class final

The configuration used for rendering Portable Text. This class is used to define the visual representation of the Portable Text blocks, spans, and marks. It is used by the PortableText widget to render the Portable Text content. The configuration can be customized to match the visual design of the app. The default configuration is based on the Material Design guidelines.

Note that the configuration is shared across all instances of the PortableText widget.

Properties

baseStyle TextStyle? Function(BuildContext)
The base style used for rendering the Portable Text content. The default value is the bodyMedium style from the theme.
getter/setter pair
blockContainers Map<String, BlockContainerBuilder>
The block containers used to wrap the block widgets. The keys are the block container type names used in the Portable Text content. The default block container is a simple container, named as "default". You can customize the rendering of each block container type by providing a custom block container builder.
final
blocks Map<String, BlockWidgetBuilder>
The block widgets used to render the Portable Text content. The keys are the block type names used in the Portable Text content. The default block is a single PortableTextBlock, named as "block". You can customize the rendering of each block type by providing a custom block widget builder.
final
bulletRenderer BulletRenderer
The bullet renderer used to render the bullet for list items. The default value is a simple bullet renderer that handles the default bullet types: number, square, and circle.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
itemPadding EdgeInsets
The padding used for list items. The default value is 8.
getter/setter pair
listIndent double
The indentation used for list items. The default value is 16.
getter/setter pair
markDefs Map<String, MarkDefDescriptor>
The mark definitions used to render the Portable Text content. The keys are the mark type names used in the Portable Text content. The default mark definitions are based on the Material Design typography guidelines. You can customize the rendering of each mark type by providing a custom mark definition descriptor. The mark definitions are used to apply styles and gestures to the text spans. Make sure to keep the mark names in sync with the ones used in the schema for the Portable Text.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
styles Map<String, TextStyleBuilder>
The styles used to render the Portable Text content. The keys are the style names used in the Portable Text content, such as "h1", "h2", "blockquote", etc. The default styles are based on the Material Design typography guidelines. You can customize the styles by providing a custom style builder for each style.
final

Methods

apply({double listIndent = defaultListIndent, EdgeInsets itemPadding = defaultItemPadding, BulletRenderer? bulletRenderer, Map<String, TextStyleBuilder>? styles, Map<String, BlockContainerBuilder>? blockContainers, Map<String, BlockWidgetBuilder>? blocks, Map<String, MarkDefDescriptor>? markDefs, TextStyle? baseStyle(BuildContext)?}) → dynamic
Applies the custom configuration to the shared instance of the PortableTextConfig.
buildBlock(BuildContext context, PortableBlockItem item) Widget
Builds a block widget for the given Portable block item. The block widget is determined by the block type of the item. If the block type is not found in the block widgets, an error view is rendered with a message indicating the missing block type.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reset() → void
Resets the shared instance of the PortableTextConfig to the default configuration.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

defaultBlockContainerBuilder BlockContainerBuilder
getter/setter pair
defaultBlockContainers Map<String, BlockContainerBuilder>
The default block containers used by the shared instance of PortableTextConfig.
final
defaultBlocks Map<String, BlockWidgetBuilder>
The default block widgets used by the shared instance of PortableTextConfig. The default block is a single PortableTextBlock, named as "block".
final
defaultBulletRenderer BulletRenderer
getter/setter pair
defaultStyles Map<String, TextStyleBuilder>
The default text styles used by the shared instance of PortableTextConfig.
final
shared PortableTextConfig
The shared instance of the PortableTextConfig. This instance is used by all PortableText widgets in the application. You can customize the configuration by calling the apply method.
final

Static Methods

defaultBaseStyle(BuildContext context) TextStyle?

Constants

defaultItemPadding → const EdgeInsets
defaultListIndent → const double