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

(Flutter/Dart) – How to convert double? to double

anyways to convert double? to double

because i got this message with no auto fix
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

>Solution :

The error you get is from null-safety, the type double? means that it could be either a double, or null, but your parameter only accepts a double, and no null.

For this, you can "force" the use of ‘non-null’ variable by adding a ! at the end of your variable, but be careful when doing this.

CameraPosition(
    target: LatLng(l.latitude!, l.longitude!),
    zoom: 15,
)

You can learn more about null-safety syntax and principles on the official documentation: https://flutter.dev/docs/null-safety

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