Skip to main content

go_trust_mobile_sdk 1.0.3 copy "go_trust_mobile_sdk: ^1.0.3" to clipboard
go_trust_mobile_sdk: ^1.0.3 copied to clipboard

A Flutter mobile SDK for GoTrust consent and preference management.

# GO Trust Mobile SDK for Flutter

The **GO Trust Mobile SDK** enables Flutter applications to present **Consent Form** and **Preference Center** experiences for compliant consent collection and user preference management.

---

## 🚀 Getting Started

### Step 1 — Add SDK Dependency
Add the SDK from [pub.dev](https://pub.dev/packages/go_trust_mobile_sdk) to your `pubspec.yaml`:

```yaml
dependencies:
  go_trust_mobile_sdk: ^latest_version

Then run:

flutter pub get

Step 2 — Store Configuration IDs Securely #

Keep the following values in your app configuration (separate values for sandbox/stage/production).

Tip

Best Practice: Load these via environment config (--dark-define) or remote config, rather than hardcoding them inside your UI widgets.

Parameter Description
baseUrl The GO Trust API endpoint
customerId Your unique customer identifier
consentId Consent Form source ID
preferenceFormId Preference Center form ID

🛠️ Implementation Guide #

Step 3 — Prepare Subject Identity and Additional Params #

Before calling SDK screens, prepare the logged-in user identity and mapped fields:

final subjectIdentity = user.email; // or phone
final additionalParams = {
  '8': user.fullName,
  '9': user.phone,
  '163': user.email,
};

Important

additionalParams keys are GO Trust PII field IDs. Confirm the exact mapping for your specific client tenant configuration.

Always check consent status first. Show the Consent Form only when explicitly required by the SDK helper.

final shouldShowConsent = await GoTrustSdkHelper.showConsentForm(
  consentId,
  subjectIdentity,
  baseUrl,
);

  • true $\rightarrow$ Consent Form should be shown.
  • false $\rightarrow$ Consent already exists or no consent popup required.

If shouldShowConsent returns true, route the user to the ConsentFormPage:

Navigator.push(
  context,
  MaterialPageRoute(
    builder: (_) => ConsentFormPage( 
      sourceId: consentId, 
      customerId: customerId, 
      initialSubjectValue: subjectIdentity, 
      additionalParams: additionalParams, 
      baseUrl: baseUrl, 
      showCrossButton: false, // Set to true if you want to allow the user to close without taking action
    ), 
  ),
);

Step 6 — Open Preference Center #

If consent already exists, open the Preference Center login experience:

Navigator.push(
  context,
  MaterialPageRoute(
    builder: (_) => LoginPage( 
      customerId: customerId, 
      preferenceFormId: preferenceFormId, 
      consentId: consentId, 
      emailOrPhone: subjectIdentity, 
      additionalParams: additionalParams, 
      baseUrl: baseUrl, 
    ), 
  ),
);

Step 7 — Prevent Duplicate Popups #

Use a local guard (e.g., a stateful boolean flag or a single-completer pattern) to avoid opening the Consent Form multiple times during the same screen lifecycle or during repeated refreshes.


💡 Tips & Best Practices #

  • Sequential Execution: Keep exactly one consent-check call immediately before your Consent Form navigation logic.
  • Environment Separation: Always enforce environment-wise IDs and base URLs (sandbox vs. stage vs. prod).
  • Data Validation: Validate identity field availability (ensure email or phone is not null/empty) before initiating SDK calls.
  • Persistent Access: Keep the Preference Center accessible from your app settings or user profile menu at all times to maintain compliance.
  • Coverage: Explicitly test both scenarios during QA: (1) a clean user with no prior consent, and (2) an existing user with active consent.

✅ Validation Checklist #

  • ❌ Consent Form opens properly for users without prior consent.
  • ❌ Consent Form does not open if valid consent already exists.
  • ❌ Preference Center login and profile update flow works end-to-end.
  • ❌ additionalParams mapping perfectly matches your tenant configuration dashboard.
  • ❌ Behavior verified and stable on both Android and iOS physical builds.