Ghi chú (Comment) trong Dart
🎯 Mục tiêu: Sử dụng comments và documentation annotations trong Dart.
💡 Các loại Comments
// Single-line comment
/*
Multi-line
comment
*/
/// Documentation comment (for dartdoc)
/// Supports **Markdown**📝 Documentation Comments
/// Calculates the sum of two numbers.
///
/// Returns the sum of [a] and [b].
///
/// Example:
/// ```dart
/// var result = add(2, 3); // 5
/// ```
int add(int a, int b) => a + b;
/// A user in the system.
///
/// Use [User.fromJson] to create from JSON.
class User {
/// The user's display name.
final String name;
/// Creates a new user with [name].
User(this.name);
}🔧 TODO Comments
// TODO: Implement error handling
// FIXME: Memory leak issue
// HACK: Temporary workaround✅ Checklist
- Dùng
//cho single-line - Dùng
///cho documentation - Viết doc comments cho public APIs
Tiếp theo: Kiểu dữ liệu Số
Last updated on