Coding Style
Flutter & Dart coding style guidelines and best practices for the team
GitHub
[GH-1] Repository naming convention
| Type | Format | Example |
|---|---|---|
| Framework AIO | aio_<name> | aio_cli |
| Apps | app_<app_name> | app_wayup |
| AppCast | appcast_<app_name> | appcast_wayup |
All names in lowercase within the LaBelleApp organization: https://github.com/orgs/LaBelleApp/repositories
General
[G-1] Use the AIO template (aio_app_template).
[G-2] Complete the README.md with application-related information.
[G-3] Correct Bundle Name
[G-3.1] iOS
flutter pub global run rename getBundleIdIOS getBundleId =>
com.bundle.id
[G-3.2] Android
flutter pub global run rename getBundleIdANDROID getBundleId =>
com.bundle.id
Check in android/app/build.gradle:
android {
namespace = "com.bundle.id"
...
}Check the folder names: android/app/src/main/kotlin/com/bundle/id/
Check the first line of android/app/src/main/kotlin/com/bundle/id/MainActivity.kt:
package com.bundle.id[G-4] TODO comments
[G-4.1] Remove AIO-related TODOs once completed:
// TODO(AIO-setup): ...
// TODO(RC-setup): ...[G-4.2] Remove TODOs related to completed tasks.
[G-5] Use the Router (via GoRouter). Avoid Navigator.push as much as possible as it makes navigation opaque.
Optimization
[O-1] All assets in assets/ are used in the application with no duplicates.
Verification package: flutter_assets_cleaner
dev_dependencies:
flutter_assets_cleaner: ^0.0.9dart run flutter_assets_cleaner --dry-runReturns a list of potentially unused assets. Ignore false positives from assets/fonts/.
[O-2] All packages in pubspec.yaml are used in the application.
To verify: select the package name (e.g. provider: ^6.1.2), then search across all files (Cmd + Shift + F) from the lib/ path. If no results appear, the package is unused.
Documentation
[D-1] All preference keys must have a description of their role:
final Set<String> prefsKeys = {
"isOnboardingDone", // Whether the user has completed the onboarding process
"onboardingState", // Saved state of the onboarding process (page index, answers)
};[D-2] Classes, functions, methods, and especially variables must have explicit names to clarify their role. Avoid names like:
| ❌ Bad | ✅ Good |
|---|---|
List<int> l = [] | List<int> articleList = [] |
int max | int maxArticles |
Object current | Object currentArticle |
[D-3] Folder names, file names, classes, variables, methods, enums, etc. must be in English with consistent and explicit naming:
| Type | ❌ Bad | ✅ Good |
|---|---|---|
| class | NewformHomepage | NewFormHomePage |
| variable | IsonboardingDone | isOnboardingDone |
| file | newform_home_page | new_form_home_page |
| folder | allApp-forms | all_app_forms |
Code
[C-1] Dart Basics
[C-1.1] Add trailing commas:
List<String> list = [
"1",
"2", // <-- trailing comma
];[C-1.2] Avoid anonymous functions when unnecessary:
-onTap: () => _handleOnTap()
+onTap: _handleOnTapSame applies when myMethod expects the same arguments as onTap:
-onTap: (context, child) => _handleOnTap(context, child)
+onTap: _handleOnTap // parameters are passed implicitly[C-1.3] Constructors must always be at the top of a class definition:
class MyClass {
MyClass(); // <-- constructors first
MyClass.namedConstructor();
MyClass.anotherConstructor(int param);
final String name = "Example";
void myMethod() {
print("Hello, World!");
}
}[C-1.4] Avoid using var — it reduces code readability since the type is not explicit.
[C-1.5] Restrict global-scope variables (outside functions or classes) to const constants only.
[C-2] Flutter
[C-2.1] Widget class member ordering:
- Constructors
static constmembersfinalmemberslate finalmembers- Private variable members (
_prefix) - Public variable members
@overridemethods (initState,didChangeDependencies,dispose, …)- Logical methods
buildmethod_build…widget methods
[C-2.2] Check context usage after async operations:
-await Future.delayed(const Duration(milliseconds: 100));
-context.pop();
+await Future.delayed(const Duration(milliseconds: 100));
+if (mounted) context.pop();
+// OR
+if (context.mounted) context.pop();[C-2.3] Do not ignore these warnings/errors:
use_build_context_synchronouslyprefer_const_constructors_in_immutables
[C-2.4] GlobalKey definition and usage:
- Define the key in the widget's file
- Explain why it is used
[C-2.5] Never put tokens/secrets directly in the code — use .env instead.
Cleanliness
[P-1] Remove AI-generated comments that don't clarify how the code works.
[P-2] Commit messages should clearly explain the key changes. Avoid vague commits like "fix".
[P-3] Avoid fixed sizes (height / width) to keep widgets responsive. Build layouts using:
padding/marginLayoutBuilder- Math calculations based on device data (screen size,
SafeArea, …)
Do not use fixed sizes from Figma mockups. This ensures:
- Layout adapts to all phone sizes
- Accessibility settings (e.g. font size scaling) work correctly
- Widgets adapt when reused in different parts of the app