O'Reilly logo

Dart By Example by Davy Mitchell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Posting on the API

In the georestwebservice project in this chapter, the source code is an updated version of the API with the new recordFeature method in the daoapi.dart file, which is as follows:

Future<List<String>> recordFeature(String json) async {
  var dbConn;
  DateTime time = new DateTime.now();
  String featureID = time.millisecondsSinceEpoch.toString();
  List<String> result = new List<String>();

  try {
    dbConn = await connect(uri);

    await dbConn.execute(
        'insert into dm_quakefeatures (qufeat_id, geojson) values (@qufeat_id, @geojson)',
        {'qufeat_id': featureID, 'geojson': json});
  } catch (exception, stacktrace) {
    print(exception);
    print(stacktrace);
  } finally {
    dbConn.close();
  }
  result.add(featureID);
  return result;
}

This method will create a ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required