Simulator.Screen.Recording.-.iPhone.16.-.2025-07-26.at.10.52.41.mp4
-
Clone the repository
git clone https://github.com/demolaf/ai_prompt_driven_app cd ai_prompt_driven_app
-
Install dependencies
flutter pub get
-
Set up API keys for AI functionality
cp environment.example.json environment.json # Edit environment.json with your API keys: # - OPENAI_API_KEY: Your OpenAI API key (for GPT-4) # - ANTHROPIC_API_KEY: Your Anthropic API key (for Claude)
⚠️ Security Warning:- Never commit
environment.json
to version control (it's in .gitignore) - Never share your actual API keys publicly
- API keys should only contain placeholder text in documentation
Note: At least one API key is required for AI prompt functionality. Without API keys, only predefined prompts will work.
- Never commit
-
Run the application
flutter run --dart-define-from-file environment.json
The app supports two types of prompts:
- Predefined Prompts: Quick-access buttons for common UI modifications
- Custom AI Prompts: Natural language requests processed by AI to generate UI changes
The app includes several predefined prompts that demonstrate the dynamic configuration capabilities:
- Tap the floating action button (FAB) in any view
- Choose your interaction method:
- Select from predefined prompts for quick common changes
- Enter custom AI prompt in the text field for natural language requests
- Watch the UI update in real-time
- Reset to default using the reset option
Add new prompts to lib/src/model/prompt.dart
:
{
'id': 'custom_001',
'title': 'Your Custom Prompt Title',
'configurable': {
'type': 'home', // or 'profile'
'scaffoldConfig': {
'backgroundColor': 'FFFF5722', // Orange background
},
'appBarConfig': {
'title': 'Custom Title',
},
},
}
- Create a config class in
lib/src/config/
- Implement required methods:
toJson()
,fromJson()
,copyWith()
,schema
- Add to view configurables in the appropriate view configuration file
- Update the ViewConfigurable factory in
lib/src/model/view_configurable.dart
Follow the established pattern:
class DynamicCustomWidget extends StatelessWidget {
const DynamicCustomWidget({this.config, super.key});
final CustomWidgetConfig? config;
@override
Widget build(BuildContext context) {
return Visibility(
visible: config?.visible ?? true,
child: _buildWidget()
);
}
Widget _buildWidget() {
// Implementation with fallback for null config
}
}
- Models: Data and business logic
- Views: UI components and screens
- ViewModels: State management and view logic
- Separation of Concerns: UI logic separated from configuration
- Dynamic Updates: Runtime configuration changes
- Type Safety: Strongly typed configuration objects