Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can you help me solving this error in flutter , which says 'Error: Can't access 'this' in a field initializer.'?

Here is my code:

enter image description here

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The error is at line :

onTap: () => _showActionSheet(this.context),

I don’t know whats the problem is with this line as I’m a beginner in the flutter. So please help me solving this error.

>Solution :

Firstly, you may use method instead of variable for this.

List<Marker> _list()=>[...]

You can do lazy initialization, but sometimes you may face some issue update context.

late List<Marker> _list = [...]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading