flutter_sanity_portable_text 1.0.0-beta.8 copy "flutter_sanity_portable_text: ^1.0.0-beta.8" to clipboard
flutter_sanity_portable_text: ^1.0.0-beta.8 copied to clipboard

Flutter renderer for the Sanity.io Portable Text format. It includes support for the standard blocks, spans, annotations, including the ability to provide custom blocks, annotations and styles.

example/lib/main.dart

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(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: Scaffold(
        body: SafeArea(
          child: Padding(
            padding: const EdgeInsets.all(8.0),
            child: Center(
              // Typically you would render this by querying Sanity and
              // fetching the data. Here we are hard-coding the model for brevity.
              // Use the sanity_client package to fetch data from Sanity.
              child: PortableText(
                blocks: [
                  TextBlockItem(
                    children: [
                      Span(
                        text: 'Sanity Portable Text',
                      ),
                    ],
                    style: 'h1',
                  ),

                  TextBlockItem(
                    children: [
                      Span(
                        text: 'Hello, ',
                      ),
                      Span(
                        text: 'World!',
                        marks: [
                          'strong',
                          'em',
                          'underline',
                        ],
                      ),
                    ],
                  ),

                  // Let's try a blockquote now
                  TextBlockItem(
                    children: [
                      Span(
                        text:
                            '"The best way to predict the future is to invent it."',
                      ),
                      Span(
                        text: '\n- Steve Jobs',
                      ),
                    ],
                    style: 'blockquote',
                  ),
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }
}
6
likes
0
pub points
81%
popularity

Publisher

verified publishervyuh.tech

Flutter renderer for the Sanity.io Portable Text format. It includes support for the standard blocks, spans, annotations, including the ability to provide custom blocks, annotations and styles.

Homepage
Repository (GitHub)
View/report issues

Topics

#flutter #portable-text #renderer #json

License

unknown (license)

Dependencies

collection, flutter, json_annotation, nanoid

More

Packages that depend on flutter_sanity_portable_text