Search code examples
flutterdart

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


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 ?


Solution

  • 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.