반응형
3.1과 완전히 동일하다.
자세한 것들은 아래에 있는 링크에서 보자.
https://want-to-work-life-balance.tistory.com/entry/Dart-31-Named-Parameters
Dart - 3.1 Named Parameters
일반적인 함수를 선언하려면...String sayHello(String name, int age, String country) { return "Hello $name, you are $age, and you come from $country";}이 함수를 불러오려면...void main() { print(sayHello('me', 12, 'korea'));}이렇게
want-to-work-life-balance.tistory.com
참고 코드를 남기자면, 다음과 같다.
class Player {
final String name;
int xp;
String team;
int age;
// 변수 순서 안중요함.
Player(
{required this.name,
required this.xp,
required this.team,
required this.age});
void sayHello() {
print("Hi my name is $name");
}
}
void main() {
var player = Player(name: 'me', xp: 1200, team: 'blue', age: 25);
}
반응형
'앱 만들기 프로젝트 > Dart' 카테고리의 다른 글
Dart - 4.5 Cascade Notation (0) | 2024.10.16 |
---|---|
Dart - 4.3 Named Constructors (0) | 2024.10.16 |
Dart - 4.1 Constructors(생성자) (0) | 2024.10.16 |
Dart - 4.0 Your First Dart Class (1) | 2024.10.16 |
Dart - 3.5 Typedef (0) | 2024.10.16 |