Dart Operator : Other

Dart Operator : Other

ยท

1 min read

OperatorNameMeaning
()Function applicationRepresents a function call
[]Subscript accessRepresents a call to the overridable [] operator; example: fooList[1] passes the int 1 to fooList to access the element at index 1
?[]Conditional subscript accessLike [], but the leftmost operand can be null; example: fooList?[1] passes the int 1 to fooList to access the element at index 1 unless fooList is null (in which case the expression evaluates to null)
.Member accessRefers to a property of an expression; example: foo.bar selects property bar from expression foo
?.Conditional member accessLike ., but the leftmost operand can be null; example: foo?.bar selects property bar from expression foo unless foo is null (in which case the value of foo?.bar is null)
!Non-null assertion operatorCasts an expression to its underlying non-nullable type, throwing a runtime exception if the cast fails; example: foo!.bar asserts foo is non-null and selects the property bar, unless foo is null in which case a runtime exception is thrown
ย