The definitive AI prompt guide for the Flutter + ASP.NET Core enterprise stack. Covers cross-stack architecture, Riverpod 2 state management, EF Core 9, MediatR CQRS, real-time features with SignalR, and offline-first mobile patterns.
The Flutter + .NET Core Stack in 2026
Flutter and ASP.NET Core form a compelling enterprise stack: Flutter delivers a single Dart codebase that compiles to native iOS, Android, Web, and Desktop; .NET 9 provides one of the fastest backend runtimes with C#'s strong type system and mature enterprise ecosystem. The combination is particularly productive for enterprise teams already invested in Microsoft tooling — Azure hosting, Azure AD authentication, SQL Server, and Visual Studio integrate naturally with the .NET backend while Flutter handles the mobile surface.
The key architectural decision in this stack is API design for mobile consumers. Mobile clients have different API requirements than web browsers: smaller payloads (bandwidth and battery), offline capability, optimistic UI, and push notification integration. ASP.NET Core Minimal APIs with carefully designed DTOs, EF Core projections (not entity graphs), and response compression are the production baseline. Mobile clients should never receive raw EF Core entities — always project to purpose-built mobile DTOs in the query itself.
The second key decision is real-time communication. SignalR, Microsoft's WebSocket abstraction, has first-class .NET support and a Flutter client library (signalr_netcore). For enterprise apps with live dashboards, collaboration features, or IoT data display, SignalR with a Riverpod StreamProvider on the Flutter side provides reactive real-time UI without the complexity of managing WebSocket connections manually.
Which AI Model for Which Layer
| Layer | Best Model | Why | Weak Spot to Watch |
|---|---|---|---|
| Flutter UI / Riverpod | Claude Sonnet 4.6 | Produces correct Riverpod 2 code-gen patterns, GoRouter guards, and Freezed data classes reliably | May generate Riverpod 1.0 Provider syntax — always specify Riverpod 2 with @riverpod annotation |
| ASP.NET Core / C# | Claude Sonnet 4.6 | Best async/await hygiene, MediatR CQRS design, EF Core query optimization, and Result pattern | May generate MVC controller patterns — specify Minimal APIs explicitly |
| Architecture decisions | Grok 4 | Direct answers on Flutter vs React Native, SignalR vs polling, Minimal API vs controllers | Less depth on specific .NET or Riverpod APIs |
| Boilerplate scaffolding | ChatGPT GPT-5.5 | Fast for widget boilerplate, C# interface stubs, DTO generation | setState instead of Riverpod in Flutter; DataAnnotations instead of FluentValidation in .NET |
| .NET ecosystem research | Gemini 3.5 Flash | Current on .NET 9 changelogs, NuGet package comparisons, Azure integration guides | Less precision on EF Core and MediatR specifics than Claude |
| Dart algorithms | DeepSeek V4 | Strong for pure Dart computation, data structures, sorting algorithms | Flutter-specific widget patterns and Riverpod are often outdated |
1. Flutter + .NET API Design Prompt
You are a senior architect designing an API for a Flutter mobile app backed by ASP.NET Core.
Design a production API for a field service management app:
Mobile constraints to design for:
- Offline-first: all data must be readable offline; writes queue and sync when connected
- Payload size: mobile DTOs must be flat, minimal, and compressed (no entity graphs)
- Push notifications: APNs (iOS) and FCM (Android) via Azure Notification Hubs
- Auth: Azure AD B2C with JWT; refresh tokens stored in Flutter Secure Storage
ASP.NET Core (.NET 9) backend:
- Architecture: Minimal APIs + MediatR CQRS + EF Core 9 (SQL Server)
- Mobile-specific endpoints: /api/mobile/sync (bulk delta sync), /api/mobile/push-register
- Response DTOs: ProjectSummaryDto, TaskDetailDto, UserProfileDto — flat, no circular refs
- Versioning: URL versioning (/api/v1/) with deprecation headers
Deliver:
1. Endpoint list with HTTP method, route, auth requirement, and response DTO
2. EF Core entity vs mobile DTO mapping strategy (projections in queries, not AutoMapper)
3. Delta sync design: how the client knows what changed since its last sync timestamp
4. SignalR hub design for real-time task assignment updates
5. Offline conflict resolution strategy: last-write-wins vs merge-conflict detection
2. Flutter App Authentication with .NET JWT
You are a mobile security engineer building auth for a Flutter app backed by ASP.NET Core.
Implement complete authentication:
ASP.NET Core (.NET 9) backend:
- Auth provider: Azure AD B2C with JWT validation via Microsoft.Identity.Web
- Endpoints: POST /api/v1/auth/token (exchange B2C token), POST /api/v1/auth/refresh, POST /api/v1/auth/logout
- Token strategy: short-lived access token (15 min) + long-lived refresh token (30 days) in response body
- Security: rate limiting (5 attempts/min), JWT audience/issuer validation, refresh token rotation
Flutter frontend:
- Auth service: singleton (Riverpod provider) managing access + refresh tokens
- Token storage: flutter_secure_storage (Keychain on iOS, EncryptedSharedPreferences on Android)
- Token refresh: Dio interceptor that retries on 401, refreshes token, then retries original request
- Session expiry: clear tokens and navigate to login when refresh fails
- Biometric: local_auth for biometric re-authentication after app foreground (not initial login)
Deliver: ASP.NET Core auth middleware setup, Flutter AuthService with Riverpod, Dio interceptor, and BiometricService
3. ASP.NET Core API Optimised for Mobile Clients
You are a .NET 9 backend engineer building an API specifically for mobile consumption.
Build a mobile-optimised Task API endpoint:
Endpoint: GET /api/v1/projects/{projectId}/tasks
- Returns a paginated list of tasks with cursor-based pagination (not offset)
- Response DTO: TaskSummaryDto (flat, no nested objects — IDs only for references)
- Filtering: status, assignedToId, dueDateBefore, dueDateAfter (all optional query params)
- Sorting: by dueDate, createdAt, priority (ascending or descending)
- Response compression: gzip enabled globally; mobile clients always send Accept-Encoding: gzip
EF Core 9 query requirements:
- Project directly to TaskSummaryDto in the query (.Select()) — no entity materialization
- Cursor pagination using the task's cursor field (keyset, not OFFSET)
- Indexes: confirm the query plan uses the composite index on (project_id, status, due_date)
- AsNoTracking() on all read queries
Performance: add response caching headers (Cache-Control: private, max-age=30) for unchanged data
Output: endpoint handler, EF Core query with projection, pagination logic, and integration test
4. Real-Time Features (Flutter + SignalR)
You are a real-time systems engineer working with Flutter and ASP.NET Core SignalR.
Implement real-time task assignment notifications:
ASP.NET Core SignalR hub:
- Hub: TaskHub with methods: SendTaskAssigned(taskId, assigneeId), SendTaskStatusChanged(taskId, newStatus)
- Groups: users join a group per organization (orgId) on connect
- Auth: JWT validation on hub connection
- Scale-out: Redis backplane for multi-instance deployments (StackExchange.Redis)
- Server-push: IHubContext injected into MediatR handlers to push after DB write
Flutter signalr_netcore client:
- SignalR service: singleton Riverpod provider, starts on app launch
- Connection lifecycle: connect on auth, disconnect on logout, reconnect with exponential backoff (max 30s)
- Incoming events: TaskAssignedEvent, TaskStatusChangedEvent as Freezed data classes
- Stream exposure: StreamProvider for each event type, consumed by relevant Riverpod notifiers
- UI update: TaskListNotifier listens to assignment stream, updates Drift local cache, triggers rebuild
Deliver: ASP.NET Core hub, Redis config, Flutter SignalR service, StreamProvider setup, and integration with TaskListNotifier
5. Offline-First Flutter with .NET Sync
You are a mobile architect building an offline-first Flutter app with .NET backend sync.
Implement complete offline-first task management:
Local storage (Drift — SQLite ORM for Dart):
- Tables: Task, Project, User, SyncQueue (pending changes not yet synced)
- Drift database class with TypeConverters for enums and DateTime
- Reactive queries: Stream> watchProjectTasks(projectId) — auto-updates UI on change
- SyncQueue: stores {entityType, entityId, operation (create/update/delete), payload, createdAt, attempts}
Sync service (background Isolate):
- Runs on a timer (every 60s) and on network reconnect (connectivity_plus)
- Reads SyncQueue, sends changes to POST /api/v1/sync/batch
- Handles conflicts: server returns conflict items with server version; merge strategy: server wins for status changes, client wins for description edits
- On success: removes items from SyncQueue, merges server response into Drift
ASP.NET Core sync endpoint:
- POST /api/v1/sync/batch: accepts BatchSyncRequest with list of SyncItem
- For each item: apply to DB, detect conflicts (optimistic concurrency with row version), return SyncResult
- Delta pull: GET /api/v1/sync/delta?since={timestamp} returns all changes since the given timestamp
Output: Drift database, SyncQueue table, SyncService in Isolate, ASP.NET Core batch sync endpoint, and conflict resolution logic
6. MediatR CQRS for Mobile API Commands
You are a .NET 9 architect using MediatR CQRS pattern for a mobile-facing API.
Implement the CreateTask command with full CQRS:
Command and handler:
- CreateTaskCommand: record with TaskTitle, Description, ProjectId, AssignedToId, DueDate, Priority
- CreateTaskCommandHandler: implements IRequestHandler<CreateTaskCommand, Result<TaskDetailDto>>
- Validate: project exists and user is a member (throw if not — but use Result pattern, not exceptions)
- Create Task entity, save to EF Core, publish TaskCreatedEvent via MediatR
- Return Result.Success(TaskDetailDto) or Result.Failure(error message)
Pipeline behaviors (in order):
1. LoggingBehavior: logs command name, execution time, and result outcome
2. ValidationBehavior: runs FluentValidation validators, short-circuits with validation errors
3. TransactionBehavior: wraps handler in EF Core transaction, rolls back on failure
MediatR notification handler:
- TaskCreatedEventHandler: sends SignalR notification to organization group, queues email notification via Hangfire
Minimal API endpoint:
- POST /api/v1/tasks: maps request body to CreateTaskCommand, sends via ISender, returns 201 with TaskDetailDto or 422 with errors
Output: command, handler, three pipeline behaviors, notification handler, and Minimal API endpoint
Good vs Bad Cross-Platform Prompts
| Bad Prompt | Why It Fails | Good Prompt |
|---|---|---|
| "Build a Flutter app that uses an API" | No state management, no auth, no error handling. Will use setState and http package. No offline support. | "Build a Flutter 3.24 screen using Riverpod 2 AsyncNotifier, Dio for HTTP with auth interceptor, and Drift for local caching. Handle loading, error, and offline states. Riverpod 2 with riverpod_generator." |
| "Create a .NET REST API" | No version, no architecture pattern, no validation library. Will use MVC controllers with DataAnnotations and synchronous EF Core — deadlock-prone under load. | "Create a .NET 9 Minimal API endpoint with MediatR CQRS, FluentValidation in a pipeline behavior, EF Core 9 with AsNoTracking and projection to DTO, and Result pattern for error handling. No MVC controllers. No async void. No Task.Result." |
| "Add real-time updates to my app" | No protocol specified. Will likely generate polling. No reconnection logic, no auth on the connection, no scale-out consideration. | "Add SignalR real-time task assignment updates. .NET: TaskHub with JWT auth, Redis backplane for scale-out, IHubContext push after MediatR handler completes. Flutter: signalr_netcore client as Riverpod singleton, exponential backoff reconnect, StreamProvider exposing TaskAssignedEvent as Freezed data class." |
Further Reading
Help & Answers
Frequently Asked Questions
Found this helpful?
Save it to your library or share with your team.
Keep Reading