ruut 0.0.6
ruut: ^0.0.6 copied to clipboard
Ruut Chat SDK for flutter, elevate your customer experienc with Ruut
Ruut Flutter SDK #
The Ruut Flutter SDK allows developers to easily integrate the Ruut chat widget into their Flutter applications, enabling real-time communication with customers directly within your app.
Installation #
Add the ruut package as a dependency in your pubspec.yaml file:
dependencies:
flutter:
sdk: flutter
ruut: ^1.0.0
Run flutter pub get to install the package.
Usage #
Basic Setup #
To get started with Ruut in your Flutter app, simply import the package and include the Ruut widget in your widget tree. The most basic implementation requires a ruutToken and optionally, a RuutUser object to pass user details to the chat widget.
import 'package:flutter/material.dart';
import 'package:ruut/ruut.dart';
class MyRuutScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Ruut(
ruutToken: 'YOUR_RUUT_TOKEN', // Replace with your Ruut token
user: RuutUser(
id: 'USER_ID', // Replace with actual user ID
email: 'user@example.com', // Replace with actual user email
fullName: 'John Doe', // Replace with actual user name
// Additional user fields can be added as needed
),
onReady: () {
print('Ruut is ready');
},
);
}
}
Passing User Information #
You can pass user details when initializing the Ruut widget. This will be used to set the user context within the Ruut chat widget.
RuutUser(
id: 'USER_ID', // Unique identifier for the user
email: 'user@example.com', // Email address
fullName: 'John Doe', // Full name
avatarUrl: 'https://example.com/avatar.jpg', // Optional avatar URL
phone: '+1234567890', // Optional phone number
identifierHash: 'uniqueHash', // Optional identifier hash for secure user identification
// Other optional fields include social profiles, company name, and more
)
Additional Fields for RuutUser #
The RuutUser object allows for rich user data to be passed to the widget:
RuutUser(
id: 'USER_ID',
email: 'user@example.com',
fullName: 'John Doe',
avatarUrl: 'https://example.com/avatar.jpg',
phone: '+1234567890',
identifierHash: 'uniqueHash',
description: 'User description',
countryCode: 'US',
city: 'New York',
companyName: 'Example Corp',
socialProfiles: SocialProfiles(
twitter: '@johndoe',
linkedin: 'john-doe',
facebook: 'john.doe',
github: 'johndoe',
)
);
Updating User Details #
You can dynamically update the user details after the widget has been initialized by using the Ruut.setUser() method:
Ruut.setUser(RuutUser(
id: 'USER_ID',
email: 'newemail@example.com',
fullName: 'John Doe Updated',
));
Closing the Chat Widget #
To programmatically close the chat widget, call the Ruut.shutdown() method:
Ruut.shutdown();
Customization and Interaction #
onReady Callback #
The onReady callback is triggered once the Ruut widget is fully loaded and ready for interaction.
Ruut(
ruutToken: 'YOUR_RUUT_TOKEN',
onReady: () {
print('Ruut widget is ready!');
},
);