thumbnail

Member Access Operator In Dart

Published on 29 March 2020
Last Updated on 29 March 2020

Member access operator is used for accessing member of an instance of a class or property of an expression.

Refer to following program to know when and how member access operator is used.

Program using member access operator

class Person {
  // name is a member of class Person
  String name;
}

main(List<String> args) {
  // initializing variable p
  var p = Person();
  // defining p.name using member access operator
  p.name = 'hello';

  // using the member access operator to get the updated value of p
  var name = p.name;
  print(name);
}

Above program produces following output:

hello