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.
| Requirement | Minimum Version |
|---|---|
| Flutter | 3.10.0 |
| Dart | 3.0.0 |
Android minSdk |
24 (Android 7.0) |
Android compileSdk |
34 |
| iOS minimum | 15.0 |
Add to your pubspec.yaml:
dependencies:
adaptive_core: ^1.0.0Then run:
flutter pub getThe 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" />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
}
}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());
}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',
),
);Call when the user signs out:
await AdaptiveCore.logout();This clears the current user session and flushes the pending HTTP request queue.
All methods throw AdaptiveException on failure:
try {
await AdaptiveCore.initialize(clientId: 'YOUR_API_KEY');
} on AdaptiveException catch (e) {
print('Error [${e.code}]: ${e.message}');
}| 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 |
| 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. |
const AdaptiveUser({
required String userId, // LMS user ID
required String userName, // Display name
required String userEmail, // Email address
});class AdaptiveException implements Exception {
final String code; // Machine-readable error code
final String message; // Human-readable description
}- Fork the repository
- Create your feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'feat: add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License — see the LICENSE file for details.