(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


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.

    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

Answered By – Amirhussein

Answer Checked By – Dawn Plyler (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *