Dart has it’s own naming conventions for the Variables, Fields, Methods, Classes, and Packages.
1. Variables and Field name will starts with Lower-Case and every Second word’s first letter will be Upper-Case like firstName, secondName, getAllColors. Using Under-Score in the middle of the Variable or Field Name is discussed in Dart. But you can use the underscore at the beginning of a Variable or File Name and if you do so then it will be a Private Variable or Private Field and it’s Scope will be Local.
2. Class names will starts with Upper-Case letter and every second word’s first letter is also Upper-Case like
class People{
}
class ProductService{
}
class MaterialPageRoute{
}
If you want to make the class Private then use Under-Score in front of Class name. See Below :-
class _People{
}
class _ProductService{
}
class _MaterialPageRoute{
}
3. All the Libraries, Packages, Directories, and Source Files will be named LowerCase with UnderScores like lower_case_underscores.
Note :- Constant Names, Methods, Method Parameters will follow the Variable Naming Convention.
const pi = 3.14 -> const_pi = 3.14
getAllProducts(){} -> _getAllProducts(){}
getProductByName(String name){}
- What is On-Page Optimization and Off-page Optimization - March 14, 2024
- [SOLVED] Flutter : PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null) - December 7, 2021
- [Solved] Flutter : Error: The getter ‘subhead’ isn’t defined for the class ‘TextTheme’ from package:flutter/src/material/text_theme.dart’ – searchable_dropdown - December 6, 2021