Skip to main content

sdui_flutter_sanity 0.2.0 copy "sdui_flutter_sanity: ^0.2.0" to clipboard
sdui_flutter_sanity: ^0.2.0 copied to clipboard

A Server-Driven UI Flutter package powered by Sanity.io headless CMS with realtime config updates.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:sdui_flutter_sanity/sdui_flutter_sanity.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  // 1. Initialize the SDUI Engine with project credentials and optional custom components/actions.
  await SduiEngine.initialize(
    config: const SduiConfig(
      projectId: 'your_project_id_here', // <-- Replace with your Sanity Project ID
      dataset: 'production',
    ),
  );

  runApp(const ProviderScope(child: SduiApp()));
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'SDUI + Sanity',
      theme: ThemeData(useMaterial3: true, colorSchemeSeed: Colors.indigo),
      home: const SduiPage(slug: 'home'),
    );
  }
}

/// Renders whatever component tree Sanity currently has configured for [slug]
/// using the plug-and-play [SduiView] widget.
class SduiPage extends StatelessWidget {
  final String slug;
  const SduiPage({super.key, required this.slug});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Server-Driven UI')),
      body: SafeArea(child: SduiView(slug: slug)),
    );
  }
}
0
likes
130
points
130
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A Server-Driven UI Flutter package powered by Sanity.io headless CMS with realtime config updates.

Homepage
Repository (GitHub)
View/report issues

Topics

#ui #cms #sanity #server-driven-ui

License

MIT (license)

Dependencies

cached_network_image, flutter, flutter_riverpod, hive, hive_flutter, http, path_provider, url_launcher

More

Packages that depend on sdui_flutter_sanity