Flutter Init
bear2u/my-skills
A skill your agent uses when user wants to create a new Flutter project (Todo/Habit/Note/Expense/Custom domain) with Clean Architecture, Riverpod 3.0, Drift, and modern Flutter stack
Flutter idioms: Riverpod 3 state management, Freezed immutable models, gorouter navigation, const widget optimization, and repository patterns.
$ npx skills add irahardianto/awesome-agv --skill flutter-idioms -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install irahardianto/awesome-agv flutter-idioms --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/irahardianto/awesome-agv.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/flutter-idioms .claude/skills/flutter-idioms && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "flutter-idioms" agent skill from https://github.com/irahardianto/awesome-agv/tree/main/.agents/skills/flutter-idioms into .claude/skills/flutter-idioms/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "flutter-idioms", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/irahardianto/awesome-agv/tree/main/.agents/skills/flutter-idiomsType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add irahardianto/awesome-agv --skill flutter-idioms -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install irahardianto/awesome-agv flutter-idioms --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/irahardianto/awesome-agv.git skills-src && mkdir -p .agents/skills && cp -r skills-src/.agents/skills/flutter-idioms .agents/skills/flutter-idioms && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "flutter-idioms" agent skill from https://github.com/irahardianto/awesome-agv/tree/main/.agents/skills/flutter-idioms into .agents/skills/flutter-idioms/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "flutter-idioms", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add irahardianto/awesome-agv --skill flutter-idioms -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install irahardianto/awesome-agv flutter-idioms --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/irahardianto/awesome-agv.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/.agents/skills/flutter-idioms .cursor/skills/flutter-idioms && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "flutter-idioms" agent skill from https://github.com/irahardianto/awesome-agv/tree/main/.agents/skills/flutter-idioms into .cursor/skills/flutter-idioms/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "flutter-idioms", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/irahardianto/awesome-agv.git --path .agents/skills/flutter-idioms--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add irahardianto/awesome-agv --skill flutter-idioms -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install irahardianto/awesome-agv flutter-idioms --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/irahardianto/awesome-agv.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/.agents/skills/flutter-idioms .gemini/skills/flutter-idioms && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "flutter-idioms" agent skill from https://github.com/irahardianto/awesome-agv/tree/main/.agents/skills/flutter-idioms into .gemini/skills/flutter-idioms/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "flutter-idioms", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install irahardianto/awesome-agv flutter-idiomsInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add irahardianto/awesome-agv --skill flutter-idioms -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/irahardianto/awesome-agv.git skills-src && mkdir -p .github/skills && cp -r skills-src/.agents/skills/flutter-idioms .github/skills/flutter-idioms && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "flutter-idioms" agent skill from https://github.com/irahardianto/awesome-agv/tree/main/.agents/skills/flutter-idioms into .github/skills/flutter-idioms/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "flutter-idioms", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add irahardianto/awesome-agv --skill flutter-idioms -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install irahardianto/awesome-agv flutter-idioms --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/irahardianto/awesome-agv.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/.agents/skills/flutter-idioms .opencode/skills/flutter-idioms && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "flutter-idioms" agent skill from https://github.com/irahardianto/awesome-agv/tree/main/.agents/skills/flutter-idioms into .opencode/skills/flutter-idioms/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "flutter-idioms", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
flutter-idiomsFlutter idioms: Riverpod 3 state management, Freezed immutable models, gorouter navigation, const widget optimization, and repository patterns.
Flutter Idioms is an agent skill from irahardianto/awesome-agv. Flutter idioms: Riverpod 3 state management, Freezed immutable models, gorouter navigation, const widget optimization, and repository patterns. Use when developing, refactoring, or reviewing Flutter mobile applications.
Its SKILL.md is about 7.3k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files, including reference files (for example `references/project-structure.md`).
It sits in Mobile, covering Cross-platform mobile apps, State management and Design patterns. It works with Flutter. The repository describes itself as: Comprehensive sets of standards and practices designed to elevate the capabilities of AI coding agents. The licence is MIT.
3 steps, taken from the first numbered list in SKILL.md.
Read from SKILL.md and the folder at commit 9e997ba. It shows what the files ask for, not the result of running them.
Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.
From allowed-tools in the SKILL.md frontmatter.
Shell commands in SKILL.md call:
dartflutterFrom the folder's file list and the shell code blocks in SKILL.md.
No URLs in SKILL.md.
From URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Flutter Idioms loads about 7.3k tokens when it runs, and up to ~8.6k if it reads all its reference files. Until then it costs about 59 tokens; SKILL.md has 1,523 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check found no risky patterns in SKILL.md.
Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
The full file from irahardianto/awesome-agv at commit 9e997ba, republished under its MIT licence (© irahardianto). 1,523 words, ~7,288 tokens.
.claude/skills/flutter-idioms/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.Flutter is a UI toolkit first — performance is a first-class concern. const widgets and immutable data keep the render tree efficient. Riverpod 3 is the canonical state management solution: compile-safe, testable without BuildContext, no implicit global state, and with automatic retry and pause/resume built in.
Code generation is mandatory. All providers must use @riverpod / @Riverpod(keepAlive: true) annotations with riverpod_generator and build_runner. This catches type errors, missing overrides, and broken provider graphs at compile time — bugs are caught before they reach users.
Required dependencies:
# pubspec.yaml
dependencies:
flutter_riverpod: 3.2.1
riverpod_annotation: 4.0.2
dev_dependencies:
riverpod_generator: 4.0.3
build_runner: # latest
riverpod_lint: # latestScope: This file covers Flutter/Dart coding idioms. For file and folder layout, see
references/project-structure.md. For test naming, seetesting-strategy.md. For general error handling principles, seeerror-handling-principles.md.
const Constructors — EverywhereMake every widget const when possible. const widgets are created once and never rebuilt unless their inputs change — this is Flutter's most impactful performance optimization.
// ✅ const constructor — widget is rebuild-safe
class TaskCard extends StatelessWidget {
const TaskCard({super.key, required this.task});
final Task task;
// ...
}
// Usage — compile-time constant
const TaskCard(task: myTask)
// ❌ Missing const — rebuilt on every parent rebuild
TaskCard(task: myTask)Rules:
StatelessWidget that has no mutable state must have a const constructorconst keyword at the call site, not just the definitionprefer_const_constructors must be enabled in analysis_options.yamlLarge build methods are the primary source of performance problems and unmaintainable UI code.
Extract a new widget when a subtree has distinct responsibilities
// ❌ Everything in one build method
@override
Widget build(BuildContext context) {
return Column(children: [
// 30 lines of header...
// 50 lines of list...
// 20 lines of footer...
]);
}
// ✅ Each subtree is a named widget with a const constructor
@override
Widget build(BuildContext context) {
return Column(children: [
const TaskHeader(),
const TaskList(),
const TaskFooter(),
]);
}Never use builder methods (_buildHeader()) as a substitute for extracting widgets
const and always rerun on parent rebuildStatelessWidget or ConsumerWidget insteadKeep build methods under ~30 lines — if longer, decompose
freezedAll domain models must be immutable. Use the freezed package for:
copyWith==, hashCode, and toString// task/models/task.dart
@freezed
class Task with _$Task {
const factory Task({
required String id,
required String title,
@Default(TaskStatus.pending) TaskStatus status,
DateTime? dueDate,
}) = _Task;
factory Task.fromJson(Map<String, dynamic> json) => _$TaskFromJson(json);
}
// Usage — immutable update via copyWith
final updated = task.copyWith(status: TaskStatus.done);
// ❌ Never mutate a model directly
task.status = TaskStatus.done; // compile error — field is finalRules:
@freezeddart run build_runner build after changing freezed modelsUse this tree to pick the correct provider pattern. Follow it top-to-bottom — the first match wins.
Does the provider have side-effects (create/update/delete)? ──> YES ──┐
│ │
NO │
│ Is it async?
│ │ │
Is it async? YES NO
│ │ │ │
YES NO ▼ ▼
│ │ @riverpod @riverpod
▼ ▼ class class
@riverpod @riverpod (AsyncNotifier) (Notifier)
function function
(FutureProvider) (Provider)Decision summary:
| Has side-effects? | Async? | Pattern | Provider type generated |
|---|---|---|---|
| No | No | @riverpod function | Provider |
| No | Yes | @riverpod async function | FutureProvider |
| No | Stream | @riverpod Stream function | StreamProvider |
| Yes | No | @riverpod class | NotifierProvider |
| Yes | Yes | @riverpod class with Future build | AsyncNotifierProvider |
| Yes | Stream | @riverpod class with Stream build | StreamNotifierProvider |
Riverpod 3 is the only state management solution used in this project. Do not introduce BLoC, Cubit, Provider (package:provider), or GetX.
For file layout of state/ directories, see
references/project-structure.md.
ProviderScopeEvery Flutter app using Riverpod must wrap the root widget in ProviderScope. This creates the ProviderContainer that powers all providers in the widget tree.
// main.dart
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
void main() {
runApp(const ProviderScope(child: MyApp()));
}Rules:
ProviderScope at the app root — never nest ProviderScope widgetsoverrides: parameter only in tests (see Testing section)retry: to the root ProviderScope (see Runtime Behaviors)Use class-based providers when the provider needs methods to modify state.
// Synchronous notifier — e.g., a filter or toggle
@riverpod
class TaskFilter extends _$TaskFilter {
@override
TaskFilterState build() {
return const TaskFilterState();
}
void setStatus(TaskStatus? status) {
state = state.copyWith(status: status);
}
void toggleShowCompleted() {
state = state.copyWith(showCompleted: !state.showCompleted);
}
}// Async notifier — e.g., CRUD operations
@riverpod
class TaskList extends _$TaskList {
@override
Future<List<Task>> build() async {
return ref.watch(taskRepositoryProvider).getTasks();
}
Future<void> addTask(CreateTaskRequest request) async {
state = const AsyncLoading();
state = await AsyncValue.guard(() async {
final repo = ref.read(taskRepositoryProvider);
await repo.createTask(request);
// REQUIRED: check ref.mounted after every await
if (!ref.mounted) return state.requireValue;
return repo.getTasks();
});
}
Future<void> deleteTask(String id) async {
state = const AsyncLoading();
state = await AsyncValue.guard(() async {
final repo = ref.read(taskRepositoryProvider);
await repo.deleteTask(id);
if (!ref.mounted) return state.requireValue;
return repo.getTasks();
});
}
}Use functional providers for derived values with no side-effects.
// Computed value — filtered task list
@riverpod
List<Task> filteredTasks(Ref ref) {
final tasks = ref.watch(taskListProvider).valueOrNull ?? [];
final filter = ref.watch(taskFilterProvider);
return tasks.where((t) => filter.matches(t)).toList();
}
// Async one-shot read — e.g., fetch a single task
@riverpod
Future<Task> taskDetail(Ref ref, String id) async {
return ref.watch(taskRepositoryProvider).getById(id);
}
// Stream — real-time data
@riverpod
Stream<List<Task>> taskStream(Ref ref) {
return ref.watch(taskRepositoryProvider).watchAll();
}Family providers (parameterized): When a provider takes extra arguments beyond Ref, Riverpod creates a family — each unique argument combination gets its own independent provider instance with its own cache and disposal. With code generation (which we mandate), any number of parameters are supported, including named, optional, and default values. Constraints:
== and hashCode (primitives, freezed models, Dart records all work)// ✅ Family with a single key
@riverpod
Future<Task> taskDetail(Ref ref, String id) async {
return ref.watch(taskRepositoryProvider).getById(id);
}
// ✅ Multiple parameters — fully supported with code generation
@riverpod
Future<List<Task>> projectTasks(Ref ref, String projectId, {TaskStatus? status}) async {
return ref.watch(taskRepositoryProvider).getByProject(projectId, status: status);
}
// Usage: ref.watch(projectTasksProvider('proj-1', status: TaskStatus.done))ref.watch vs ref.read// ✅ ref.watch — subscribes to changes, use inside build() or widget build
final tasks = ref.watch(taskListProvider);
// ✅ ref.read — one-time read, use inside event handlers / notifier actions
Future<void> onSubmit() async {
await ref.read(taskListProvider.notifier).addTask(request);
}
// ❌ Never use ref.watch inside async functions or event handlers
Future<void> onSubmit() async {
final tasks = ref.watch(taskListProvider); // WRONG — causes errors
}Ref.mounted — Mandatory After AwaitsRiverpod 3 throws if you interact with a disposed Ref or Notifier. Always check ref.mounted after any await in a notifier.
Future<void> updateTask(Task task) async {
final repo = ref.read(taskRepositoryProvider);
await repo.update(task);
// REQUIRED: provider may have been disposed during await
if (!ref.mounted) return;
state = await AsyncValue.guard(() => repo.getTasks());
}keepAlive// ✅ autoDispose is the DEFAULT with code generation (@riverpod)
// Provider is disposed when no consumers are listening
@riverpod
Future<Task> taskDetail(Ref ref, String id) async {
return ref.watch(taskRepositoryProvider).getById(id);
}
// ✅ Opt into keepAlive explicitly for app-wide, long-lived state
@Riverpod(keepAlive: true)
class AuthState extends _$AuthState {
@override
Future<User?> build() async {
return ref.watch(authRepositoryProvider).getCurrentUser();
}
}
// ✅ Repositories should also be keepAlive — they hold connection state and
// should not be re-initialized every time a screen rebuilds
@Riverpod(keepAlive: true)
TaskRepository taskRepository(Ref ref) {
return TaskRepositoryImpl(apiClient: ref.watch(apiClientProvider));
}
// ❌ Do not set keepAlive: false — that is the default
// ❌ Do not set keepAlive: true for screen-scoped stateAll data access goes through an abstract repository interface. This is the Flutter expression of the Testability-First architecture (see @.agents/rules/architectural-pattern.md).
// repository/task_repository.dart — Abstract interface (contract)
abstract class TaskRepository {
Future<List<Task>> getTasks();
Future<Task> getById(String id);
Future<void> createTask(CreateTaskRequest request);
Future<void> deleteTask(String id);
}// repository/task_repository_impl.dart — Production adapter
class TaskRepositoryImpl implements TaskRepository {
const TaskRepositoryImpl({required this.apiClient});
final ApiClient apiClient;
@override
Future<List<Task>> getTasks() async {
final response = await apiClient.get('/tasks');
return (response.data as List)
.map((e) => Task.fromJson(e as Map<String, dynamic>))
.toList();
}
@override
Future<Task> getById(String id) async {
final response = await apiClient.get('/tasks/$id');
return Task.fromJson(response.data as Map<String, dynamic>);
}
@override
Future<void> createTask(CreateTaskRequest request) async {
await apiClient.post('/tasks', data: request.toJson());
}
@override
Future<void> deleteTask(String id) async {
await apiClient.delete('/tasks/$id');
}
}// repository/task_repository_mock.dart — Test adapter
class MockTaskRepository implements TaskRepository {
final List<Task> _tasks = [];
@override
Future<List<Task>> getTasks() async => List.unmodifiable(_tasks);
@override
Future<Task> getById(String id) async =>
_tasks.firstWhere((t) => t.id == id);
@override
Future<void> createTask(CreateTaskRequest request) async {
_tasks.add(Task(id: 'mock-id', title: request.title));
}
@override
Future<void> deleteTask(String id) async {
_tasks.removeWhere((t) => t.id == id);
}
}// Wiring — provider that the rest of the app depends on
@Riverpod(keepAlive: true)
TaskRepository taskRepository(Ref ref) {
return TaskRepositoryImpl(apiClient: ref.watch(apiClientProvider));
}
// In tests, override with mock:
// taskRepositoryProvider.overrideWith((_) => MockTaskRepository())// ✅ Prefer ConsumerWidget — stateless, simpler
class TaskListView extends ConsumerWidget {
const TaskListView({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final asyncTasks = ref.watch(taskListProvider);
return asyncTasks.when(
data: (tasks) => TaskListBody(tasks: tasks),
loading: () => const LoadingIndicator(),
error: (e, _) => ErrorView(error: e),
);
}
}
// Use ConsumerStatefulWidget only when local widget state + riverpod is neededRiverpod 3 automatically retries providers that throw, using exponential backoff. This improves resilience against transient network failures.
// ✅ Default behavior — providers auto-retry on failure
// No action needed for standard use
// ✅ Disable retry for a specific provider when failure is non-transient
@Riverpod(retry: null)
Future<Config> appConfig(Ref ref) async {
return ref.watch(configRepositoryProvider).load();
}
// ✅ Disable globally via ProviderScope
ProviderScope(
retry: (_, __) => null, // disable for all providers
child: const MyApp(),
)Rules:
Riverpod 3 automatically pauses provider listeners when the consuming widget is no longer visible. When the widget becomes visible again, listeners resume.
This is automatic — no action needed. Be aware of it when debugging.
ProviderException WrappingWhen a provider fails, reading it in Riverpod 3 throws a ProviderException wrapping the original error, not the raw exception.
// ✅ Catch ProviderException when reading providers that may fail
try {
final value = container.read(myProvider);
} on ProviderException catch (e) {
// e.exception contains the original error
// e.provider contains which provider failed
}// ✅ Assert on provider failure in tests
expect(
() => container.read(myProvider),
throwsA(isA<ProviderException>()),
);==)Riverpod 3 uses the == operator (not identical) to determine if state changed and rebuilds are needed. This means:
freezed models work correctly out of the box (generated ==)== / hashCode or use freezedupdateShouldNotify on a Notifier for custom comparison logicAlways handle all three AsyncValue states: data, loading, error
// ✅ Exhaustive
asyncValue.when(
data: (data) => DataWidget(data: data),
loading: () => const CircularProgressIndicator(),
error: (err, stack) => ErrorText(err.toString()),
);Surfacing notifier errors to UI — use when(error:...) for exhaustive handling; use hasError only for conditional checks alongside a separate data display:
// ✅ Exhaustive — covers all states, preferred for full-screen states
asyncTasks.when(
data: (tasks) => TaskListBody(tasks: tasks),
loading: () => const LoadingIndicator(),
error: (e, _) => ErrorView(error: e),
);
// ✅ Conditional — show inline error banner while keeping stale data visible
if (asyncTasks.hasError) {
// show snackbar or inline error
}
final tasks = asyncTasks.valueOrNull ?? const [];Use safe AsyncValue accessors to prevent runtime crashes
// ✅ Safe — returns null if state is loading or error
final tasks = ref.watch(taskListProvider).valueOrNull;
// ⚠️ Unsafe — throws StateError if state is not AsyncData
// Only use when you have already confirmed the state is loaded
final tasks = ref.watch(taskListProvider).requireValue;Use AsyncValue.guard inside notifier actions to wrap async calls
AsyncError automaticallyUse StreamProvider for real-time data — never poll manually with Timer
Always check ref.mounted after await — see Ref.mounted section above
Force a provider to re-fetch with ref.invalidate
// ✅ Invalidate from outside a notifier (e.g., after a form submit in a widget)
ref.invalidate(taskListProvider);
// The next watch/read will trigger a fresh build()
// ✅ Invalidate from inside a notifier after a mutation
Future<void> addTask(CreateTaskRequest request) async {
final repo = ref.read(taskRepositoryProvider);
await repo.createTask(request);
if (!ref.mounted) return;
ref.invalidateSelf(); // triggers build() to re-run and return fresh list
}Decision: invalidateSelf() vs manual state assignment
After a mutation:
├── Need optimistic UI (instant visual update before server confirms)?
│ └── YES → Set state manually via AsyncValue.guard
│ (e.g., remove item from list immediately, then call API)
└── NO → ref.invalidateSelf() (simpler, always correct — re-runs build())Define a typed exception hierarchy using sealed classes (Dart 3+). Map infrastructure exceptions to domain exceptions inside notifier actions.
// core/errors/app_exception.dart — Typed exception hierarchy
sealed class AppException implements Exception {
const AppException(this.message);
final String message;
@override
String toString() => message;
}
class NetworkException extends AppException {
const NetworkException(super.message, {this.statusCode});
final int? statusCode;
}
class ValidationException extends AppException {
const ValidationException(super.message, {required this.field});
final String field;
}
class NotFoundException extends AppException {
const NotFoundException(super.message);
}// ✅ Map infrastructure exceptions to domain exceptions inside notifier actions
Future<void> addTask(CreateTaskRequest request) async {
state = const AsyncLoading();
state = await AsyncValue.guard(() async {
try {
final repo = ref.read(taskRepositoryProvider);
await repo.createTask(request);
if (!ref.mounted) return state.requireValue;
return repo.getTasks();
} on DioException catch (e) {
// Transform infrastructure error → domain error
throw NetworkException(
'Failed to create task: ${e.message}',
statusCode: e.response?.statusCode,
);
}
});
}// ✅ Handle typed errors in UI
asyncTasks.when(
data: (tasks) => TaskListBody(tasks: tasks),
loading: () => const LoadingIndicator(),
error: (error, _) => switch (error) {
NetworkException() => ErrorView(message: 'Network error: ${error.message}'),
NotFoundException() => const ErrorView(message: 'Not found'),
_ => ErrorView(message: 'Unexpected error: $error'),
},
);Rules:
AppException (sealed class)DioException, SocketException) are caught and re-thrown as domain exceptionsswitch on the sealed class in error displayerror-handling-principles.md for general error handling guidancego_routergo_router is the canonical navigation library.
// core/router/app_router.dart
@riverpod
GoRouter appRouter(Ref ref) {
return GoRouter(
initialLocation: '/tasks',
routes: [
GoRoute(path: '/tasks', builder: (_, __) => const TaskListView()),
GoRoute(
path: '/tasks/:id',
builder: (_, state) => TaskDetailView(
// state.pathParameters['id'] is guaranteed non-null by the :id
// route pattern — acceptable use of ! in route infrastructure code
id: state.pathParameters['id']!,
),
),
],
);
}
// Navigate — always by path, never by widget reference
context.go('/tasks/$taskId');
context.push('/tasks/new'); // push adds to the back stackNull safety — use ?., ??, and ??= idiomatically
final city = user?.address?.city ?? 'Unknown';
cache ??= await compute(); // assign only if nullUse late only for fields initialized before first use that cannot be final
final fields initialized in the constructorlate without initialization is an unsafe nullable escape hatchExtension methods for adding behaviour to types you don't own
extension TaskStatusLabel on TaskStatus {
String get label => switch (this) {
TaskStatus.pending => 'Pending',
TaskStatus.done => 'Done',
};
}Use switch expressions (Dart 3+) for exhaustive pattern matching
final label = status switch {
TaskStatus.pending => 'Pending',
TaskStatus.done => 'Done',
// Compiler error if a case is missing
};Avoid dynamic — it is the Dart equivalent of TypeScript's any
Test naming and pyramid proportions are defined in
testing-strategy.md. This section covers Flutter/Riverpod 3 test patterns.
ProviderContainer.testProviderContainer.test creates an isolated container that auto-disposes after the test — no manual addTearDown needed.
test('addTask updates state', () async {
final container = ProviderContainer.test(overrides: [
taskRepositoryProvider.overrideWith((_) => MockTaskRepository()),
]);
await container.read(taskListProvider.notifier).addTask(request);
expect(container.read(taskListProvider).value, hasLength(1));
});build Method with overrideWithBuildWhen you need to control initial state but keep the notifier's methods intact:
test('deleteTask removes item from pre-seeded list', () async {
final container = ProviderContainer.test(overrides: [
taskRepositoryProvider.overrideWith((_) => MockTaskRepository()),
taskListProvider.overrideWithBuild((ref, notifier) {
// Seed initial state — methods (addTask, deleteTask) still work
return Future.value([mockTask1, mockTask2]);
}),
]);
await container.read(taskListProvider.notifier).deleteTask(mockTask1.id);
expect(container.read(taskListProvider).value, hasLength(1));
});ProviderScopetestWidgets('shows task list', (tester) async {
await tester.pumpWidget(ProviderScope(
overrides: [
taskRepositoryProvider.overrideWith((_) => MockTaskRepository()),
],
child: const MaterialApp(home: TaskListView()),
));
expect(find.byType(TaskCard), findsWidgets);
});mockito with @GenerateNiceMocks for Interface MocksPlace the annotation on the library (top of the test file or on main) and add a part directive for the generated file:
// task_notifier_test.dart
@GenerateNiceMocks([MockSpec<TaskRepository>()])
library;
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'task_notifier_test.mocks.dart'; // generated by build_runner
void main() {
// tests use MockTaskRepository()
}These are common mistakes agents reproduce from Riverpod 2 training data. Every item below is a hard rule violation.
| ❌ Anti-Pattern | ✅ Correct Pattern |
|---|---|
StateProvider | @riverpod class with Notifier |
StateNotifierProvider | @riverpod class with Notifier |
ChangeNotifierProvider | @riverpod class with Notifier |
import 'package:riverpod/legacy.dart' | Never import legacy APIs |
Typed ref subclass (TaskDetailRef ref) | Ref ref — Riverpod 3 uses a single Ref type; typed subclasses were a Riverpod 2 codegen artifact that no longer exists |
ref.watch inside async/event handler | ref.read for one-shot reads in handlers |
Accessing state/ref after await without ref.mounted check | Always check ref.mounted after await |
ProviderContainer() + addTearDown(container.dispose) | ProviderContainer.test(overrides: [...]) |
Timer.periodic for polling data | StreamProvider or Stream return |
keepAlive: false in annotation | Omit — false is the default |
Manual providers without @riverpod annotation | Always use code generation |
| Catching raw exceptions from provider reads | Catch ProviderException |
overrideWith((_) => MockNotifier()) when only initial state needs seeding | overrideWithBuild(...) — keeps notifier methods intact, only seeds initial state |
| Tool | Purpose | Config File |
|---|---|---|
dart format | Canonical formatting | — (built-in) |
flutter analyze | Static analysis + lint | analysis_options.yaml |
riverpod_lint | Riverpod-specific lint rules | dev_dependencies |
dart pub deps | Dependency audit | — |
dart run build_runner build | Generate provider code | — |
Mandatory analysis_options.yaml settings (Dart 3+):
analyzer:
language:
strict-casts: true
strict-raw-types: true
errors:
invalid_assignment: error
plugins:
- riverpod_lint
linter:
rules:
- prefer_const_constructors
- prefer_const_declarations
- avoid_dynamic_calls
- avoid_print
- use_super_parametersAfter any code change involving providers, run:
dart run build_runner build --delete-conflicting-outputs
flutter analyze
dart format .During active development, use watch mode to avoid re-running manually:
dart run build_runner watch --delete-conflicting-outputs© irahardianto, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
SKILL.md and 1 other file (references) in .agents/skills/flutter-idioms of irahardianto/awesome-agv.
Open the folder on GitHubat commit 9e997ba
Flutter Idioms next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| Flutter Idioms this skillirahardianto/awesome-agv | 156 | — | ~7.3k | Automated safety check: Pass | MIT | |
| Flutter Initbear2u/my-skills | 932 | — | ~2.5k | Automated safety check: Pass | None | |
| Flutter Riverpod State Managementandrewyng/context-hub | 14k | — | ~1.1k | Automated safety check: Pass | MIT | |
| BlocVeryGoodOpenSource/vgv-ai-flutter-plugin | 170 | — | ~2k | Automated safety check: Pass | MIT | |
| Flutter Dart Code Reviewaffaan-m/ECC | 277k | 2 repos | ~5.8k | Automated safety check: Notes | MIT | |
| Signals for Flutterrodydavis/signals.dart | 819 | — | ~1.9k | Automated safety check: Pass | Apache-2.0 |
bear2u/my-skills
A skill your agent uses when user wants to create a new Flutter project (Todo/Habit/Note/Expense/Custom domain) with Clean Architecture, Riverpod 3.0, Drift, and modern Flutter stack
andrewyng/context-hub
Guides Flutter state management with Riverpod: choosing provider types, wiring ConsumerWidgets, handling async state and lifecycle, and overriding providers in tests.
VeryGoodOpenSource/vgv-ai-flutter-plugin
Best practices for Bloc state management in Flutter/Dart, covering Cubit versus Bloc, event and state naming, sealed classes with Equatable, the Page/View split with BlocProvider, BlocBuilder…
affaan-m/ECC
Library-agnostic Flutter/Dart code review checklist covering widget best practices, state management patterns (BLoC, Riverpod, Provider, GetX, MobX, Signals), Dart idioms, performance…
rodydavis/signals.dart
Reference for the signals_flutter package: reactive signals, computed values, effects, async signals and collection signals bound to Flutter widgets.
alinaqi/maggy
Flutter development with Riverpod state management, Freezed, gorouter, and mocktail testing
irahardianto/awesome-agv
Commits to one bold aesthetic direction, sets up a CSS token system for it, then builds the interface in Vue or plain HTML using those tokens.
irahardianto/awesome-agv
Profile-driven performance optimization protocol. An agent skill from irahardianto/awesome-agv.
irahardianto/awesome-agv
Coding conventions for Angular 19 and later: standalone components, signals, OnPush change detection, lazy routes and where RxJS still belongs.
irahardianto/awesome-agv
Rules for designing CI/CD pipelines in layers: universal lint, test and scan stages, container builds with SBOM attestation, and GitOps for orchestrated deployments.
irahardianto/awesome-agv
Hono lightweight web framework patterns: type-safe route handlers, middleware composition, Zod validation, and RPC clients for Cloudflare Workers, Node, or Bun.
irahardianto/awesome-agv
Mobile E2E testing patterns — Flutter integrationtest, Patrol, Maestro, golden testing, device matrix, and test data management.
Works with
Categories
Flutter idioms: Riverpod 3 state management, Freezed immutable models, gorouter navigation, const widget optimization, and repository patterns. Flutter Idioms is an agent skill from irahardianto/awesome-agv. Flutter idioms: Riverpod 3 state management, Freezed immutable models, gorouter navigation, const widget optimization, and repository patterns.
Flutter Idioms fits situations like: reviewing Flutter mobile applications; tasks that involve Cross-platform mobile apps; tasks that involve State management.
Run `npx skills add irahardianto/awesome-agv --skill flutter-idioms -a claude-code`. Or copy the skill folder (.agents/skills/flutter-idioms in irahardianto/awesome-agv) into .claude/skills/flutter-idioms in your project. Claude Code loads it when a task matches its description.
Run `npx skills add irahardianto/awesome-agv --skill flutter-idioms -a codex`. Or copy the skill folder (.agents/skills/flutter-idioms in irahardianto/awesome-agv) into .agents/skills/flutter-idioms in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add irahardianto/awesome-agv --skill flutter-idioms -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/flutter-idioms, .gemini/skills/flutter-idioms, .github/skills/flutter-idioms and .opencode/skills/flutter-idioms in your project.
Going by SKILL.md and its folder, Flutter Idioms needs the command-line tools its instructions call (dart and flutter).
SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.
Flutter Idioms is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.
About 7.3k tokens (SKILL.md is roughly 29k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 1.4k tokens, read only when the agent opens those files.
Skills that share tags, products or a category with Flutter Idioms: Flutter Init (bear2u/my-skills, 932 stars), Flutter Riverpod State Management (andrewyng/context-hub, 14k stars), Bloc (VeryGoodOpenSource/vgv-ai-flutter-plugin, 170 stars) and Flutter Dart Code Review (affaan-m/ECC, 277k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
irahardianto (a GitHub user) maintains it in irahardianto/awesome-agv, which has 156 GitHub stars. The repository holds 34 skills in this directory. The repository was last updated on October 5, 2026.
Source: irahardianto/awesome-agv on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.