Async Providers
// Prompt: "Create async provider for user data with:// - Caching// - Refresh capability// - Error recovery// - Family modifier for parameters"
Accelerate Flutter development with Cursor IDE and Claude Code. These patterns cover widget creation, state management, platform integration, and the unique features that make Flutter a powerful choice for cross-platform development.
claude "Set up Flutter project with clean architecture"
// Cursor prompt for custom widgets:"Create a CustomCard widget that:- Accepts title, subtitle, and leading icon- Has Material 3 elevation and theming- Supports onTap callback- Includes hero animation support"
// Agent generates:import 'package:flutter/material.dart';
class CustomCard extends StatelessWidget { final String title; final String? subtitle; final IconData? leadingIcon; final VoidCallback? onTap; final String? heroTag;
const CustomCard({ super.key, required this.title, this.subtitle, this.leadingIcon, this.onTap, this.heroTag, });
@override Widget build(BuildContext context) { // Implementation with Material 3 theming }}
// Prompt: "Create an AnimatedCounter widget with:// - Smooth number transitions// - Customizable duration// - Number formatting support// - Accessibility features"
// Cursor Agent prompt:"Set up Riverpod with:1. Authentication state provider2. User profile provider with async loading3. Theme mode provider4. Language preference providerInclude proper error handling and loading states"
Async Providers
// Prompt: "Create async provider for user data with:// - Caching// - Refresh capability// - Error recovery// - Family modifier for parameters"
State Notifiers
// Prompt: "Implement shopping cart with:// - Add/remove items// - Quantity updates// - Price calculation// - Persistence"
// Comprehensive navigation prompt:"Implement go_router with:- Nested navigation- Auth guards- Deep linking- Web URL support- Custom transitions- Error handling"
// Cursor will generate:final router = GoRouter( routes: [ GoRoute( path: '/', builder: (context, state) => const HomePage(), routes: [ GoRoute( path: 'details/:id', builder: (context, state) { final id = state.pathParameters['id']!; return DetailsPage(id: id); }, ), ], ), ],);
// Prompt: "Add authentication flow with:// - Login redirect// - Protected routes// - Refresh token handling"
// Cursor prompt for responsive layouts:"Create a responsive dashboard that:- Uses LayoutBuilder for breakpoints- Adapts navigation (drawer vs rail vs bottom nav)- Responsive grid layout- Maintains state across layout changes"
// Cursor Agent prompt:"Implement camera feature with:- Photo capture- Video recording- Gallery picker- Image compression- iOS/Android permissions"
// Prompt: "Add location tracking with:// - Current position// - Background updates// - Geofencing// - Battery optimization"
// Comprehensive test generation:"Write widget tests for CustomCard including:- Golden tests for visual regression- Interaction tests (tap, long press)- Accessibility tests- Theme variation tests- Error state tests"
AI-Assisted Performance
Cursor/Claude can help with:
// Performance monitoring prompt:"Add performance tracking for:- Widget build times- Frame rendering metrics- Memory usage- Network request duration- Include DevTools integration"
// Cursor prompt for API setup:"Create API service with Dio that includes:- Interceptors for auth tokens- Request/response logging- Error handling with retry- Offline queue- Type-safe models with Freezed"
// Simple storage prompt:"Create settings service with:- Type-safe preference keys- Migration support- Default values- Stream updates"
// Database prompt:"Implement SQLite with Drift for:- User data storage- Full-text search- Migrations- Reactive queries"
// Comprehensive architecture prompt:"Set up clean architecture with:- Domain layer (entities, use cases)- Data layer (repositories, data sources)- Presentation layer (pages, view models)- Dependency injection with get_it- Error handling strategy"
// Complete auth implementation:"Implement authentication with:1. Email/password login2. Social login (Google, Apple)3. Biometric authentication4. Session management5. Auto-logout on inactivity"
// Pagination pattern:"Create infinite scroll list with:- Lazy loading- Pull to refresh- Error state handling- Loading indicators- Empty state- Network efficiency"
// Debugging setup prompt:"Configure Flutter DevTools with:- Custom inspector properties- Performance overlays- Memory profiling markers- Network debugging- Widget tree optimization hints"
Comprehensive Error Strategy
AI can implement:
# Cursor prompt: "Configure Android build with:# - App signing# - ProGuard rules# - Multi-APK support# - Play Store metadata"
# Prompt: "Set up iOS build with:# - Code signing# - App Store Connect# - TestFlight distribution# - App clips support"
// Structure your prompts like:"Create a [Widget type] that:- Follows Material 3 guidelines- Supports [specific features]- Handles [edge cases]- Includes [platform-specific code]- Has comprehensive documentation"
// Complex UI prompt:"Create custom painter for:- Animated wave background- Gradient mesh effect- Responsive to theme- Performance optimized- With customizable parameters"
// Native integration prompt:"Implement platform channel for:- iOS HealthKit integration- Android Health Connect- Type-safe communication- Error handling- Mock implementation for tests"