-
flutte 에서의 명명 규칙flutter 2025. 4. 17. 16:38반응형
변수 명명 (camelCase)
final userName = 'ha_jun'; var isLoggedIn = false; int itemCount = 0;
소문자로 시작하고 단어 경계마다 대문자 (camelCase)
불리언 변수는 is, has, can, should 같은 접두어 사용
user_name, IsLogin, temp1 는 Dart에서는 권장되지 않음
메서드 명명 (camelCase)
void fetchUserData() {} bool validateForm() {} void onLoginPressed() {}
동사로 시작 + 동작이 잘 드러나야 함
onXxx, handleXxx 같은 UI 이벤트 핸들러 표현도 일반적
Fetch_Data(), Submitbtn() 는 안됨
클래스 명명 (PascalCase)
class LoginPage extends StatelessWidget {} class UserModel {} class ProfileController extends GetxController {}
클래스는 항상 대문자로 시작 (PascalCase)
위젯, 모델, 컨트롤러 등 모두 같은 규칙
상수 및 enum (UPPER_SNAKE_CASE or PascalCase)
const int MAX_LENGTH = 20; enum ButtonType { primary, secondary, disabled }
- enum은 PascalCase + 값은 camelCase로
- 전역 상수는 UPPER_SNAKE_CASE, 클래스 내 상수는 camelCase도 OK
파일명 / 디렉터리명 (snake_case)
user_model.dart login_controller.dart home_page.dart
항상 소문자 + 언더바 (_)
HomePage.dart, LoginCtrl.dart → Dart/Flutter 권장 X
반응형'flutter' 카테고리의 다른 글
Flutter 자동화 테스트 함수 정리 (0) 2025.04.28 [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Invalid argument(s): Failed to load dynamic library 'libtensorflowlite_c.so': dlopen failed: library "libtensorflowlite_c.so" not found (1) 2025.04.04 Flutter와 Discode web-hook 설정 (0) 2025.03.24 pub.dev - flutter package publish (패키지 올리기) (1) 2025.03.06 생체 인증 추가 (0) 2025.02.25