💻
Gürkan Fikret Günak - Personal
  • 👨‍💻About me
    • 🌊Journey
  • 🎯Dart
    • 🔬What's Dart Algorithms?
    • 🔬What's Dart Structures?
    • 🧮#01 Algorithm Guidance: Implementing Calculation Algorithms
    • 🧮#02 Algorithm Guidance: Two Sum
  • 📄Guidances
    • Flutter MVVM Guidance
    • Dart Programming Guidance
    • E-Commerce Use Cases
    • E-Commerce Applications
    • Flutter App Color Palette Usage Guidance
    • Flutter Custom AppBar Usage Guidance
    • Flutter Network Image Cache Usage Guidance
    • Flutter Project Bitbucket SSH Guidance
    • Flutter Project GitHub SSH Guidance
    • Flutter SliverAppBar Usage Guidance
    • The Importance of BuildContext in Flutter Tests Guidance
    • Internship Basic Guidance v0.1.0
    • The Importance of Type Casting in Flutter
    • Effective and Detailed Pull Request Guide
    • Flutter Naming Conventions Guidance
    • Flutter Widget Guidance
    • Semantic Commit Guidance
    • Being Part of a Mobile Software Team and Working on a Shared Architecture
    • Understanding Deep Links for Any Development Platform
    • The Journey of a Developer: Stories of Becoming Junior, Middle, and Senior Developer
    • Becoming a Team Leader: Growing in Sync with Your Team
    • Why IP Changes Are Important for Mobile Applications in Flutter
    • Why Your Growing Mobile Team Needs CI/CD and How to Build a Winning Strategy
    • Dart in 2024: 20 Features You Need to Know With Code Examples and Scenarios
    • Remote Theme Management with API (JSON): Implementing a Helper in Flutter SDK
    • Understanding and Implementing Force Upgrade in Your Flutter Project
    • Life Lessons from the Bald Eagle: A Metaphor for Growth, Change, and Leadership
    • The Beauty of Imperfection: Why Today Doesn’t Need to Be Perfect
    • # The Reverse Curve of Productivity: When Social Cohesion in Software Teams Starts to Hurt **How str
    • 📱 Mobil Uygulamalarda GraphQL Tercihi: Bakım ve Maliyet Etkiler
    • 📉 Türkiye’de Yazılım Projelerinde Süreç Yönetimi ve Ekonomik Kayıp: Bir Bekâ Sorunu mu?
  • 📹VIDEOS
    • Introduction to Flutter Boilerplate! ( Turkish )
    • Flutter APIs effective using ( English )
    • Understand to SDK ( English )
  • Links
    • 💼 | Linkedin
    • 🆇 | x.com
    • 📧 | Mail me
Powered by GitBook
On this page
  • Package Names
  • Project Names
  • File Names
  • Class and Function Names
  • Variable Names
  • Constant Names
  • Private Variable and Method Names
  • Boolean Variables
  • Argument Names
  • Widget Names
  • Enum Names
  • Constant Names with Prefix
  • Constructor Names
  • Factory Constructor Names
  • Named Constructor Names
  • Setters and Getters
  • Boolean Getter Names
  • Widget Constructor Arguments
  • Utility Class Names
  • Widget Key Names
  • Constant Values in Switch Statements
  1. Guidances

Flutter Naming Conventions Guidance

In Flutter projects, following a consistent and meaningful naming convention is crucial for code readability and maintainability. This guide provides a set of commonly accepted naming conventions for Flutter projects.

Package Names

Package names should be written in lowercase, and words should be separated by underscores (_).

Example: com.example.my_flutter_app

Project Names

Project names should be written in lowercase, and words should be separated by spaces.

Example: my_flutter_app

File Names

Dart files and other files should be written in lowercase, and words should be separated by underscores (_). File names should be descriptive enough to convey their content.

Examples:

  • user_profile.dart

  • constants.dart

Class and Function Names

Class and function names should follow the "camelCase" convention. Class names should start with an uppercase letter and be descriptive of their purpose.

Examples:

class User {
  // class implementation
}

void fetchUserData() {
  // function implementation
}

Variable Names

Variable names should follow the "camelCase" convention and should be descriptive and meaningful.

Examples:

String userName = 'John Doe';
int userAge = 30;

Constant Names

Constants should be written in uppercase letters and words should be separated by underscores (_).

Examples:

const int MAX_LENGTH = 100;
const int DEFAULT_TIMEOUT = 5000;

Private Variable and Method Names

Private variables and methods should be written with an underscore (_) followed by "camelCase."

Example:

String _privateVariable = 'private data';

void _privateMethod() {
  // method implementation
}

Boolean Variables

Boolean variables should have names that convey a positive meaning if true and a negative meaning if false.

Example:

bool isLoading = true;
bool hasError = false;

Argument Names

Function arguments should have descriptive and meaningful names.

Example:

void calculateArea(double width, double height) {
  // function implementation
}

Widget Names

Custom widgets should have descriptive names that clearly convey their purpose and functionality.

Example:

class CustomButton extends StatelessWidget {
  // widget implementation
}

Enum Names

Enum tipleri, büyük harfle başlamalı ve "camelCase" kullanılmalıdır. Enum değerleri de büyük harfle yazılmalıdır.

enum Color {
  RED,
  GREEN,
  BLUE,
}

Constant Names with Prefix

When declaring constants in a class, use a prefix to indicate their purpose or category.

class APIEndpoints {
  static const String BASE_URL = "https://api.example.com/";
  static const String AUTH_URL = "https://api.example.com/auth";
}

Constructor Names

Constructors should use "camelCase" with the class name in lowercase.

class Person {
  String name;
  
  Person(this.name);
}

Factory Constructor Names

Factory constructors should be named appropriately and use "camelCase."

class APIResponse {
  // factory constructor
  factory APIResponse.fromJson(Map<String, dynamic> json) {
    // create object from JSON data
  }
}

Named Constructor Names

Named constructors should be descriptive and use "camelCase."

class Rectangle {
  int width;
  int height;
  
  Rectangle(this.width, this.height);
  
  // named constructor
  Rectangle.square(int sideLength) : width = sideLength, height = sideLength;
}

Setters and Getters

Use "camelCase" for getter and setter methods, with a prefix like "get" and "set."

class Person {
  String _name;
  
  // setter
  void set name(String newName) {
    _name = newName;
  }
  
  // getter
  String get name {
    return _name;
  }
}

Boolean Getter Names

Boolean getter methods should be descriptive and start with "is" or "has."

class NetworkResponse {
  bool _hasError = false;
  
  bool get hasError {
    return _hasError;
  }
}

Widget Constructor Arguments

When creating custom widgets, constructor arguments should be descriptive and follow "camelCase."

class CustomButton extends StatelessWidget {
  final String text;
  final VoidCallback onPressed;
  
  CustomButton({required this.text, required this.onPressed});
  
  // Widget implementation
}

Utility Class Names

Utility classes should have descriptive names that indicate their purpose.

class DateUtils {
  static DateTime addDays(DateTime date, int days) {
    // implementation
  }
  
  static DateTime subtractDays(DateTime date, int days) {
    // implementation
  }
}

Widget Key Names

When using widget keys, use descriptive names that represent their purpose.

class MyWidget extends StatelessWidget {
  final Key loginButtonKey = Key('login_button');
  final Key signUpButtonKey = Key('signup_button');
  
  // Widget implementation
}

Constant Values in Switch Statements

When using constants in switch statements, capitalize the constant names.

enum Day {
  MONDAY,
  TUESDAY,
  WEDNESDAY,
  // ...
}

void printDay(Day day) {
  switch (day) {
    case Day.MONDAY:
      print('Today is Monday');
      break;
    case Day.TUESDAY:
      print('Today is Tuesday');
      break;
    // ...
  }
}
---


### Abbreviations

Avoid using confusing or obscure abbreviations whenever possible. Names should be clear and easy to understand.

### Logical Grouping

Organize files, classes, and variables logically to keep related code together and maintain a clean project structure.

---

This guide provides a general set of naming conventions for Flutter projects. Remember that each project may have specific requirements, so it's essential to adapt these conventions to suit the project's needs. Consistent and meaningful naming practices will improve code collaboration and make your Flutter project more maintainable.
PreviousEffective and Detailed Pull Request GuideNextFlutter Widget Guidance
📄