1- Introduction
spect8-chat SDK for Flutter, adds an awesome expansion to Flutter's cross-platform applications for iOS, android and Web by enabling Real-Time Messaging, Polling, Merchandise selling and much more to its users. Platform's provided services are of high reliability, low latency, and high payout.
spect8_ui :
Introduction:
The Spect8 UI includes a UI kit for customizable UI components, providing you with the exact amount of control you need. Create your desired Flutter messaging experience, complete with rich messages, reactions, threads and many others support.
Installation:
-
Add dependencies:
Add the following dependencies to your project as per your requirement in pubspec.yaml file:
dependencies:
spect8_ui: ^1.0.0
-
Download dependency:
Install packages from the command line
$ flutter pub get
-
Accessing Package
Import packages with following commands
import 'package:spect8_ui/spect8_ui.dart';
Using spect8-ui
For displaying chat from a user using spect-ui some steps have to be followed which are necessary, if you have already authenticated and have the correct channelManager please skip to step 3- .
1- Add Client configuration:
The client has to be configured in order to be use the package. Add following code before logging in.
final spect8Client = Spect8Client(
config: ClientConfig(
authURL: 'some-auth-url',
coreURL: 'some-core-url',
webSocketURL: 'some-websockets-url',
));
2- Logging In
For differentiating a user from others in chat authentication is necessary. For authenticating a user a demoUserId and a tenantId are required, demoUserId is any Id which will be used to tell a user apart and tenantId is the id provided to you by us. Authentication provides you with a tenantManager which we will use in next steps.
Future<void> main() async {
TenantManager tenantManager = await spect8Client.connectDemoUser(
demoUserId: 'some-user-id', tenantId: 'your-tenant-id');
runApp(MyApp());
}
3- Identifying a Channel
Spect8 supports multiple broadcasts per tenant and multiple channels per broadcast. So every Tenant can have different broadcasts and each broadcast can have different channels. It is important that we select the correct channel for which we want to display the tabs.
4- Get current user manager:
Get an instance of CurrentUserManager which can be used for operations related to current user.
CurrentUserManager currentUserManager = tenantManager.getCurrentUserManager();
5: Get broadcast manager :
To get a broadcast manager which is used for operations related to a specific broadcast.
BroadcastManager broadcastManager = tenantManager.getBroadcastManager(
broadcastId: 'id-of-a-broadcast');
6- Spect8chat as a widget
class Chatview extends StatelessWidget {
const Chatview({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: <Widget>[
Expanded(
child: Spect8Chat(
currentUserManager: tenantManager.getCurrentUserManager(),
broadcastManager: tenantManager.getBroadcastManager(
broadcastId: 'some-broadcast-id'),),
),
],
),
);
}
}