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.
Positional parameters are passed in order.
- Named parameters use curly braces and are called by name.
- Named parameters can be optional; combine with the
requiredkeyword to make them mandatory. - Named params improve readability for functions with many arguments.