ai_ui_render 0.1.0
ai_ui_render: ^0.1.0 copied to clipboard
AI-driven JSON to Flutter UI rendering framework. Safely generate Flutter UI from AI prompts with guardrailed component catalogs, streaming support, visibility conditions, and rich action handling.
/// AI UI Render Example App
///
/// Comprehensive demo showcasing all features of the ai_ui_render package.
library;
import 'package:flutter/material.dart';
import 'pages/components_gallery_page.dart';
import 'pages/data_binding_page.dart';
import 'pages/actions_demo_page.dart';
import 'pages/visibility_demo_page.dart';
import 'pages/streaming_demo_page.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'AI UI Render Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
useMaterial3: true,
),
home: const HomePage(),
);
}
}
class HomePage extends StatefulWidget {
const HomePage({super.key});
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
int _currentIndex = 0;
final List<Widget> _pages = const [
ComponentsGalleryPage(),
DataBindingPage(),
VisibilityDemoPage(),
ActionsDemoPage(),
StreamingDemoPage(),
];
final List<String> _titles = const [
'Components Gallery',
'Data Binding',
'Visibility Conditions',
'Actions',
'Streaming',
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(_titles[_currentIndex]),
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
actions: [
IconButton(
icon: const Icon(Icons.info_outline),
tooltip: 'About',
onPressed: () => _showAboutDialog(context),
),
],
),
body: _pages[_currentIndex],
bottomNavigationBar: NavigationBar(
selectedIndex: _currentIndex,
onDestinationSelected: (index) {
setState(() {
_currentIndex = index;
});
},
destinations: const [
NavigationDestination(
icon: Icon(Icons.widgets_outlined),
selectedIcon: Icon(Icons.widgets),
label: 'Components',
),
NavigationDestination(
icon: Icon(Icons.data_object_outlined),
selectedIcon: Icon(Icons.data_object),
label: 'Data',
),
NavigationDestination(
icon: Icon(Icons.visibility_outlined),
selectedIcon: Icon(Icons.visibility),
label: 'Visibility',
),
NavigationDestination(
icon: Icon(Icons.touch_app_outlined),
selectedIcon: Icon(Icons.touch_app),
label: 'Actions',
),
NavigationDestination(
icon: Icon(Icons.stream_outlined),
selectedIcon: Icon(Icons.stream),
label: 'Stream',
),
],
),
);
}
void _showAboutDialog(BuildContext context) {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Row(
children: [
Icon(Icons.auto_awesome, color: Colors.blue),
SizedBox(width: 8),
Text('AI UI Render'),
],
),
content: const Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'A Flutter framework for safely generating UI from AI prompts.',
style: TextStyle(fontWeight: FontWeight.w500),
),
SizedBox(height: 16),
Text('Features:'),
SizedBox(height: 8),
_FeatureItem('Guardrailed component catalogs'),
_FeatureItem('JSON to Widget rendering'),
_FeatureItem('Streaming UI generation'),
_FeatureItem('Visibility conditions'),
_FeatureItem('Rich action system'),
_FeatureItem('Data binding'),
_FeatureItem('Built-in validation'),
SizedBox(height: 16),
Text(
'Version 0.1.0',
style: TextStyle(color: Colors.grey),
),
],
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('Close'),
),
],
),
);
}
}
class _FeatureItem extends StatelessWidget {
final String text;
const _FeatureItem(this.text);
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 2),
child: Row(
children: [
const Icon(Icons.check_circle, size: 16, color: Colors.green),
const SizedBox(width: 8),
Text(text, style: const TextStyle(fontSize: 13)),
],
),
);
}
}