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;
  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) {
  } finally {
  return result;

This method will create a ...

Get Dart: Scalable Application Development now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.