flutter_zendes_plugin 0.9.3 copy "flutter_zendes_plugin: ^0.9.3" to clipboard
flutter_zendes_plugin: ^0.9.3 copied to clipboard

outdated

A Zendesk Chat&Support Flutter plugin.

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:flutter_zendes_plugin/flutter_zendes_plugin.dart';

void main() {
  runApp(MyApp());
}

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

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  String _accountKey = 'tFh19KFTd8BBqP3gihF65iF9ep7q4sLa';
  String _applicationId = '1323be531854d29aad23e614fe163fd12c282fd750f649c5';
  String _clientId = 'mobile_sdk_client_1a01855820c478aec204';
  String _domainUrl = 'https://brplay.zendesk.com';
  FlutterZendeskPlugin _flutterPlugin = FlutterZendeskPlugin();

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  // 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 FlutterZendeskPlugin.platformVersion;
      _flutterPlugin.init(
        _accountKey,
        applicationId: _applicationId,
        clientId: _clientId,
        domainUrl: _domainUrl,
        nameIdentifier: "Grayson Identifier",
        emailIdentifier: "Grayson@gmail.com",
        phone: "173****4531",
        name: "Haven iOS",
        email: "HaveniOS@gmail.com",
        departmentName: "Department Name iOS",
      );
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    // 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;
    });
  }

  @override
  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: '),
            RaisedButton(
              onPressed: () async {
                await _flutterPlugin.startChatV1();
              },
              child: Text("Start Chat V1"),
            ),
            RaisedButton(
              onPressed: () async {
                await _flutterPlugin.startChatV2(
                    phone: "173****4531",
                    name: "Haven Android",
                    email: "HavenAndroid@gmail.com",
                    departmentName: "Department Name Android",
                    botLabel: "Bot Label",
                    toolbarTitle: "Online Service");
              },
              child: Text("Start Chat V2"),
            ),
            RaisedButton(
              onPressed: () async {
                await _flutterPlugin.helpCenter().then((value) {
                  print('object<<<<<<<<<<<<< ' + value.toString());
                });
              },
              child: Text("Help Center"),
            ),
          ],
        )),
      ),
    );
  }
}
6
likes
0
pub points
0%
popularity

Publisher

unverified uploader

A Zendesk Chat&Support Flutter plugin.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, package_info

More

Packages that depend on flutter_zendes_plugin