Installation

Flutter Inform SDK Wrapper

Authentication with Artifactory

To access the Flutter packages in the Validic Pub repository, generate a Pub token in the Validic Artifactory instance and then store it locally with pub. If you don't have access to Artifactory, please contact Validic support.

Generate a Pub Token in Artifactory

  1. log in to Artifactory
  2. click user icon in top right corner and then "Set Me Up"
  3. Choose "Pub"
  4. Select or type in the mobile-pub repo
  5. Enter user password and click "Generate Token & Create Instructions"

Note: do not run the export PUB_HOSTED_URL=... command shown by Artifactory when the token is generated.

Store the Pub Token Locally to Access Validic Flutter SDKs

  1. run dart pub token add https://validic.jfrog.io/artifactory/api/pub/mobile-pub/
  2. enter the generated pub token when prompted

Usage

Creating a Flutter project using the ValidicMobile plugin involves the following steps.

  1. To use the validic_core package, add it to your pubspec.yaml file:
dependencies:
  validic_core:
    hosted:
      name: validic_core
      url: https://validic.jfrog.io/artifactory/api/pub/mobile-pub
    version: ^2.0.0
  1. Then, import the package in your Dart code:
import 'package:validic_core/validic_core.dart';

These code examples add the Session (validic_core) module to your project.




Example Usage

Create a Validic User

final ValidicUser validicUser = ValidicUser(
  userID: 'VALIDIC_USER_ID',
  organizationID: 'ORGANIZATION_ID',
  accessToken: 'ACCESS_TOKEN',
);

Starting a Session

void startValidicSession() async {
  await ValidicCore.startSession(validicUser);
}

Ending a Session

void endValidicSession() async {
  await ValidicCore.endSession();
}

Submitting a Record

void submitRecord() async {
  final InformRecord record = InformRecord(
    // Initialize the record with appropriate values
  );
  await ValidicCore.submitRecord(record);
}

Listening to events

void listenToEvents() {
  ValidicCore.onSessionEnd.listen((event) {
    print('Session ended: ${event.userID} with ${event.informRecords.length} unsent Records');
  });

  ValidicCore.onRecordSubmit.listen((event) {
    print('Record submitted: ${event.informRecord}');
  });

  ValidicCore.onRecordSubmitError.listen((event) {
    print('Record submission error: ${event.error}');
  });
}