-3

I got this error after following a tutorial.

enter image description here

Note: in the screenshot I tired _answersModel and answersModel but none worked.


Here is my Controller:

enter image description here


Then Here is my Model

enter image description here


How can I get rid of this error?

Upos Tyni
  • 63
  • 7
  • 1
    Please [don’t post images of code, error messages, or other textual data.](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-on-so-when-asking-a-question/285557#285557) – tripleee Aug 20 '22 at 20:02

2 Answers2

1

Changing _answersModel to answersModel would fix your issue.

Also calling AnswersController.answersModel doesn't work because answersModel is not a static field, I think you meant call answersController.answersModel

Note: Adding an underscore to a class file is making it private field in dart/flutter which means it can't be accessed in another file.

Rodrick Vy
  • 36
  • 5
0

Make the _answersModel in AnswersController public by removing _ in the begging of name, like answersModel.

Why in the tutorial it works? I may guess that in the tutorial the AnswersController in the same file in main.dart.

Andrew Piterov
  • 340
  • 3
  • 12
  • "Make the _answersModel in AnswersController public by removing _ in the begging of name, like answersModel." I have already done that but didn't work – Upos Tyni Aug 10 '22 at 16:28