bubble_overlay 0.1.1+1

  • Readme
  • Changelog
  • Example
  • Installing
  • 75

Android only feature #

Getting Started #

What you need to include in your project to start working:

  • Open your AndroidManifest.xml and add inside application tag:

      <service
          android:name="com.adriankohls.bubble_overlay.BubbleOverlayService"
          android:enabled="true"
          android:exported="false" />
    

And add this permissions at manifest top level:

    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />

Create a local variable in your dart file:

    final BubbleOverlay bubbleOverlay = BubbleOverlay();
    bubbleOverlay.openBubble();

The first time you call openBubble(), it will request Android overlay permission

After granting permission, call it again, and it will open the bubble

More details you can find in example/lib/main.dart

How it works #

BubbleOverlayPlugin.kt: Make the 'talk' with Dart/Flutter with native Android OS, connect the OS with the Service, etc.

BubbleOverlayService.kt Updates Bubble data, all bubble data is parsed from XML file (layout_bubble.xml), as developing a native app for Android with XML

Google Play Demo #

Link: https://play.google.com/store/apps/details?id=com.adriankohls.bubble_overlay_example

Changelog #

0.1.1+1 #

  • Fixed 'No implementation found for method isBubbleOpen on channel com.adriankohls/bubble_overlay'

0.1.1 #

Fixed nullability crash on some devices due to memory/OS apps GC management Added missing resource releasers to avoid memory leak

0.1.0+1 #

Flutter format

0.1.0 #

Fixed isOpen behaviour by checking if Android Service class is running periodically (1 second) Added callback, and close with proper dispose to avoid memory leak

0.0.4+1 #

Fixed Readme

0.0.4 #

Added iOS project folder to make plugin runnable in Flutter project for Android and iOS. Remember, this plugin only works for Android platform

0.0.3 #

  • Fixed close button layout
  • Fixed bubble layouts
  • Renamed title to topText
  • Fixed bubble text sizes
  • Added Timer callback, for custom inside bubble functions
  • Fixed some access to object

0.0.2 #

  • Removed close bubble on tapping on bubble, close bubble overlay only tapping on X
  • Added top and bottom text to bubble
  • Fixed title, middle and bottom text size

0.0.1+0 #

  • Initial release

0.0.1+1 #

  • Initial release

0.0.1+2 #

  • Initial release

0.0.1+3 #

  • Initial release

0.0.1+4 #

  • Initial release

0.0.1+5 #

  • Initial release

0.0.1+6 #

  • Initial release

example/lib/main.dart

import 'dart:async';
import 'dart:developer';

import 'package:bubble_overlay/bubble_overlay.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;

Future<void> main() async {
  runApp(MaterialApp(home: Home()));
}

class Home extends StatefulWidget {
  _Home createState() => _Home();
}

class _Home extends State<Home> {
  final BubbleOverlay bubbleOverlay = BubbleOverlay();
  bool alternateColor = false;

  void setMiddleTextCounter() {
    int time = 0;
    if (bubbleOverlay.isOpen)
      bubbleOverlay
          .setCallback(Timer.periodic(Duration(milliseconds: 500), (timer) {
        time++;
        if (bubbleOverlay.isOpen) bubbleOverlay.updateMiddleText('$time');
        log('callback');
      }));
  }

  void setBottomTextHelloWorld() {
    if (bubbleOverlay.isOpen) {
      bubbleOverlay.removeCallback();
      bubbleOverlay.updateBottomText('Hello World');
    }
  }

  void closeBubble() {
    if (bubbleOverlay.isOpen) {
      bubbleOverlay.closeBubble();
    }
  }

  void updateTextAndBgColor() {
    if (bubbleOverlay.isOpen) {
      bubbleOverlay.removeCallback();
      String textColor = alternateColor ? '#000000' : '#ffffff';
      String bgColor = alternateColor ? '#ffffff' : '#000000';
      bubbleOverlay.updateMiddleTextColor(textColor);
      bubbleOverlay.updateTopTextColor(textColor);
      bubbleOverlay.updateBottomTextColor(textColor);
      bubbleOverlay.updateBackgroundColor(bgColor);
      alternateColor = !alternateColor;
    }
  }

  void setTopText() {
    if (bubbleOverlay.isOpen) {
      bubbleOverlay.removeCallback();
      bubbleOverlay.updateTopText('Set Bubble Title');
    }
  }

  void setTopIcon() async {
    String url =
        'https://meterpreter.org/wp-content/uploads/2018/09/flutter.png';
    http.get(url).then((response) {
      if (response != null)
        bubbleOverlay.updateTopIconWithBytes(response.bodyBytes);
    });
  }

  void setBottomIcon() async {
    String url =
        'https://github.githubassets.com/images/modules/open_graph/github-mark.png';
    http.get(url).then((response) {
      if (response != null)
        bubbleOverlay.updateBottomIconWithBytes(response.bodyBytes);
    });
  }

  @override
  Widget build(BuildContext context) => Scaffold(
        appBar: AppBar(title: Text('Bubble Overlay')),
        body: SingleChildScrollView(
          padding: EdgeInsets.all(50),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: [
              RaisedButton(
                  child: Text('Open Bubble Overlay'),
                  onPressed: () => bubbleOverlay.openBubble()),
              RaisedButton(
                onPressed: closeBubble,
                child: Text('Close Bubble'),
              ),
              RaisedButton(
                onPressed: setTopText,
                child: Text('Set Bubble Top Text'),
              ),
              RaisedButton(
                onPressed: setMiddleTextCounter,
                child: Text('Set Middle Text Counter'),
              ),
              RaisedButton(
                onPressed: setBottomTextHelloWorld,
                child: Text('Set Bottom Text "Hello World"'),
              ),
              RaisedButton(
                onPressed: updateTextAndBgColor,
                child: Text('Update text and background color'),
              ),
              RaisedButton(
                child: Text('Set Top Icon'),
                onPressed: setTopIcon,
              ),
              RaisedButton(
                child: Text('Set Bottom Icon'),
                onPressed: setBottomIcon,
              ),
            ],
          ),
        ),
      );
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  bubble_overlay: ^0.1.1+1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:bubble_overlay/bubble_overlay.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
50
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
75
Learn more about scoring.

We analyzed this package on Jul 2, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:bubble_overlay/bubble_overlay.dart] that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because of import path [package:bubble_overlay/bubble_overlay.dart] that declares support for platforms: android, ios

Package does not support Flutter platform web

Because of import path [package:bubble_overlay/bubble_overlay.dart] that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because of import path [package:bubble_overlay/bubble_overlay.dart] that declares support for platforms: android, ios

Package not compatible with SDK dart

because of import path [bubble_overlay] that is in a package requiring null.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test