Bỏ qua để đến nội dung

Ghi chú / Chú thích (Comment)

🎯 Mục tiêu: Sử dụng comments và documentation annotations trong Dart.


// Single-line comment
/*
Multi-line
comment
*/
/// Documentation comment (for dartdoc)
/// Supports **Markdown**

/// 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: Implement error handling
// FIXME: Memory leak issue
// HACK: Temporary workaround

  • 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ố