title: What's the difference between a normal method and a setter method in Dart?
body: <p>I just stared learning Dart yesterday. I want to know what's the difference between a normal method and a setter method in Dart? For example, I have the following demo code.</p>
  <pre><code>class Person {
    String? firstName;
    String? lastName;
  
    // Normal method
    fullName(String? name) {
      var names = name!.split(' ');
      this.firstName = names[0];
      this.lastName = names[1];
    }
  }
  
  main() {
    Person p = Person();
    p.fullName('John Smith');
    print(&quot;${p.firstName} ${p.lastName}&quot;);
  }
  </code></pre>
  <p>And:</p>
  <pre><code>class Person {
    String? firstName;
    String? lastName;
  
    // Setter
    set fullName(String? name) {
      var names = name!.split(' ');
      this.firstName = names[0];
      this.lastName = names[1];
    }
  }
  
  main() {
    Person p = Person();
    p.fullName = 'John Smith';
    print(&quot;${p.firstName} ${p.lastName}&quot;);
  }
  </code></pre>
  <p>The difference seems only the invocation syntax. Besides that, are there any other differences?</p>