flutter_sanity_portable_text library

This is a library for rendering Portable Text from Sanity.io in Flutter. It is based on the official Portable Text specification found at https://www.portabletext.org/.

Supported features:

  • Text blocks
  • Custom blocks
  • Custom block containers
  • Inline text marks
  • Custom text styles
  • Custom mark definitions
  • Custom text mark recognizers
  • Shared config across all Portable Text Widgets

Classes

ErrorView
Renders an error message when a block type is missing a builder or when a mark is misconfigured.
MarkDef
A single mark definition.
MarkDefDescriptor
Describes a MarkDef and its associated builders.
PortableBlockItem
The PortableBlockItem interface provides a way to handle different types of 'Block Items' within the Portable Text. Every such block item is identified by the blockType property.
PortableText
A widget that renders a list of PortableBlockItems. This widget is the main entry point for rendering Portable Text content. It is responsible for rendering the entire content of a Portable Text document, including all blocks and marks. It relies on the PortableTextConfig to determine the visual representation of each block.
PortableTextBlock
Renders a single block of Portable Text. This widget is used internally by the PortableText widget. It is not meant to be used directly for most common scenarios. If you need to render a single block of Portable Text, consider using the PortableText widget.
PortableTextConfig
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.
Span
A Span is the standard way to express inline text within a block
TextBlockItem
A block of text within the Portable Text document. This is the most common and popular block item within the Portable Text instance. Most of the fields are based on the specification for Portable Text, which can be seen here: https://www.portabletext.org/

Enums

ListItemType
Identifies the type of list-item within the block.

Typedefs

BlockContainerBuilder = Widget Function(BuildContext, Widget)
A function that builds a widget for a Portable block container.
BlockWidgetBuilder = Widget Function(BuildContext context, PortableBlockItem item)
A function that builds a widget for a Portable block item.
MarkDefFromJson = MarkDef Function(Map<String, dynamic> json)
Deserializes a MarkDef from a JSON map.
MarkDefSpanBuilder = InlineSpan Function(BuildContext context, MarkDef mark, String text, TextStyle style)
Builds an InlineSpan for a given MarkDef.
MarkDefTextStyleBuilder = TextStyle Function(BuildContext context, MarkDef mark, TextStyle base)
Builds a TextStyle for a given MarkDef.
TextStyleBuilder = TextStyle Function(BuildContext context, TextStyle base)
A function that builds a text style for a Portable Text block or span.