dartrosa_openrosa
An OpenRosa server client for
DartRosa (ODK Central, KoboToolbox
and other OpenRosa servers). A port of ODK Collect's open-rosa module
and its OpenRosa instance uploader, over package:http, so it works on
the VM, in Flutter and on the web.
OpenRosaClient: form list, manifests, form and media downloads, entity list integrity checks.OpenRosaInstanceUploader:multipart/form-datasubmission withxml_submission_file, split to respect the server'sX-OpenRosa-Accept-Content-Length.HttpClientConnection: Collect's headers and Digest/Basic authentication;WebCredentialsUtilschooses the credentials.InstanceUpload.forFormturns aFormSessionsubmission into an upload, encrypting it (withdartrosa_encryption) when the form asks.
Install
dart pub add dartrosa_openrosa
Example
import 'package:dartrosa_openrosa/dartrosa_openrosa.dart';
import 'package:http/http.dart' as http;
Future<void> main() async {
const serverUrl = 'https://central.example.org/v1/key/TOKEN/projects/1';
final connection = HttpClientConnection(
client: http.Client(),
fileToContentTypeMapper: CollectThenSystemContentTypeMapper(),
userAgent: 'my-app/1.0',
);
final credentials = WebCredentialsUtils(
InMemoryServerCredentialsSettings(serverUrl: serverUrl),
);
final client = OpenRosaClient(
serverUrl,
connection,
credentials,
deviceId: 'my-app:device-1',
);
for (final form in await client.fetchFormList()) {
print('${form.formId} ${form.version}: ${form.downloadUrl}');
}
// Uploading a finalized FormSession submission:
// final uploader = OpenRosaInstanceUploader(connection, credentials);
// await uploader.uploadOneSubmission(
// InstanceUpload.forForm(definition.formDef, submission),
// serverUrl: serverUrl,
// deviceId: 'my-app:device-1',
// );
}
example/example.dart runs the form-list fetch against a mock server.
Documentation
- API reference
- Documentation index
- Download forms, encrypt and submit
- Getting started
- Compatibility matrix
- Plugins and extension points
- Migrating from JavaRosa
License
Apache License 2.0 (see LICENSE). Ports ODK Collect's
open-rosa module and uploader (Apache-2.0); see
the licensing notes.
Libraries
- dartrosa_openrosa
- An OpenRosa server client for DartRosa.