adaptive_core 1.0.33 copy "adaptive_core: ^1.0.33" to clipboard
adaptive_core: ^1.0.33 copied to clipboard

Flutter plugin for the Adaptive SDK Core module. Provides SDK initialization, user session management, and a resilient HTTP client with offline queue for the Adaptive e-learning platform.

adaptive_core #

pub version License: MIT Platform Android Platform iOS

Flutter plugin for the Adaptive SDK Core module — the foundation layer required by all other Adaptive plugins. It provides:

  • 🔑 SDK Initialization with your client API key
  • 👤 User session management (login / logout)
  • 🌐 Resilient HTTP client with an offline-first persistent request queue (encrypted storage, exponential back-off, up to 3 automatic retries)

Supports Android and iOS.


Table of Contents #


Requirements #

Requirement Minimum Version
Flutter 3.10.0
Dart 3.0.0
Android minSdk 24 (Android 7.0)
Android compileSdk 34
iOS minimum 15.0

Installation #

Add to your pubspec.yaml:

dependencies:
  adaptive_core: ^1.0.0

Then run:

flutter pub get

Android permissions #

The underlying SDK requires internet access. Add to your android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Setup #

No additional Android Gradle configuration is needed. The plugin pulls the native adaptive-core AAR from Maven Central automatically via Gradle.

Ensure your android/build.gradle (project-level) includes mavenCentral():

allprojects {
    repositories {
        google()
        mavenCentral()   // ← required
    }
}

Usage #

1. Initialize #

Call once at app startup — typically in main() before runApp():

import 'package:adaptive_core/adaptive_core.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await AdaptiveCore.initialize(
    clientId: 'YOUR_API_KEY',   // Provided by Adaptive
    debug: true,                 // Set to false in production
  );

  runApp(const MyApp());
}

2. Login #

Call after the user authenticates in your app:

await AdaptiveCore.login(
  const AdaptiveUser(
    userId: '3244',               // Moodle / LMS user ID
    userName: 'Jane Doe',
    userEmail: 'jane@example.com',
  ),
);

3. Logout #

Call when the user signs out:

await AdaptiveCore.logout();

This clears the current user session and flushes the pending HTTP request queue.


Error Handling #

All methods throw AdaptiveException on failure:

try {
  await AdaptiveCore.initialize(clientId: 'YOUR_API_KEY');
} on AdaptiveException catch (e) {
  print('Error [${e.code}]: ${e.message}');
}

Error codes #

Code Cause
INITIALIZATION_ERROR SDK failed to initialize (e.g., invalid context)
LOGIN_ERROR Login call failed or SDK not initialized
LOGOUT_ERROR Logout call failed or SDK not initialized
INVALID_ARGUMENT A required argument was missing or null

API Reference #

AdaptiveCore #

Method Description
initialize({required String clientId, bool debug = false}) Initializes the SDK. Must be called first.
login(AdaptiveUser user) Attaches a user to the session.
logout() Clears the session and HTTP queue.

AdaptiveUser #

const AdaptiveUser({
  required String userId,    // LMS user ID
  required String userName,  // Display name
  required String userEmail, // Email address
});

AdaptiveException #

class AdaptiveException implements Exception {
  final String code;    // Machine-readable error code
  final String message; // Human-readable description
}

Contributing #

  1. Fork the repository
  2. Create your feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'feat: add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

License #

This project is licensed under the MIT License — see the LICENSE file for details.

0
likes
140
points
152
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Flutter plugin for the Adaptive SDK Core module. Provides SDK initialization, user session management, and a resilient HTTP client with offline queue for the Adaptive e-learning platform.

Repository (GitHub)
View/report issues

Topics

#adaptive #sdk #e-learning #lms

License

MIT (license)

Dependencies

flutter

More

Packages that depend on adaptive_core

Packages that implement adaptive_core