zendesk_flutter_plugin 1.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 83

Bors enabled

zendesk-flutter-plugin #

A Flutter plugin that integrates Zendesk Chat and Support Center to Flutter

Please check the example folder for a full use case of a flutter app that uses the plugin.

You can check agent status on a specific chat account, send online and offline messages, send attachments like images and videos, check if there are any unread messages from the user, get platform version, start and end a chat session with this plugin.

Getting Started #

To use this plugin, add zendesk_flutter_plugin as a dependency in your pubspec.yaml file.

Get the Crendentials for your Zendesk chat API project.

Import package:zendesk_flutter_plugin/zendesk_flutter_plugin.dart, and initiate ZendeskFlutterPlugin with your credentials.

Integration #

        final ZendeskFlutterPlugin _chatApi = ZendeskFlutterPlugin();
        await _chatApi.init("YOUR ZENDESK ACCOUNT KEY")

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

1.0.2 (2019-10-18) #

Documentation Changes

Added usage reference on readme

  • release: Updating pubscpec.yaml description for pubspec
New Features
Bug Fixes

Adding fix for regex when parsing new messages from user on android

1.0.1 (2019-10-15) #

Documentation Changes
  • release: Changing description of the plugin
New Features
Bug Fixes

1.0.0 (2019-10-11) #

Documentation Changes
  • release: Initial release to pub dart, adding author, changelog and licenses
New Features
Bug Fixes


import 'package:image_picker/image_picker.dart';
import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:zendesk_flutter_plugin/zendesk_flutter_plugin.dart';
import 'package:zendesk_flutter_plugin/chat_models.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  _MyAppState createState() => _MyAppState();

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  String _chatStatus = 'Uninitialized';
  String _zendeskAccountkey = '';

  final ZendeskFlutterPlugin _chatApi = ZendeskFlutterPlugin();

  StreamSubscription<ConnectionStatus> _chatConnectivitySubscription;
  StreamSubscription<AccountStatus> _chatAccountSubscription;
  StreamSubscription<List<Agent>> _chatAgentsSubscription;
  StreamSubscription<List<ChatItem>> _chatItemsSubscription;

  void initState() {

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      platformVersion = await _chatApi.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';

    _chatConnectivitySubscription =
    _chatAccountSubscription =
    _chatAgentsSubscription =
    _chatItemsSubscription =

    String chatStatus;
    try {
      await _chatApi.init(_zendeskAccountkey);
      chatStatus = 'INITIALIZED';
    } on PlatformException {
      chatStatus = 'Failed to initialize.';

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
      _chatStatus = chatStatus;

  void dispose() {

  void _chatConnectivityUpdated(ConnectionStatus status) {
    print('chatConnectivityUpdated: $status');

  void _chatAccountUpdated(AccountStatus status) {
    print('chatAccountUpdated: $status');

  void _chatAgentsUpdated(List<Agent> agents) {
    agents.forEach((e) => debugPrint(e.toString()));

  void _chatItemsUpdated(List<ChatItem> chatLog) {
    chatLog.forEach((e) => debugPrint(e.toString()));

  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        body: Center(
            child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            Text('Running on: $_platformVersion\n'),
            Text('Chat status: $_chatStatus'),
              onPressed: () async {
                await _chatApi.startChat('Test Visitor Name',
                    department: 'Card');
              child: Text("Start Chat"),
              onPressed: () async {
                await _chatApi.sendMessage('Greeting from Visitor');
              child: Text("Send Greeting Message"),
              onPressed: () async {
                final file =
                    await ImagePicker.pickImage(source: ImageSource.gallery);
                if (file != null) {
                  try {
                    await _chatApi.sendAttachment(file.path);
                  } on PlatformException catch (e) {
                    debugPrint('An error occurred: ${e.code}');
              child: Text("Send Attachment"),
              onPressed: () async {
                await _chatApi.sendChatRating(ChatRating.GOOD,
                    comment: 'Good service');
              child: Text("Send GOOD Rating"),
              onPressed: () async {
                await _chatApi.sendChatRating(ChatRating.BAD,
                    comment: 'Bad service');
              child: Text("Send BAD Rating"),
              onPressed: () async {
                await _chatApi
                    .sendOfflineMessage('Offline Greeting from Visitor');
              child: Text("Send Offline Message"),
              onPressed: () async {
                await _chatApi.endChat();
              child: Text("EndChat"),

Use this package as a library

1. Depend on it

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

  zendesk_flutter_plugin: ^1.0.2

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:zendesk_flutter_plugin/zendesk_flutter_plugin.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 Apr 8, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

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

Health issues and suggestions

Document public APIs. (-1 points)

90 out of 90 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
package_info ^0.4.0+6 0.4.0+16
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
test ^1.4.0