Homeโ€บBlogโ€บFlutter & Dart AI Prompts: Build Production iOS & โ€ฆ
Programming17 min read ยท May 10, 2026

Flutter & Dart AI Prompts: Build Production iOS & Android Apps in 2026

By Promptprepare Team ยท AI Prompt Experts

Complete AI prompt library for Flutter developers. Covers Riverpod state management, GoRouter navigation, authentication, REST API integration, Isar local database, animations, widget testing, and CI/CD with Fastlane and GitHub Actions.

#Flutter#Dart#iOS#Android#Mobile Development#Riverpod#AI Coding Prompts

Flutter in 2026: The Cross-Platform Native SDK

Flutter compiles to native ARM code and runs on iOS, Android, Web, and Desktop from a single Dart codebase. The developers building the smoothest Flutter apps in 2026 use Riverpod 2, GoRouter, Freezed, and Dio โ€” and they use AI prompts that specify these libraries explicitly to avoid getting legacy patterns from pre-2023 training data.

1. Flutter Project Architecture with Riverpod

You are a senior Flutter architect using Flutter 3.24, Dart 3, and Riverpod 2 with code generation.

Design a production Flutter app architecture for a project management app:

Packages: riverpod + riverpod_generator + riverpod_annotation, go_router, dio, freezed + json_serializable, isar (local DB), flutter_secure_storage, local_auth, firebase_messaging

Folder structure (feature-first):
- lib/features/auth/: models/, providers/, repositories/, screens/, widgets/
- lib/features/projects/: same structure
- lib/features/tasks/: same structure
- lib/core/: api/ (Dio client), router/, theme/, utils/, widgets/

Deliver:
1. Full directory tree with one-sentence purpose per folder
2. Riverpod provider graph: which providers depend on which
3. GoRouter setup: routes, redirect guard checking authProvider, deep link support
4. Dio client setup: base URL from flavor, auth interceptor, retry interceptor
5. Flavor configuration: development, staging, production (different API URLs and Firebase projects)

2. Riverpod 2 Providers with Code Generation

You are a Riverpod 2 expert using riverpod_generator.

Build the task state management layer using Riverpod code generation:

Models (Freezed):
@freezed class Task: id, title, description, status (enum), priority (enum), dueDate, assignedTo (User?), projectId, createdAt, updatedAt

Providers:

@riverpod
Future<List<Task>> taskList(TaskListRef ref, {required String projectId, TaskFilter? filter}) {
  // fetch from repository, watch auth provider for invalidation
}

@riverpod
class TaskNotifier extends _$TaskNotifier {
  // createTask: optimistic insert โ†’ API โ†’ revert on failure
  // updateTask: optimistic patch โ†’ API โ†’ revert on failure
  // deleteTask: optimistic remove โ†’ API โ†’ restore on failure
}

Repository (taskRepository provider):
- All HTTP calls via Dio client provider
- Map API errors to domain exceptions (NetworkException, AuthException, ValidationException)
- Local cache: read from Isar, update from API, write-through on mutations

Output: Task Freezed model with all JSON annotations, taskListProvider, TaskNotifier, TaskRepository, and generated file references (.g.dart). Show how to override providers in tests.

3. GoRouter with Auth Guard

You are a GoRouter expert for Flutter applications.

Configure GoRouter for a Flutter SaaS app with:

Routes:
- /login, /register, /forgot-password (no auth required)
- /onboarding (authenticated, no org selected)
- / (home shell with bottom navigation: /home, /projects, /notifications, /profile)
- /projects/:projectId (nested in shell)
- /tasks/:taskId (nested in shell)
- /settings (nested in shell)

Auth redirect logic:
- unauthenticated user โ†’ always redirect to /login (except public marketing routes)
- authenticated, no organisation โ†’ redirect to /onboarding
- authenticated + organisation โ†’ allow through to requested route
- /login when authenticated โ†’ redirect to /home

Features:
- ShellRoute for bottom navigation (preserves scroll position per tab)
- Deep link support: app.example.com/tasks/123 โ†’ opens TaskDetailScreen
- Custom error page for unknown routes (not default 404)
- refreshListenable: GoRouter re-evaluates redirect when authProvider changes (Riverpod + Listenable adapter)

Output: router.dart with full route tree, auth redirect function, and bottom navigation shell widget.

4. Dio HTTP Client with Interceptors

You are a Flutter networking expert.

Build a production Dio client for a Flutter app:

Base client:
- Base URL from flavour config
- ConnectTimeout: 30s, ReceiveTimeout: 30s, SendTimeout: 30s
- JSON headers by default

Interceptors (in this order):
1. AuthInterceptor: inject Bearer token from flutter_secure_storage into every request. On 401: call refresh token endpoint, update stored token, retry original request (max 1 retry). On refresh failure: clear storage, redirect to login via GoRouter.
2. RetryInterceptor: on network errors (SocketException, TimeoutException), retry 3 times with exponential backoff (1s, 2s, 4s). Do NOT retry 4xx errors.
3. LoggingInterceptor: in debug mode only โ€” log method, URL, headers (redact Authorization), response status, duration. In release: no logging.
4. ErrorInterceptor: map DioException to domain exceptions: NetworkException, ServerException(statusCode, message), AuthException, ValidationException(fieldErrors).

Repository layer:
- Never let Dio types leak into feature code
- All methods return Either<Failure, T> (dartz) or throw typed exceptions
- Parse response with Freezed .fromJson()

Output: dio_client.dart, each interceptor file, and one complete repository example (TaskRepository).

5. Isar Local Database for Offline Support

You are a Flutter offline-first expert using Isar database.

Implement offline-first data layer for a Flutter task app:

Isar schemas:
- TaskEntity: all task fields + syncStatus (enum: synced/pending/conflict) + locallyUpdatedAt
- ProjectEntity: similar
- SyncQueueEntity: entityType, entityId, operation (create/update/delete), payload (String JSON), createdAt, retryCount

Sync service:
- On mutation: write to Isar immediately (optimistic), add to SyncQueue
- Background sync: ConnectivityProvider watches network; on reconnect, process SyncQueue
- Process queue: send each item to API, on success update syncStatus=synced + remove from queue
- On conflict: server returns 409 with server version โ†’ store in TaskEntity.syncStatus=conflict, notify user
- Periodic sync: every 60 seconds when app is active

Repository pattern:
- TaskRepository reads from Isar first (instant), then triggers background API refresh
- Use Isar watchers (watchObject/watchLazy) to push Isar changes to Riverpod providers reactively

Output: Isar schemas with @Collection annotation, SyncService, TaskRepository with Isar + API coordination, and ConnectivityProvider.

6. Flutter Widget & Integration Testing

You are a Flutter testing expert.

Write widget and integration tests for a TaskListScreen:

Widget tests (test/features/tasks/task_list_screen_test.dart):
Setup:
- ProviderScope with overrides: mock taskListProvider, mock authProvider
- Use pumpWidget with MaterialApp.router(routerConfig: mockGoRouter)

Test cases:
1. Shows loading indicator while taskListProvider is AsyncLoading
2. Shows task list when loaded โ€” verify task titles with find.text
3. Shows empty state widget when task list is empty
4. Shows error widget with retry button when provider is AsyncError
5. Tap task row โ†’ verify GoRouter.go called with correct route
6. Pull-to-refresh โ†’ verify provider.invalidate() called
7. FAB tap โ†’ verify navigation to task creation screen

Integration tests (integration_test/task_flow_test.dart):
- Full flow: app launch โ†’ login (mock API) โ†’ create project โ†’ create task โ†’ mark complete
- Use integrationDriver with real Isar (in-memory) and mocked Dio

Golden tests:
- TaskListScreen with 5 tasks โ†’ compare to baseline PNG

Output: widget test file, integration test file, test helpers (pumpApp wrapper, mock providers).

7. CI/CD with Fastlane & GitHub Actions

You are a Flutter DevOps engineer.

Build a CI/CD pipeline for a Flutter app using GitHub Actions and Fastlane:

GitHub Actions workflow (.github/workflows/flutter.yml):

test job (all PRs):
- Flutter 3.24 stable setup with cache
- flutter pub get
- dart format --set-exit-if-changed (fail on unformatted code)
- flutter analyze (zero warnings)
- flutter test --coverage (fail below 75%)
- Upload coverage to Codecov

build-android job (main branch):
- flutter build appbundle --release --flavor production
- Sign with keystore from GitHub Secrets
- Upload .aab artifact

build-ios job (main branch, macos-latest runner):
- flutter build ipa --release --flavor production --export-options-plist
- Code sign via Fastlane match (App Store Connect API key from Secrets)
- Upload .ipa artifact

deploy job (after both build jobs):
- Android: Fastlane supply upload to Google Play internal track
- iOS: Fastlane pilot upload to TestFlight
- Slack notification with build number and download link

Fastlane (fastlane/Fastfile):
- lane :test: flutter test
- lane :beta_android: build + Play Store internal
- lane :beta_ios: build + TestFlight
- lane :release: promote internal โ†’ production on both stores

Output: GitHub Actions YAML, Fastfile, Matchfile, and required GitHub Secrets list.

8. Good vs Bad Flutter Prompts

TaskโŒ Bad Promptโœ… Good Prompt
State"Build a counter app with Riverpod""Create a Riverpod 2 AsyncNotifier (with riverpod_generator @riverpod annotation) for tasks: fetchTasks(), createTask() with optimistic insert + revert on API failure, deleteTask() with optimistic remove. Dart 3 strict null safety."
Navigation"Add navigation to my app""Configure GoRouter for Flutter: ShellRoute with bottom nav (home/projects/profile), auth redirect guard reading from Riverpod authProvider via refreshListenable, deep link /tasks/:id, and custom 404 page. Show how redirect is re-evaluated on login/logout."
API"Call an API in Flutter""Build a Dio client with AuthInterceptor (inject Bearer token, refresh on 401 with max 1 retry), RetryInterceptor (exponential backoff on network errors, skip 4xx), and ErrorInterceptor mapping DioException to typed domain exceptions. Never let Dio types leak into feature code."

Generate a custom Flutter prompt โ†’ Try PromptPrepare free

Found this helpful? Share it.