title: Class 'double' has no instance method 'sort'
body: <p>I receive the following NoSuchMethodError in my code:</p>
  <pre><code>I/flutter (22695): {nom: CLINIQUE CENTRE, latitude: 37.4259071, longitude: -122.1095606, distance: 0}
  I/flutter (22695): latitude  de :  CLINIQUE CENTRE37.4259071
  I/flutter (22695): {nom: CLINIQUE CHATEAU, latitude: 37.4420794, longitude: -122.1432758, distance: 0}
  I/flutter (22695): latitude  de :  CLINIQUE CENTRE37.4259071
  I/flutter (22695): NoSuchMethodError: Class 'double' has no instance method 'sort'.
  I/flutter (22695): Receiver: 2.298635770797528
  I/flutter (22695): Tried calling: sort(Closure: (dynamic, dynamic) =&gt; dynamic)
  </code></pre>
  <p>I want de get distance wetween two locations</p>
  <pre><code>import 'package:flutter/material.dart';
  import 'package:geolocator/geolocator.dart';
  import 'package:flutter_sorting_location/Utils.dart';
  import 'package:http/http.dart' as http;
  import 'dart:convert';
  import 'package:flutter_sorting_location/Destination.dart';
  
  class Home extends StatefulWidget {
    @override
    _HomeState createState() =&gt; _HomeState();
  }
  
  class _HomeState extends State&lt;Home&gt; {
    double? distance;
    List destinations = [];
  
    Position? _currentPosition;
    List&lt;Destination&gt; destinationlist = [];
  
    Future&lt;List&gt; getData() async {
      var url = 'http://aidemens.global-aeit.com/flutter/getlocation.php';
      print(url);
      final response = await http.get(Uri.parse(url));
      // print(json.decode(response.body));
      destinations = json.decode(response.body);
      return json.decode(response.body);
    }
  
    @override
    void initState() {
      _getCurrentLocation();
      super.initState();
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
          appBar: AppBar(
            title: Text(&quot;Location sorting from current location&quot;),
          ),
          body: FutureBuilder&lt;List&gt;(
              future: getData(),
              builder: (context, snapshot) {
                if (snapshot.hasError) print(snapshot.error);
                return snapshot.hasData
                    ? ListView.builder(
                        itemCount: snapshot.data!.length,
                        itemBuilder: (context, index) {
                          // print(snapshot.data!);
                          return Card(
                            margin: EdgeInsets.all(5),
                            elevation: 5,
                            child: Padding(
                              padding: EdgeInsets.all(5),
                              child: Container(
                                height: 40,
                                color: Colors.white,
                                child: Column(
                                  children: [
                                    Text(&quot;${snapshot.data![index]['nom']}&quot;),
                                    Text(
                                        &quot;${double.parse(snapshot.data![index]['distance']!).toStringAsFixed(2)} km&quot;),
                                  ],
                                ),
                              ),
                            ),
                          );
                        })
                    : const Center(
                        child: Text(
                          &quot;Aucun encaissement ce jour&quot;,
                          style: TextStyle(color: Colors.red),
                        ),
                      );
              }));
    }
  
    // get Current Location
    _getCurrentLocation() {
      Geolocator.getCurrentPosition(
              desiredAccuracy: LocationAccuracy.best,
              forceAndroidLocationManager: true)
          .then((Position position) {
        distanceCalculation(position);
        setState(() {
          _currentPosition = position;
        });
      }).catchError((e) {
        print(e);
      });
    }
  
    List tmp = [];
  
    distanceCalculation(Position position) {
      tmp.clear();
      for (var d in destinations) {
        if (destinations.isNotEmpty) {
          tmp.add(d);
        }
        destinations = tmp;
        print(d);
  
        //  for (var i = 0; i &lt; destinations.length; i++) {
        // print(&quot;latitude  : &quot; + destinations[d]['latitude'].toDouble());
        var km = getDistanceFromLatLonInKm(
            position.latitude,
            position.longitude,
            double.parse(destinations[0]['latitude']),
            double.parse(destinations[0]['longitude']));
        // var m = Geolocator.distanceBetween(position.latitude,position.longitude, d.lat,d.lng);
        // d.distance = m/1000;
  
        destinations[0]['distance'] = km;
        // d.distance = km;
        //print(&quot;distance : ${d.distance}&quot;);
        // print(&quot;distance : ${destinations[0]['distance']}&quot;);
        //destinations.add(d);
        //print(d);
        // print(&quot;distance 2 : ${destinations[0]['distance']}&quot;);
        /*
        print(getDistanceFromLatLonInKm(
            position.latitude,
            position.longitude,
            destinations[0]['latitude'].toDouble(),
            destinations[0]['longitude'].toDouble()));
            */
        print(&quot;latitude  de :  &quot; +
            destinations[0]['nom'] +
            destinations[0]['latitude']);
      }
  
      setState(() {
        destinations[0]['distance'].sort((a, b) {
          return a.double.parse(destinations[0]['distance'])
              .compareTo(b.double.parse(destinations[0]['distance']) as double);
        });
      });
    }
  }
  </code></pre>
  <p>Utils.dart</p>
  <pre><code>import'dart:math' as Math;
  
  //HaverSine formula
  double getDistanceFromLatLonInKm(lat1,lon1,lat2,lon2) {
    var R = 6371; // Radius of the earth in km
    var dLat = deg2rad(lat2-lat1);  // deg2rad below
    var dLon = deg2rad(lon2-lon1);
    var a =
        Math.sin(dLat/2) * Math.sin(dLat/2) +
            Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *
                Math.sin(dLon/2) * Math.sin(dLon/2)
    ;
    var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
    var d = R * c; // Distance in km
    return d;
  }
  
  double deg2rad(deg) {
    return deg * (Math.pi/180);
  }
  </code></pre>
  <p>my dbb</p>
  <pre><code>CREATE TABLE `adherent` (
    `id` int(11) NOT NULL,
    `nom` varchar(100) NOT NULL,
    `latitude` double NOT NULL,
    `longitude` double NOT NULL,
    `distance` double NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  --
  -- Déchargement des données de la table `adherent`
  --
  
  INSERT INTO `adherent` (`id`, `nom`, `latitude`, `longitude`, `distance`) VALUES
  
  (25, 'wwwwwwwwwwww', 37.4259071, -122.1095606, 0),
  (35, 'xxxxxxxxxxx',  37.4420794, -122.1432758, 0);
  </code></pre>
  <p>code php</p>
  <pre><code> $db_datas = array();
    $sql12 = &quot;SELECT A.nom,A.latitude,A.longitude,A.distance
              FROM adherent A
              WHERE A.id IN(25,35)
      &quot;;
      $results = $conn-&gt;query($sql12);
      
      if($results-&gt;num_rows &gt;0){
          while($row = $results-&gt;fetch_assoc()){
              $db_datas[] = $row;
          }//fin while
           //Retourn toutes les reponses en json
           echo json_encode(utf8ize($db_datas));
      }else{
          echo &quot;erreur&quot;;  
      }
  </code></pre>