Skip to content
pubscout

flutter_sanity_portable_text

2.3.0, released 9 days ago by vyuh.tech

Flutter renderer for Sanity.io Portable Text format with block, span, and style support.

WASM-readyUses material_ui
$ flutter pub add flutter_sanity_portable_text
Source repository

What it does

Renders Sanity.io Portable Text format content inside Flutter applications. Supports standard and custom blocks, spans, annotations, and styles with helpful inline error messages for unregistered elements.

AI-written summary of version 2.2.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to render Sanity CMS portable text content in a Flutter application.
  • You want custom block and custom mark support for rich text rendering.

Skip it when

  • You are not using Sanity.io as your backend CMS.
  • You only need to render basic Markdown or HTML strings.

Strengths

  • Complete support for standard Portable Text styles and marks.
  • Extensible architecture for custom blocks, custom marks, and custom list builders.
  • Developer-friendly error handling for unregistered elements.

Weaknesses

  • Tied specifically to the Sanity.io Portable Text format.
  • FSL-1.1-MIT license requires attention regarding commercial terms.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
Yes (build_runner)
Direct dependencies
4

Add the package to pubspec.yaml and register any custom blocks or mark definitions if needed.

import 'package:flutter/material.dart';
import 'package:flutter_sanity_portable_text/flutter_sanity_portable_text.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: PortableText(
          blocks: [
            TextBlockItem(
              children: [
                Span(
                  text: 'Sanity Portable Text',
                ),
              ],
              style: 'h1',
            ),
          ],
        ),
      ),
    );
  }
}

Alternatives

Packages that do the same job and could replace flutter_sanity_portable_text.

Works with

Packages commonly used together with flutter_sanity_portable_text: ones it builds on, ones built on it, and its own family.