Skip to Content
Developer docsBeta
Website & app chat

Flutter

The bubble in a Flutter app on iOS and Android, with native Flutter widgets.

mawgood_chat draws the chat with Flutter widgets (no WebView), in a Material 3 or a Cupertino style. It supports iOS 13 or later and Android minSdk 24; web and desktop aren't targeted.

Allow your app

In your Mawgood › Overview and channels › Website & app chat, add your app to the site key's Allowed sites and apps: the iOS bundle ID and the Android package name (like com.example.app). A call from an app that isn't listed is refused with origin_not_allowed, and the SDK prints which ID to add.

Install

pubspec.yaml
dependencies:
  mawgood_chat: ^0.1.0

flutter:
  uses-material-design: true # the bubble's icons

Until mawgood_chat is published on pub.dev, use a path or git dependency.

Android (AndroidManifest.xml): INTERNET, and RECORD_AUDIO for voice notes. Keep the SDK's secure storage out of Auto Backup (android:allowBackup="false", or backup rules that exclude FlutterSecureStorage).

iOS (Info.plist): NSMicrophoneUsageDescription (voice notes), NSPhotoLibraryUsageDescription and NSCameraUsageDescription (photos).

Start it

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

void main() {
  MawgoodChat.init(siteKey: 'mwg_pk_live_…', mawgoodId: 'mw_ag_…');
  runApp(const MyApp());
}

// On any screen: the floating launcher, placed per the look.
MawgoodLauncher(child: Scaffold(/* … */));

// Or from your own button (hide the launcher in the look):
MawgoodChat.open(context);

// Or embedded in a tab or a page:
const MawgoodChatView();

MawgoodChat.open follows the look's window mode: full screen, a bottom sheet, or a floating panel (sideSheet is web only and opens floating). For staging, pass environment: MawgoodEnvironment.staging.

Tell the Mawgood where the customer is:

MawgoodChat.setScreen('product');
MawgoodChat.setAttributes({'cart': 450}); // up to 20

MawgoodChat.init

ArgumentWhat it does
siteKey, mawgoodIdRequired.
environmentMawgoodEnvironment.production (default), .staging, or your own hosts.
localear or en; default the app's locale.
lookYour in-code look (ChatLookOverride, Customization).
identityA signed customer (ChatIdentity).
optionsMawgoodChatOptions: style, launcherBuilder, headerBuilder, messageBuilders, emptyStateBuilder, onLink.
onOpen, onClose, onMessage, onUnreadChange, onHandoff, onErrorEvents.

MawgoodChatView marks replies read only while it is on screen (its route on top, the app in the foreground). Embedded in a tab, pass visible: yourself.

Push notifications

Push for a closed app comes later: MawgoodChat.registerPushToken() does nothing yet. Meanwhile, use onUnreadChange with your own push system.

On this page