Skip to content
CARP Docs
Ask AISystemLightDark
On this page

Research Package

Surveys, informed consent and structured results for Flutter research apps, modeled on Apple's ResearchKit.

Copy MarkdownOpen inOpen in GitHubView as MarkdownOpen in Scira AIOpen in ChatGPTOpen in ClaudeOpen in Cursor

research_package shows surveys and informed consent flows in a Flutter app and returns the participant's answers as structured results. It is a Flutter implementation of Apple's ResearchKit. You define a task as a list of steps, and the package shows one screen per step on Android and iOS.

The package is part of CARP and works in any Flutter app. In a CARP Mobile Sensing (CAMS) study, carp_survey_package turns these tasks into app tasks and stores their results as measurements. See Survey Sampling Package.

pub.devAPI referenceGitHub

Version 3.2.0 in CAMS apps

These pages document research_package 4.0.0, while apps that also use carp_survey_package or cognition_package get 3.2.0, because both packages require version 3. Tasks, steps, answer formats and results have the same API in both versions, but the permission API differs. For the differences, see Migrate to 4.0.

Features

Surveys

Build surveys from instruction, question, form, timer and completion steps, with seven answer formats.

Informed consent

Explain the study section by section, ask for permissions in context and collect a signature.

Branching

Skip questions, or keep only the steps that earlier answers select, with navigation rules.

Localization

The package's own texts come in seven languages, and every text in a task can be a translation key.

Results

Each run returns one RPTaskResult with the answers and their timestamps, which serializes to JSON.

Activity steps

Run interactive tests that log timings and gestures, such as the cognitive tests in cognition_package.

Requirements

ComponentRequirement
Dart SDK3.12 or later
Flutter3.44 or later
AndroidAPI level 24 (Android 7.0) or later
iOS15.0 or later

The Android and iOS minimums come from the video_player plugin, which plays videos in instruction steps. To ask for permissions in a consent flow, your app adds a plugin such as permission_handler, which brings its own requirements. See Permissions.

How it works

flowchart LR
    Task["<b>Task</b><br/>an RPOrderedTask<br/>with its steps"] --> UI["<b>RPUITask</b><br/>one screen per step"]
    UI -->|onSubmit| App["<b>Your app</b><br/>receives one<br/>RPTaskResult"]

The flow has three stages:

  1. Your app builds a task: an RPOrderedTask with a list of steps, in which each question step has an answer format.
  2. RPUITask shows the steps one screen at a time and records a result for each step that collects an answer.
  3. After the last step, RPUITask calls onSubmit with one RPTaskResult and closes its route.

A task with one slider question, shown on a new route:

final task = RPOrderedTask(
  identifier: 'stressCheck',
  steps: [
    RPQuestionStep(
      identifier: 'stressNow',
      title: 'How stressed do you feel right now?',
      answerFormat: RPSliderAnswerFormat(
        minValue: 0,
        maxValue: 10,
        divisions: 10,
      ),
    ),
    RPCompletionStep(
      identifier: 'done',
      title: 'Thank you',
      text: 'Your answer is saved.',
    ),
  ],
);

Navigator.of(context).push(
  MaterialPageRoute<void>(
    builder: (_) => RPUITask(
      task: task,
      onSubmit: (RPTaskResult result) => print(jsonEncode(result)),
    ),
  ),
);

Next steps

Installation

Add the package, its localization delegates and its translation files.

Quickstart

Build a short survey and print the answers as JSON.

Tasks and steps

Task classes and every step type, with their parameters.

Informed consent

Build a consent flow with sections, permissions and a signature.

Quick links

Page · DocumentationCARP DocumentationPage · DocumentationIntroductionPage · DocumentationQuickstartPage · DocumentationTerminologyPage · DocumentationArchitecture