askonu_flutter 1.0.0
askonu_flutter: ^1.0.0 copied to clipboard
Install the complete AskOnu administrator application securely in Flutter Web, Android, iOS, and macOS dashboards.
example/lib/main.dart
import 'dart:convert';
import 'package:askonu_flutter/askonu_flutter.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
void main() => runApp(const AskOnuExample());
class AskOnuExample extends StatelessWidget {
const AskOnuExample({super.key});
Future<String> _getContext() async {
final response = await http.post(
// Replace this host with the dashboard's authenticated backend.
Uri.parse('https://your-dashboard.example.com/api/askonu/context'),
headers: const <String, String>{'content-type': 'application/json'},
);
if (response.statusCode != 200) {
throw StateError('AskOnu context request failed.');
}
final body = jsonDecode(response.body) as Map<String, dynamic>;
return body['token'] as String;
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'AskOnu Flutter example',
theme: ThemeData(colorSchemeSeed: const Color(0xff246bfd)),
darkTheme: ThemeData.dark(useMaterial3: true),
themeMode: ThemeMode.system,
home: Scaffold(
appBar: AppBar(title: const Text('AskOnu')),
body: AskOnuModule(
agentToken: 'YOUR_LIVE_AGENT_TOKEN',
getContext: _getContext,
),
),
);
}
}