bubble_head 0.0.4 copy "bubble_head: ^0.0.4" to clipboard
bubble_head: ^0.0.4 copied to clipboard

PlatformAndroid

A flutter plugin to enable you launch a bubble while putting your application to background and upon clicking the bubble brings your application back to foreground

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:bubble_head/bubble.dart';

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

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

class _MyAppState extends State<MyApp> {
  Bubble _bubble = new Bubble(showCloseButton: true);

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> startBubbleHead() async {
    // Platform messages may fail, so we use a try/catch PlatformException.
    // We also handle the message potentially returning null.
    try {
      await _bubble.startBubbleHead(sendAppToBackground: false);
    } on PlatformException {
      print('Failed to call startBubbleHead');
    }
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> stopBubbleHead() async {
    // Platform messages may fail, so we use a try/catch PlatformException.
    // We also handle the message potentially returning null.
    try {
      await _bubble.stopBubbleHead();
    } on PlatformException {
      print('Failed to call stopBubbleHead');
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Bubble Head App'),
        ),
        body: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Container(
                height: 50,
                width: double.infinity,
                margin: EdgeInsets.all(8),
                child: TextButton(
                  style: ButtonStyle(
                    backgroundColor: MaterialStateProperty.all(Colors.teal),
                  ),
                  onPressed: () async {
                    await startBubbleHead();
                  },
                  child: Text(
                    "Start Bubble",
                    style: TextStyle(color: Colors.white),
                  ),
                ),
              ),
              Container(
                height: 50,
                width: double.infinity,
                margin: EdgeInsets.all(8),
                child: TextButton(
                  style: ButtonStyle(
                    backgroundColor:
                        MaterialStateProperty.all(Colors.redAccent),
                  ),
                  onPressed: () async {
                    await stopBubbleHead();
                  },
                  child: Text(
                    "Stop Bubble",
                    style: TextStyle(color: Colors.white),
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
17
likes
150
points
248
downloads

Publisher

unverified uploader

Weekly Downloads

A flutter plugin to enable you launch a bubble while putting your application to background and upon clicking the bubble brings your application back to foreground

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on bubble_head