Operator : ??
If Left side is null then show right side
null ?? 'shown' or non-null ?? 'not Shown'String capitalizeName(String? name, [int? age = 10, String? cntry = 'kor']) { if (name != null) { return name.toUpperCase(); }
return 'Name is null';
}
String capitalizeName1(String? name, [int? age = 10, String? cntry = 'kor']) {
return name != null ? name.toUpperCase() : 'Name is null';
}
String capitalizeName2(String? name, [int? age = 10, String? cntry = 'kor']) {
return name?.toUpperCase() ?? 'Name is null';
}
> Opeator : ??=
var? name;
// do something and
name ??= 'new Name' // 값이 비어있으면 해당 값을 입력해라.