1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] Private variables giving the warning not in use try removing the variable

Discussão em 'Mobile' iniciado por Stack, Outubro 13, 2024 às 07:33.

  1. Stack

    Stack Membro Participativo

    I recently started learning Dart and come accross this warning in Dart pad. I don't why this warning is thrown. Can any body explain what is going on here. I have attaced the screenshot.enter image description here

    I didn't expected the warning as the _name variable is in use in the constructer for setting tbe value.

    Code:

    void main() {
    final ani = Animal('Tiger', 23);
    ani.setName = 'Tiggerr';
    }

    class Animal {
    String _name;
    final int age;

    Animal(this._name, this.age) {
    print('hello from constructer');
    }

    set setName(String newName){
    _name = newName;
    }
    }

    Continue reading...

Compartilhe esta Página