Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter - Error: The getter X isn't defined for the class

Tags:

flutter

dart

I have a class TripController that contains a private field _updatedAccount. I created a getter in order to get from outside.

class TripController {
  final String _accountId;
  final BuildContext _context;
  Account _updatedAccount;  
  Account updatedAccount() => _updatedAccount;


  TripController(this._accountId, this._context);
...
}

In another class, where I perfectly have access to the TripController class, I have the code :

onTap: () {
 TripController _tripController =
 new TripController(_account.id, context);
 _tripController.add(context);
 _account.trips  = _tripController.updatedAccount.trips;
 _account.notifyListeners();
},

And here, updatedAccount from _tripController.updatedAccount.trips is underlined in red with the message : The getter 'updatedAccount' isn't defined for the class 'TripController'

Did I misdeclared the getter ?

like image 872
user54517 Avatar asked Jul 23 '19 07:07

user54517


1 Answers

Okay, I finally fixed it. I don't know why, but I had to delete the code related to TripController, and ther re-write it again. I don't know why, maybe it was an Editor problem, I'm using VScode.

like image 147
user54517 Avatar answered Dec 15 '22 10:12

user54517