title: I intend to define and use a setter normally in Dart, but I get an error : The method 'setAnimal' isn't defined for the type 'AnimalCage'
body: <pre><code>void main(){
  
    Animal a1 = Animal();
    Cat c1 = Cat();
  
    AnimalCage ac1 = AnimalCage();
  
    ac1.setAnimal(a1); //error: The method 'setAnimal' isn't defined for the type 'AnimalCage'.
  
  
  }
  
  class AnimalCage{
    Animal? _animal;
  
    set setAnimal(Animal animal){
      print('animals setter');
      _animal = animal;
    }
  }
  
  class Animal {
  
  }
  </code></pre>
  <p>I get the above error, but I don't know what's wrong.</p>
  <p>Is there something wrong with using the setter?</p>
  <p>If I define setAnimal as a method, the error will disappear, but I think there is no problem with the setter.</p>