?
를 타입 뒤에 붙인다. required도 nullable할 수 있음.String sayHello({required String name, required int age}) {
return '$name, hello! you are $age years old.';
}
void main() {
var test = sayHello(
name: 'Seolgi',
age: 4,
);
print(test);
}
[String? opsionval]
left ?? right
일때, left가 널이 아니면 left를 리턴하고, 널이면 right를 리턴한다.left ?? right
간단한 type alias를 만든다.
typedef IntList = List<int>;
IntList il = [1, 2, 3];