floaty_chatheads 1.3.0 copy "floaty_chatheads: ^1.3.0" to clipboard
floaty_chatheads: ^1.3.0 copied to clipboard

Floating chathead plugin for Android & iOS with draggable bubbles, expandable content panels, theming, snap-to-edge physics, and bidirectional app-overlay messaging.

example/example.md

Floaty Chatheads Example #

Basic chathead with bidirectional messaging #

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

void main() => runApp(const MaterialApp(home: BasicExample()));

/// Overlay entry point — must be top-level for AOT discoverability.
@pragma('vm:entry-point')
void overlayMain() => FloatyOverlayApp.run(const OverlayContent());

class BasicExample extends StatefulWidget {
  const BasicExample({super.key});
  @override
  State<BasicExample> createState() => _BasicExampleState();
}

class _BasicExampleState extends State<BasicExample> {
  int _received = 0;

  @override
  void initState() {
    super.initState();
    FloatyChatheads.onData.listen((data) {
      if (mounted) setState(() => _received++);
    });
  }

  Future<void> _show() async {
    final hasPermission = await FloatyChatheads.requestPermission();
    if (!hasPermission) return;

    await FloatyChatheads.showChatHead(
      ChatHeadConfig(
        entryPoint: 'overlayMain',
        contentWidth: 300,
        contentHeight: 400,
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Basic Chathead')),
      body: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            ElevatedButton(onPressed: _show, child: const Text('Show')),
            Text('Received from overlay: $_received'),
            ElevatedButton(
              onPressed: () => FloatyChatheads.shareData('Hello overlay!'),
              child: const Text('Send to overlay'),
            ),
          ],
        ),
      ),
    );
  }
}

class OverlayContent extends StatelessWidget {
  const OverlayContent({super.key});

  @override
  Widget build(BuildContext context) {
    return Material(
      child: Center(
        child: ElevatedButton(
          onPressed: () => FloatyOverlay.shareData('Hello main app!'),
          child: const Text('Send to app'),
        ),
      ),
    );
  }
}

See the full gallery app for 14 runnable examples covering messenger chat, mini player, map sync, notification counters, multi-chathead, survival after app death, and more.

9
likes
0
points
404
downloads

Publisher

unverified uploader

Weekly Downloads

Floating chathead plugin for Android & iOS with draggable bubbles, expandable content panels, theming, snap-to-edge physics, and bidirectional app-overlay messaging.

Repository (GitHub)
View/report issues

Topics

#overlay #chathead #floating-window #widget #pip

License

unknown (license)

Dependencies

floaty_chatheads_android, floaty_chatheads_ios, floaty_chatheads_platform_interface, flutter, meta

More

Packages that depend on floaty_chatheads

Packages that implement floaty_chatheads