Cơ BảnFlutter iconFlutter

Named parameters và positional parameters trong hàm Dart khác nhau như thế nào?

Positional parameters được truyền theo thứ tự: void greet(String name, int age) gọi là greet("John", 30).

  • Named parameters dùng dấu ngoặc nhọn: void greet({String? name, int? age}) gọi là greet(name: "John", age: 30).
  • Named parameters có thể tùy chọn; kết hợp từ khóa required để bắt buộc chúng.

Xem toàn bộ Flutter cùng filter theo level & chủ đề con.

Mở danh sách Flutter