unifyapps_sdk_flutter 0.0.1
unifyapps_sdk_flutter: ^0.0.1 copied to clipboard
UnifyApps SDK Flutter
UnifyApps SDK Flutter #
A powerful Flutter SDK that enables seamless integration of UnifyApps into your mobile applications with built-in authentication, dynamic data handling, and real-time communication.
Overview #
The UnifyApps SDK Flutter provides a Flutter widget that connects your mobile app to UnifyApps platforms. It handles user authentication, data synchronization, and bi-directional communication between your Flutter app and UnifyApps.
Key Features #
🔐 Secure Authentication #
- Token-based authentication system
- Identity provider integration
- Automatic session management
- Secure credential handling
📡 Real-time Communication #
- Bi-directional event system
- Listen to app events and user interactions
- Send data updates from Flutter to UnifyApps
- Handle notifications and status changes
🔄 Dynamic Data Management #
- Pass initial data to UnifyApps on load
- Update data in real-time without page refresh
- Handle complex data structures and nested objects
- Automatic data serialization
🎯 Page Navigation #
- Direct navigation to specific pages
- Dynamic page routing
- Context-aware navigation
- Maintain navigation state
Installation #
Add the SDK to your Flutter project:
dependencies:
unifyapps_sdk_flutter: ^0.0.1
Install the package:
flutter pub get
Getting Started #
Basic Integration #
import 'package:flutter/material.dart';
import 'package:unifyapps_sdk_flutter/unifyapps_sdk_flutter.dart';
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('My UnifyApp')),
body: UnifyAppsWidget(
host: 'https://your-app.unifyapps.com',
),
);
}
}
Authenticated Access #
UnifyAppsWidget(
host: 'https://your-app.unifyapps.com',
token: 'user-session-token',
identityProviderId: 'your-identity-provider',
)
Page Navigation with Data #
UnifyAppsWidget(
host: 'https://your-app.unifyapps.com',
pageId: 'dashboard',
pageInputs: {
'userId': currentUser.id,
'role': currentUser.role,
'preferences': currentUser.preferences,
},
)
Real-time Event Handling #
UnifyAppsWidget(
host: 'https://your-app.unifyapps.com',
onPageEvent: (String event) {
switch (event) {
case 'session_expired':
handleSessionExpiry();
break;
case 'data_changed':
syncLocalData();
break;
}
},
)
Advanced Usage #
Dynamic Data Updates #
Use a GlobalKey to access the widget's state and update data dynamically:
class DynamicDataExample extends StatefulWidget {
@override
_DynamicDataExampleState createState() => _DynamicDataExampleState();
}
class _DynamicDataExampleState extends State<DynamicDataExample> {
final GlobalKey<UnifyAppsWidgetState> _appKey = GlobalKey<UnifyAppsWidgetState>();
void updateUserData() {
final newData = {
'timestamp': DateTime.now().toIso8601String(),
'user': {
'id': user.id,
'name': user.name,
'lastActivity': DateTime.now().toIso8601String(),
},
'settings': updatedSettings,
};
_appKey.currentState?.updatePageInputs(newData);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Dynamic Updates'),
actions: [
IconButton(
icon: Icon(Icons.refresh),
onPressed: updateUserData,
),
],
),
body: UnifyAppsWidget(
key: _appKey,
host: 'https://your-app.unifyapps.com',
pageId: 'live-dashboard',
pageInputs: initialData,
),
);
}
}
Event-Driven Architecture #
class EventDrivenExample extends StatefulWidget {
@override
_EventDrivenExampleState createState() => _EventDrivenExampleState();
}
class _EventDrivenExampleState extends State<EventDrivenExample> {
final GlobalKey<UnifyAppsWidgetState> _appKey = GlobalKey<UnifyAppsWidgetState>();
List<String> notifications = [];
void handleAppEvent(String event) {
final event = jsonDecode(event);
// Respond to specific events
if (event == 'session_expired') {
_appKey.currentState?.updatePageInputs({
'session_id': getNewSessionId(),
});
}
}
@override
Widget build(BuildContext context) {
return Column(
children: [
// Notifications area
Container(
height: 100,
child: ListView.builder(
itemCount: notifications.length,
itemBuilder: (context, index) => Text(notifications[index]),
),
),
// UnifyApp
Expanded(
child: UnifyAppsWidget(
key: _appKey,
host: 'https://your-app.unifyapps.com',
onPageEvent: handleAppEvent,
),
),
],
);
}
}
API Reference #
UnifyAppsWidget Widget #
The main widget for integrating UnifyApps into your Flutter application.
Constructor Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
host |
String |
Yes | The UnifyApps host URL |
token |
String? |
No | Authentication token for user sessions |
identityProviderId |
String? |
No | Identity provider for authentication |
pageId |
String? |
No | Specific page to navigate to |
pageInputs |
Map<String, dynamic>? |
No | Initial data to pass to the application |
onPageEvent |
Function(String)? |
No | Callback for handling app events |
Methods
updatePageInputs(Map<String, dynamic> newInputs)
Updates the data passed to the UnifyApp and refreshes the content.
Parameters:
newInputs: The new data to pass to the application
Usage:
// Get reference to the widget state
final appState = _appKey.currentState;
// Update with new data
appState?.updatePageInputs({
'user': updatedUser,
'settings': newSettings,
'timestamp': DateTime.now().toIso8601String(),
});
Platform Support #
- ✅ iOS (12.0+)
- ✅ Android (API 21+)
Requirements #
- Flutter SDK 3.0.0 or higher
- Dart 3.8.1 or higher
- Internet connectivity for UnifyApps communication
Built with ❤️ by the UnifyApps Team