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

PlatformAndroid
outdated

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();
    } 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),
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
16
likes
130
pub points
76%
popularity

Publisher

unverified uploader

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)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on bubble_head