dartrosa_external_data
ODK Collect's external data ("dynamic preload") for
DartRosa: pulldata() and
search() appearances over CSV form media. A port of Collect's
dynamicpreload package and the entities module's
PullDataFunctionHandler.
- Add an
ExternalDataPlugintoDartRosaConfig.plugins: CSV media are imported when the form loads (into anExternalDataRepository; in memory by default, or your own persistent one to import only changed files),pulldata()is registered, and saved instances are typed as Collect types them. - Read the choices of selects with a
search()appearance withloadSelectChoices;dartrosa_flutterdoes this for you. PullDataInstanceAdapterlets other sources (such asdartrosa_entities' local entity lists) answerpulldata()first.
Install
dart pub add dartrosa_external_data
Example
import 'dart:convert';
import 'package:dartrosa/dartrosa.dart';
import 'package:dartrosa_external_data/dartrosa_external_data.dart';
Future<void> main() async {
final config = DartRosaConfig(
// Form media, read as jr://file/<name>.
resolver: MapResourceResolver({
'jr://file/fruits.csv': utf8.encode('name,price\nmango,1.5\n'),
}),
plugins: [ExternalDataPlugin(listMedia: (_) => ['fruits.csv'])],
);
// The form calculates pulldata('fruits', 'price', 'name', /data/fruit).
final definition = await FormDefinition.parse(xform, config: config);
final session = definition.createSession();
final [fruit, price] = session.root.children.cast<QuestionNode>();
session.answer(fruit.index, const StringValue('mango'));
print(price.value?.displayText); // 1.5
}
See example/example.dart for the complete program.
Documentation
- Documentation index
- Use CSV data and entities
- Plugins and extension points
- Getting started
- Compatibility matrix
- Migrating from JavaRosa
License
Apache License 2.0 (see LICENSE). Ports ODK Collect code (Apache-2.0); see the licensing notes.
Libraries
- dartrosa_external_data
- ODK Collect's external data ("dynamic preload") for DartRosa:
pulldata()andsearch()appearances over CSV form media. - testing
- Test support: drive forms that use external data with DartRosa's
Scenario.