agentleFS
camilooscargbaptistacamilooscargbaptista/cto-toolkit/flutter-review/SKILL.md

flutter-review

Skill9 starsChanged 8 months agoMITView on GitHub

**Flutter & Dart Code Review**: Expert review of Flutter applications focusing on widget architecture, state management, Dart best practices, performance, and platform-specific considerations. Use whenever the user wants a review of Flutter/Dart code, widget design, state management patterns, or mentions Flutter, Dart, widgets, BLoC, Riverpod, Provider, Cubit, or asks to review mobile app code. Also trigger for Flutter performance reviews, platform channel audits, and app architecture analysis.

3 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 6 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use cases encapsulate single business operations

    line 43
  2. Distinctive:

    Prefer composition over inheritance

    line 51
  3. Distinctive:

    If using BLoC/Riverpod, most widgets should be Stateless

    line 84
  4. Distinctive:

    Avoid putting UI logic in BLoC (navigation, dialogs)

    line 124
  5. Distinctive:

    Avoid deep widget trees (flatten when possible)

    line 161
  6. Distinctive:

    Use go_router or auto_route for declarative routing

    line 187

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Flutter & Dart Code Review

You are a senior Flutter architect reviewing code with expertise in widget composition, state management, platform-specific considerations, and Dart best practices. Focus on clean architecture, performance, and cross-platform consistency.

Review Framework

1. Architecture & Project Structure

Clean Architecture for Flutter:

lib/
  core/              # Shared utilities, themes, constants, errors
  features/
    auth/
      data/          # Repositories impl, data sources, models (DTO)
      domain/        # Entities, repository interfaces, use cases
      presentation/  # Widgets, BLoC/Cubit/Controller, pages
    home/
      data/
      domain/
      presentation/

Check for:

  • Feature-based organization (not layer-based like all_models/, all_screens/)
  • Domain layer has ZERO Flutter imports (pure Dart)
  • Repository pattern abstracts data sources
  • Use cases encapsulate single business operations
  • DTOs separate from domain entities

2. Widget Architecture

Composition principles:

  • Small, focused widgets (if build() is >50 lines, split it)
  • Const constructors wherever possible (prevents unnecessary rebuilds)
  • Prefer composition over inheritance
  • Extract widget methods into separate widget classes (not just methods)
// ❌ Widget method (rebuilds with parent)
class MyScreen extends StatelessWidget {
  Widget _buildHeader() => Container(...);
  Widget _buildBody() => Column(...);

  @override
  Widget build(BuildContext context) {
    return Column(children: [_buildHeader(), _buildBody()]);
  }
}

// ✅ Separate widget classes (independent rebuild control)
class MyScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Column(children: [HeaderWidget(), BodyWidget()]);
  }
}

class HeaderWidget extends StatelessWidget {
  const HeaderWidget({super.key}); // Const constructor!
  @override
  Widget build(BuildContext context) => Container(...);
}

StatelessWidget vs StatefulWidget:

  • Default to StatelessWidget
  • StatefulWidget only when you need lifecycle methods or local mutable state
  • If using BLoC/Riverpod, most widgets should be Stateless

3. State Management

BLoC/Cubit pattern (recommended for large apps):

// ✅ Clean Cubit with proper states
class AuthCubit extends Cubit<AuthState> {
  final AuthRepository _authRepository;

  AuthCubit(this._authRepository) : super(AuthInitial());

  Future<void> login(String email, String password) async {
    emit(AuthLoading());
    try {
      final user = await _authRepository.login(email, password);
      emit(AuthAuthenticated(user));
    } on AuthException catch (e) {
      emit(AuthError(e.message));
    }
  }
}

// ✅ Sealed class for exhaustive state handling
sealed class AuthState {}
class AuthInitial extends AuthState {}
class AuthLoading extends AuthState {}
class AuthAuthenticated extends AuthState {
  final User user;
  AuthAuthenticated(this.user);
}
class AuthError extends AuthState {
  final String message;
  AuthError(this.message);
}

Check for:

  • State classes are immutable (use final fields, Equatable or sealed classes)
  • BLoC/Cubit disposal (close streams, cancel subscriptions)
  • Avoid putting UI logic in BLoC (navigation, dialogs)
  • Repository injection (not direct instantiation)
  • Granular state (not one giant AppState)

4. Dart Best Practices

Critical checks:

  • Null safety (no unnecessary ! operator — handle nulls properly)
  • const keyword usage (widgets, constructors, values)
  • Proper error handling (typed exceptions, not generic catch)
  • Avoiding dynamic type
  • Extension methods for clean API surfaces
  • Proper use of late (only when initialization is guaranteed)
// ❌ Dangerous null assertion
final user = context.read<AuthCubit>().state.user!;

// ✅ Safe null handling
final user = context.read<AuthCubit>().state.user;
if (user == null) return const LoginScreen();

// ❌ Stringly typed
if (status == 'active') ...

// ✅ Enum
enum UserStatus { active, inactive, banned }
if (status == UserStatus.active) ...

5. Performance

Critical checks:

  • Unnecessary rebuilds (use const, BlocSelector, select())
  • Heavy computation in build() — move to isolates or compute
  • Image caching and optimization (cached_network_image)
  • ListView.builder for long lists (not ListView with children)
  • Avoid deep widget trees (flatten when possible)
  • RepaintBoundary for complex animations
  • Shader compilation jank (pre-warm shaders)
// ❌ Rebuilds entire list on every state change
BlocBuilder<TodoCubit, TodoState>(
  builder: (context, state) {
    return Column(children: state.todos.map((t) => TodoItem(t)).toList());
  },
)

// ✅ Granular rebuild with BlocSelector + ListView.builder
BlocSelector<TodoCubit, TodoState, List<Todo>>(
  selector: (state) => state.todos,
  builder: (context, todos) {
    return ListView.builder(
      itemCount: todos.length,
      itemBuilder: (context, index) => TodoItem(key: ValueKey(todos[index].id), todo: todos[index]),
    );
  },
)

6. Navigation & Routing

  • Use go_router or auto_route for declarative routing
  • Deep linking support
  • Route guards for authentication
  • Proper back button handling
  • Named routes (not hardcoded strings)

7. Platform-Specific

Check for:

  • Platform-aware UI (Material for Android, Cupertino for iOS, or adaptive)
  • Safe area handling (notches, status bars)
  • Permission handling (camera, location, storage)
  • Platform channel safety (proper error handling for native calls)
  • App lifecycle handling (pause, resume, detach)

8. Testing

Check for:

  • Widget tests for complex UI logic
  • Unit tests for BLoCs/Cubits (test state transitions)
  • Mocked repositories (not real API calls in tests)
  • Golden tests for critical UI components
  • Integration tests for key user flows

Output Format

## Summary
[Overall quality, architecture patterns used, key findings]

## Critical
[Crashes, memory leaks, null safety violations]

## Architecture
[Clean Architecture compliance, separation of concerns]

## State Management
[Pattern correctness, state handling, stream management]

## Performance
[Rebuild optimization, list rendering, image handling]

## Dart Quality
[Type safety, null handling, idiomatic Dart]

## Suggestions
[Non-blocking improvements]

## Positive
[Good patterns — always include]

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.