chatasist_flutter 1.0.13 copy "chatasist_flutter: ^1.0.13" to clipboard
chatasist_flutter: ^1.0.13 copied to clipboard

Flutter plugin for embedding the Chatasist customer support chat widget with realtime messaging, media uploads, and voice/video call support.

example/lib/main.dart

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

void main() {
  runApp(const ExampleApp());
}

class ExampleApp extends StatefulWidget {
  const ExampleApp({super.key});

  @override
  State<ExampleApp> createState() => _ExampleAppState();
}

class _ExampleAppState extends State<ExampleApp> {
  final GlobalKey<NavigatorState> _navigatorKey = GlobalKey<NavigatorState>();
  bool _initialized = false;
  bool _working = false;
  String? _error;

  Future<void> _initialize() async {
    setState(() {
      _working = true;
      _error = null;
    });
    try {
      await chatasistFlutter.initialize(
        ChatasistWidgetOptions(
          baseUrl: 'https://chatasist.com',
          channelId: '00000000-0000-0000-0000-000000000001',
          language: 'en',
          navigatorKey: _navigatorKey,
        ),
      );
      await chatasistFlutter.setIdentity('visitor@example.com');
      setState(() => _initialized = true);
    } catch (e) {
      setState(() => _error = e.toString());
    } finally {
      if (mounted) {
        setState(() => _working = false);
      }
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Chatasist Flutter Example',
      navigatorKey: _navigatorKey,
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
      ),
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Chatasist Flutter Example'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              FilledButton(
                onPressed: _working ? null : _initialize,
                child: Text(_initialized ? 'Reinitialize Widget' : 'Initialize Widget'),
              ),
              const SizedBox(height: 12),
              FilledButton.icon(
                onPressed: !_initialized || _working
                    ? null
                    : () => chatasistFlutter.present(context: _navigatorKey.currentContext),
                icon: const Icon(Icons.chat_bubble_outline),
                label: const Text('Open Chatasist'),
              ),
              const SizedBox(height: 12),
              ValueListenableBuilder<int>(
                valueListenable: chatasistFlutter.unreadCount,
                builder: (BuildContext context, int count, _) {
                  return Text('Unread: $count');
                },
              ),
              if (_error != null) ...<Widget>[
                const SizedBox(height: 12),
                Padding(
                  padding: const EdgeInsets.symmetric(horizontal: 24),
                  child: Text(
                    _error!,
                    style: const TextStyle(color: Colors.red),
                    textAlign: TextAlign.center,
                  ),
                ),
              ],
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
160
points
371
downloads

Documentation

API reference

Publisher

verified publisherchatasist.com

Weekly Downloads

Flutter plugin for embedding the Chatasist customer support chat widget with realtime messaging, media uploads, and voice/video call support.

Homepage

License

MIT (license)

Dependencies

collection, file_picker, flutter, flutter_html, flutter_secure_storage, flutter_webrtc, http, http_parser, image_picker, mime, pusher_channels_flutter, url_launcher

More

Packages that depend on chatasist_flutter