quickblox_sdk 0.2.2-alpha

  • Readme
  • Changelog
  • Example
  • Installing
  • 68

Quickblox Flutter SDK #

Quick Start #

This guide demonstarates how to connect Quickblox Flutter SDK to your project and start development.

Create a new app in the Admin Panel #

Quickblox application includes everything that brings messaging right into your application - chat, video calling, users, push notifications, etc. To create a QuickBlox application, follow the steps below:

  1. Register a new account. Type in your email and password to sign in. You can also sign in with your Google or Github accounts.
  2. Create the app clicking New app button.
  3. Configure the app. Type in the information about your organization into corresponding fields and click Add button.
  4. Go to the screen with credentials. Locate Credentials groupbox and copy your Application ID, Authorization Key, and Authorization Secret. These data are needed to run your application on QuickBlox server.

Install Flutter SDK into your app #

To create a new Flutter chat messaging app with QuickBlox SDK from scratch follow these steps:

  1. Install Flutter for your platform
  2. Run flutter create myapp to create a new project
  3. Add QuickBlox SDK into your project's dependencies into dependencies section in *pubspec.yaml* file in your root project dir.

dependencies: quickblox_sdk: 0.2.2-alpha

Send your first message #

Initialize QuickBlox SDK

Initialize the framework with your application credentials. Pass appId, authKey, authSecret, accountKey to the QB.settings.init method using the code snippet below. As a result, your application details are stored in the server database and can be subsequently identified on the server.

const String APP_ID = "XXXXX";
const String API_ENDPOINT = ""; //optional
const String CHAT_ENDPOINT = ""; //optional

try {
      await QB.settings.init(APP_ID, AUTH_KEY, AUTH_SECRET, ACCOUNT_KEY,
          apiEndpoint: API_ENDPOINT, chatEndpoint: CHAT_ENDPOINT);
    } on PlatformException catch (e) {
        // Some error occured, look at the exception message for more details 

Authorize user

In order to use the abilities of QuickBlox SDK, you need to authorize your app on the server, log in to your account and create a session. To get it all done call QB.auth.login method and pass login and password parameters to it using the code snippet below.

try {
      QBLoginResult result = await QB.auth.login(login, password);
      QBUser qbUser = result.qbUser;
      QBSession qbSession = result.qbSession;
    } on PlatformException catch (e) {
         // Some error occured, look at the exception message for more details     

Note! You must initialize SDK before calling any methods through the SDK except for the method initializing your QuickBlox instance. If you attempt to call a method without connecting, the error is returned.

Connect to chat

To connect to chat server, use the code snippet below:

try {
      await QB.chat.connect(userId, userPassword);
     } on PlatformException catch (e) {
          // Some error occured, look at the exception message for more details     

Create dialog

QuickBlox provides three types of dialogs: 1-1 dialog, group dialog, and public dialog.

Let’s create 1-1 dialog. Call QB.chat.createDialog method and pass QBChatDialogTypes.CHAT parameter as a dialog type to it. QBChatDialogTypes.CHAT parameter allows specifying that two occupants are going to participate in the dialog.

try {
      QBDialog createdDialog = await QB.chat.createDialog(occupantsIds, dialogName, dialogType: dialogType);
      } on PlatformException catch (e) {
           // Some error occured, look at the exception message for more details     

Subscribe to receive messages

QuickBlox provides message event handler allowing to notify client apps of events that happen on the chat. Thus, when a dialog has been created, a user can subscribe to receive notifications about new incoming messages. To subscribe to message events call QB.chat.subscribeMessageEvents method and pass dialogId, eventName, data parameters to it using the following code snippet. The QB.chat.subscribeMessageEvents method tells SDK to send events about new messages. eventName - provides some values:

  • QBChatEvents.RECEIVED_NEW_MESSAGE - subscribe to new messages event
 await QB.chat.subscribeMessageEvents(dialogId, eventName, (data) {
          //receive a new message
          Map<String, Object> map = new Map<String, dynamic>.from(data);
          String messageType = map["type"];
          if (messageType == QBChatEvents.RECEIVED_NEW_MESSAGE) {
             Map<String, Object> payload = new Map<String, dynamic>.from(map["payload"]);
             String messageBody = payload["body"];
             String messageId = payload["id"];
     } on PlatformException catch (e) {
          // Some error occured, look at the exception message for more details     
  • Unsubscribe to new messages event
// eventName - QBChatEvents.RECEIVED_NEW_MESSAGE
try {
      await QB.chat.unsubscribeMessageEvents(dialogId, eventName);
    } on PlatformException catch (e) {
      // Some error occured, look at the exception message for more details

Send message

When a dialog is created, a user can send a message. To create and send your first message, call QB.chat.sendMessage method and specify the dialogId and body parameters to it. Pass saveToHistory parameter if you want this message to be saved in chat history that is stored forever.

try {
      await QB.chat.sendMessage(dialogId, body: messageBody, saveToHistory: true);
      } on PlatformException catch (e) {
          // Some error occured, look at the exception message for more details     


For license information, please visit: https://quickblox.com/terms-of-use/

0.1.0-alpha #

  • Created first version of QuickBlox Flutter SDK

0.2.0-alpha #

  • Added WebRTC video calls
  • Bug fixing
  • Improved implementation for Android

0.2.1-alpha #

  • Improved the methods for subscribe, unsubscribe methods in chat
  • Fixed mapping for dialogs in chat

0.2.2-alpha #

  • Bug fixing


quickblox_sdk_example #

Demonstrates how to use the quickblox_sdk plugin.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  quickblox_sdk: ^0.2.2-alpha

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:quickblox_sdk/quickblox_sdk.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Feb 24, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Fix lib/mappers/qb_custom_object_mapper.dart. (-1.49 points)

Analysis of lib/mappers/qb_custom_object_mapper.dart reported 3 hints:

line 5 col 1: Prefer using /// for doc comments.

line 16 col 30: The value of the local variable 'permission' isn't used.

line 17 col 35: The value of the local variable 'permissionLevel' isn't used.

Fix lib/auth/module.dart. (-0.50 points)

Analysis of lib/auth/module.dart reported 1 hint:

line 9 col 1: Prefer using /// for doc comments.

Fix lib/chat/constants.dart. (-0.50 points)

Analysis of lib/chat/constants.dart reported 1 hint:

line 3 col 1: Prefer using /// for doc comments.

Fix additional 41 files with analysis or formatting issues. (-20 points)

Additional issues in the following files:

  • lib/chat/module.dart (1 hint)
  • lib/customobjects/constants.dart (1 hint)
  • lib/customobjects/module.dart (1 hint)
  • lib/file/constants.dart (1 hint)
  • lib/file/module.dart (1 hint)
  • lib/mappers/qb_attachment_mapper.dart (1 hint)
  • lib/mappers/qb_dialog_mapper.dart (1 hint)
  • lib/mappers/qb_event_mapper.dart (1 hint)
  • lib/mappers/qb_file_mapper.dart (1 hint)
  • lib/mappers/qb_filter_mapper.dart (1 hint)
  • lib/mappers/qb_message_mapper.dart (1 hint)
  • lib/mappers/qb_rtc_session_mapper.dart (1 hint)
  • lib/mappers/qb_session_mapper.dart (1 hint)
  • lib/mappers/qb_sort_mapper.dart (1 hint)
  • lib/mappers/qb_subscription_mapper.dart (1 hint)
  • lib/mappers/qb_user_mapper.dart (1 hint)
  • lib/models/qb_attachment.dart (1 hint)
  • lib/models/qb_custom_object.dart (1 hint)
  • lib/models/qb_custom_object_permission.dart (1 hint)
  • lib/models/qb_custom_object_permission_level.dart (1 hint)
  • lib/models/qb_dialog.dart (1 hint)
  • lib/models/qb_event.dart (1 hint)
  • lib/models/qb_file.dart (1 hint)
  • lib/models/qb_filter.dart (1 hint)
  • lib/models/qb_message.dart (1 hint)
  • lib/models/qb_rtc_session.dart (1 hint)
  • lib/models/qb_session.dart (1 hint)
  • lib/models/qb_sort.dart (1 hint)
  • lib/models/qb_subscription.dart (1 hint)
  • lib/models/qb_user.dart (1 hint)
  • lib/notifications/constants.dart (1 hint)
  • lib/notifications/module.dart (1 hint)
  • lib/push/constants.dart (1 hint)
  • lib/push/module.dart (1 hint)
  • lib/quickblox_sdk.dart (1 hint)
  • lib/settings/module.dart (1 hint)
  • lib/users/constants.dart (1 hint)
  • lib/users/module.dart (1 hint)
  • lib/webrtc/constants.dart (1 hint)
  • lib/webrtc/rtc_video_view.dart (1 hint)
  • lib/webrtc/module.dart (Run flutter format to format lib/webrtc/module.dart.)

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-release. (-5 points)

Pre-release versions should be used with caution; their API can change in breaking ways.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies