3 min read
Launch your Footprint onboarding flow from a Flutter app. Your playbook defines the data to collect and checks to run. Install the SDK first: Installation.
Start an onboarding
- Create an onboarding session. Call POST /onboardings and keep the onboarding session token it returns, such as
obtok_xxx. - Launch the flow. When the user taps a button, for example, call
onboarding.initializewith theonboardingSessionToken, aredirectUrl, yourBuildContext, and anonCompletecallback.
dart1Widget build(BuildContext context) {
2 return MaterialApp(
3 home: Scaffold(
4 body: Center(
5 child: ElevatedButton(
6 onPressed: () {
7 onboarding.initialize(
8 onboardingSessionToken: "YOUR SESSION TOKEN",
9 redirectUrl: "YOUR REDIRECT URL (example: com.footprint.fluttersdk://example)",
10 context: context,
11 onComplete: (result) {
12 print("onComplete: ${result.onboardingId}");
13 },
14 );
15 },
16 child: Text('Launch Footprint Onboarding'),
17 ),
18 ),
19 ),
20 );
21}
Handle the result
When the user completes the flow, onComplete receives an OnboardingCompleteResult with validationToken and onboardingId. Send the onboardingId to your backend and read the result with GET /onboardings/{id}. The ID comes from the device, so check that it matches the id your backend got from POST /onboardings for this user before you act on the result. validationToken is deprecated and will be removed, so use onboardingId when possible.
onComplete received the validation token as a plain string. To upgrade, change onComplete: (token) { ... } to onComplete: (result) { ... } and read result.validationToken.The SDK also reports cancellation and errors. Pass onCancel and onError to initialize:
dart1onboarding.initialize(
2 onboardingSessionToken: "YOUR SESSION TOKEN",
3 redirectUrl: "YOUR REDIRECT URL (example: com.footprint.fluttersdk://example)",
4 context: context,
5 onComplete: (result) {
6 print("onComplete: ${result.onboardingId}");
7 },
8 onCancel: () {
9 print("onCancel: user canceled the flow");
10 },
11 onError: (error) {
12 print("onError: $error");
13 },
14);
Customize the appearance
Pass an appearance object to initialize to change the look of the flow:
dart1onboarding.initialize(
2 onboardingSessionToken: "YOUR SESSION TOKEN",
3 redirectUrl: "YOUR REDIRECT URL (example: com.footprint.fluttersdk://example)",
4 context: context,
5 onComplete: (result) {
6 print("onComplete: ${result.onboardingId}");
7 },
8 appearance: FootprintAppearance(
9 variables: FootprintAppearanceVariables(
10 borderRadius: "8px",
11 colorSuccess: "#10b981",
12 colorError: "#F87171",
13 buttonPrimaryBg: "#5550e9",
14 ),
15 ),
16);
The customization guide lists every variable.
Available props
| Variable | Description |
|---|---|
onboardingSessionToken | The onboarding session token you created. |
redirectUrl | A deep link used to navigate back to your app if the in-app browser was opened during the onboarding process. |
context | Your widget's BuildContext. |
onComplete | Optional. Triggered after the user completes the onboarding flow. You receive an OnboardingCompleteResult with validationToken and onboardingId. Read the result with GET /onboardings/{onboardingId}. |
onError | Optional. Called when there was an unrecoverable error during the onboarding flow. |
onCancel | Optional. Triggered when the user abandons the flow. |
appearance | Optional. A FootprintAppearance object that customizes the look of your integration. |
l10n | Optional. The desired localization, as a FootprintL10n object. See Localization configuration. |
Next steps
- Handle the decision explains how to read the onboarding status on your backend.
- Changelog lists notable releases of
footprint_flutter.