Langsung ke konten
Skillpedia
Aplikasi mobile280k Β· #180

flutter-dart-code-review

Fungsinya

Ini adalah panduan untuk meninjau kode Flutter dan Dart. Panduan ini memeriksa apakah kode sudah terorganisir dengan baik, menggunakan praktik pemrograman yang baik, dan menghindari kesalahan umum, tanpa peduli library state management apa pun yang digunakan.

Kapan dipakai

  • βœ“Saat meninjau kode milik orang lain.
  • βœ“Sebelum menyelesaikan sebuah fitur.
  • βœ“Untuk mempelajari praktik terbaik di Flutter/Dart.

Link skill

https://github.com/affaan-m/ECC/blob/main/pi/core/skills/flutter-dart-code-review/SKILL.md

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/affaan-m/ECC/blob/main/pi/core/skills/flutter-dart-code-review/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit β†’

Contoh permintaan ke AI

β€œTinjau kode Flutter ini, dengan fokus pada praktik terbaik untuk organisasi dan potensi kesalahan.”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Panduan ini memeriksa struktur proyek, penggunaan bahasa Dart yang benar, praktik terbaik dalam membuat widget (bagian tampilan layar), dan cara state (data yang berubah) dikelola. Panduan ini memastikan kode berjalan efisien, mudah diakses, dan aman.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.

Flutter/Dart Code Review Best Practices

Comprehensive, library-agnostic checklist for reviewing Flutter/Dart applications. These principles apply regardless of which state management solution, routing library, or DI framework is used.


1. General Project Health

  • Project follows consistent folder structure (feature-first or layer-first)
  • Proper separation of concerns: UI, business logic, data layers
  • No business logic in widgets; widgets are purely presentational
  • pubspec.yaml is clean β€” no unused dependencies, versions pinned appropriately
  • analysis_options.yaml includes a strict lint set with strict analyzer settings enabled
  • No print() statements in production code β€” use dart:developer log() or a logging package
  • Generated files (.g.dart, .freezed.dart, .gr.dart) are up-to-date or in .gitignore
  • Platform-specific code isolated behind abstractions

2. Dart Language Pitfalls

  • Implicit dynamic: Missing type annotations leading to dynamic β€” enable strict-casts, strict-inference, strict-raw-types
  • Null safety misuse: Excessive ! (bang operator) instead of proper null checks or Dart 3 pattern matching (if (value case var v?))
  • Type promotion failures: Using this.field where local variable promotion would work
  • Catching too broadly: catch (e) without on clause; always specify exception types
  • Catching Error: Error subtypes indicate bugs and should not be caught
  • Unused async: Functions marked async that never await β€” unnecessary overhead
  • late overuse: late used where nullable or constructor initialization would be safer; defers errors to runtime
  • String concatenation in loops: Use StringBuffer instead of + for iterative string building
  • Mutable state in const contexts: Fields in const constructor classes should not be mutable
  • Ignoring Future return values: Use await or explicitly call unawaited() to signal intent
  • var where final works: Prefer final for locals and const for compile-time constants
  • Relative imports: Use package: imports for consistency
  • Mutable collections exposed: Public APIs should return unmodifiable views, not raw List/Map
  • Missing Dart 3 pattern matching: Prefer switch expressions and if-case over verbose is checks and manual casting
  • Throwaway classes for multiple returns: Use Dart 3 records (String, int) instead of single-use DTOs
  • print() in production code: Use dart:developer log() or the project's logging package; print() has no log levels and cannot be filtered

3. Widget Best Practices

Widget decomposition:

  • No single widget with a build() method exceeding ~80-100 lines
  • Widgets split by encapsulation AND by how they change (rebuild boundaries)
  • Private _build*() helper methods that return widgets are extracted to separate widget classes (enables element reuse, const propagation, and framework optimizations)
  • Stateless widgets preferred over Stateful where no mutable local state is needed
  • Extracted widgets are in separate files when reusable

Const usage:

  • const constructors used wherever possible β€” prevents unnecessary rebuilds
  • const literals for collections that don't change (const [], const {})
  • Constructor is declared const when all fields are final

Key usage:

  • ValueKey used in lists/grids to preserve state across reorders
  • GlobalKey used sparingly β€” only when accessing state across the tree is truly needed
  • UniqueKey avoided in build() β€” it forces rebuild every frame
  • ObjectKey used when identity is based on a data object rather than a single value

Theming & design system:

  • Colors come from Theme.of(context).colorScheme β€” no hardcoded Colors.red or hex values
  • Text styles come from Theme.of(context).textTheme β€” no inline TextStyle with raw font sizes
  • Dark mode compatibility verified β€” no assumptions about light background
  • Spacing and sizing use consistent design tokens or constants, not magic numbers

Build method complexity:

  • No network calls, file I/O, or heavy computation in build()
  • No Future.then() or async work in build()
  • No subscription creation (.listen()) in build()

…

Pertanyaan umum

Apa arti 'library-agnostic'?

Artinya, tips ini berlaku untuk library state management apa pun (seperti BLoC, Riverpod, Provider, dan lainnya) yang Anda gunakan dalam proyek Flutter.

Mengapa tidak menggunakan `print()` di kode final?

`print()` bisa membuat log aplikasi menjadi berantakan dan tidak memiliki tingkat keparahan (severity level), sehingga sulit mengidentifikasi pesan penting. Sebaiknya gunakan alat logging khusus untuk keperluan itu.

Apa itu 'widget'?

Widget adalah blok bangunan antarmuka pengguna di Flutter. Widget merepresentasikan elemen visual seperti teks, tombol, layout, dan lainnya.

Detail

Deskripsi asli dari pembuat

Library-agnostic Flutter/Dart code review checklist covering widget best practices, state management patterns (BLoC, Riverpod, Provider, GetX, MobX, Signals), Dart idioms, performance, accessibility, security, and clean architecture. Use when reviewing Flutter or Dart code, whatever state management library the project uses.

repo: affaan-m/ECC

Popularitas

Bintang GitHub
280k
Peringkat
#180
Lisensi
MIT
Diperbarui
15/10/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa