SDK reference, Flutter SDK / Flutter Common Implementation Patterns

Configure Flows Locally and Run Step by Step

Use this pattern when you want to configure the flow in your app code but run modules section by section, with control returned to your app between sections. This is useful when you need to interleave Incode SDK steps with your app's own screens, perform validation or business logic between steps, or split a long flow into logical phases.

When to use this pattern

Use this pattern when:

  • You want to define your flow's modules in code rather than in Dashboard.
  • You need control returned to your app between groups of modules.
  • You want to call individual SDK modules or group modules into named sections.

For a single end-to-end call that runs all modules consecutively, see Configure Flows Locally and Run End to End. For flows configured in the Incode Dashboard, see Run Flows Configured Online.

Prerequisites

1. Set up the onboarding session

Before calling any other Onboarding SDK components, set up the onboarding session.

OnboardingSessionConfiguration sessionConfiguration = OnboardingSessionConfiguration();

IncodeOnboardingSdk.setupOnboardingSession(
  sessionConfig: sessionConfiguration,
  onError: (String error) {
    print('Incode onboarding session error: $error');
  },
  onSuccess: (OnboardingSessionResult result) {
    print('Incode Onboarding session created! $result');
  },
);

The OnboardingSessionConfiguration accepts the same parameters as the end-to-end pattern. See Configure the onboarding session on the end-to-end pattern page for the full parameter list.

2. Configure a section flow

Once the onboarding session is created, configure a section by creating an OnboardingFlowConfiguration and adding the modules for that section.

OnboardingFlowConfiguration flowConfig = OnboardingFlowConfiguration();
flowConfig.addIdScan();

For the full list of available modules and their configuration parameters, see Modules.

3. Start the onboarding section

Call startOnboardingSection and provide a sectionTag to identify the section. The sectionTag must not be blank. Add per-module listener callbacks to receive results as modules complete.

IncodeOnboardingSdk.startOnboardingSection(
  flowConfig: flowConfig,
  sectionTag: 'idSection',
  onError: (String error) {
    print('Incode onboarding section error: $error');
  },
  onUserCancelled: () {
    print('User cancelled section');
  },
  onIdFrontCompleted: (IdScanResult result) {
    print('onIdFrontCompleted result: $result');
  },
  onIdBackCompleted: (IdScanResult result) {
    print('onIdBackCompleted result: $result');
  },
  onIdProcessed: (String ocrData) {
    print('onIdProcessed result: $ocrData');
  },
  onSuccess: (String sectionTag) {
    print('Section finished: $sectionTag');
  },
);

Section callbacks

  • onError: Called when the section could not start or ended with an error. Receives an IncodeSdkFlowError code. See startOnboardingSection for the codes reported before the section starts.
  • onSuccess: Called once when the section finished. Receives the sectionTag you provided. This is the equivalent of onSuccess on startOnboarding.
  • onUserCancelled: Called when the user cancels the section.
  • Per-module completion callbacks: Optional. Add the callbacks for modules whose results you want to receive as they complete. See Results for the full list of available listeners and their payloads.

Chain multiple sections

To run more than one section within the same session, call startOnboardingSection again with a new flowConfig and sectionTag from the previous section's onSuccess or later. Only one section can run at a time; a call made while a section runs, including from onOnboardingSectionCompleted, calls onError with sectionAlreadyRunning, and the running section continues.

Example:

IncodeOnboardingSdk.startOnboardingSection(
  flowConfig: idFlowConfig,
  sectionTag: 'idSection',
  onSuccess: (String sectionTag) {
    IncodeOnboardingSdk.startOnboardingSection(
      flowConfig: selfieFlowConfig,
      sectionTag: 'selfieSection',
      onSuccess: (String sectionTag) {
        // Continue chaining, or call finishFlow() when done.
      },
      onError: (String error) { /* ... */ },
    );
  },
  onError: (String error) { /* ... */ },
);

Once all sections are complete, call finishFlow() to end the session.

4. Finish the onboarding session

Call finishFlow() when the user has completed all sections and you won't be reusing the same interviewId again. finishFlow() signals the end of the session so it can be closed server-side.

IncodeOnboardingSdk.finishFlow();

finishFlow() is only required for section-based flows. Do not call it for flows started with startOnboarding().

If you do not call finishFlow(), the session remains open on the server. This does not cause issues for subsequent sessions.

Was this page helpful?