2
#how to instantiate another class using local variable in dart? #

==========================================================================

How can I use myStatus variable to instantiate ToDoList class

class _HomeState extends State<Home> {
  var myStatus = "Done";
  List<ToDoList> todoText = [
    ToDoList("hello", "Hello body", myStatus),
  ];
Ken White
  • 123,280
  • 14
  • 225
  • 444
  • The instance member 'myStatus' can't be accessed in an initializer. Try replacing the reference to the instance member with a different expression.=> vscode response – Jebessa Dejene Mar 18 '22 at 21:38
  • `myStatus` is not a *local* variable. Local variables are declared within a function. `myStatus` is an *instance* variable. – jamesdlin Mar 18 '22 at 22:11

0 Answers0