bubble_head

Creator: coderz1093

Last updated:

Add to Cart

Description:

bubble head

bubble_head #
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
Getting Started #
Add dependency #
dependencies:
bubble_head: ^0.0.4
copied to clipboard
Add in android-manifest file (../main/AndroidManifest.xml) #
If you are unsure on where to do this, you can reference the example project AndroidManifest.xml file here
Add SYSTEM_ALERT_WINDOW permission in manifest
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
copied to clipboard
NOTE: For best UX practices, you should request for SYSTEM_ALERT_WINDOW permission on your application launch (if permission status is not granted)
To request for permission, we advise the use of this package
Add intent-filter in activity tag
<intent-filter>
<action android:name="intent.bring.app.to.foreground" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
copied to clipboard
Add service in application tag
<service
android:name="com.dsaved.bubblehead.bubble.BubbleHeadService"
android:enabled="true"
android:exported="false"/>
copied to clipboard
Note: To set bubble icon, create assets/images folder path and add your png icon with name icon.png to the directory (ensure to import assets in your pubspec.yaml file) #
GIF illustration

Examples #
To start bubble
[This puts your app in background and can be re-launched (brought to foreground) on tap of the bubble]
Bubble _bubble = new Bubble();

Future<void> startBubbleHead() async {

try {
await _bubble.startBubbleHead();
} on PlatformException {
print('Failed to call startBubbleHead');
}
}
copied to clipboard
To stop/close bubble
Bubble _bubble = new Bubble();

Future<void> stopBubbleHead() async {

try {
await _bubble.stopBubbleHead();
} on PlatformException {
print('Failed to call stopBubbleHead');
}
}
copied to clipboard
You can prevent the default action of putting your application in background when starting bubble_head by setting sendAppToBackground parameter when starting bubble head (if you choose to use another means of sending your application to background)
Bubble _bubble = new Bubble();

Future<void> startBubbleHead() async {

try {
// this will only display the bubble-head without sending the application to background
await _bubble.startBubbleHead(sendAppToBackground: false);
} on PlatformException {
print('Failed to call startBubbleHead');
}
}
copied to clipboard
Other parameters
(You can choose to tweak optional parameters when initializing bubble)
Bubble({
this.shouldBounce = true,
this.allowDragToClose = true,
this.showCloseButton = false,
});
copied to clipboard
Bubble().startBubbleHead(sendAppToBackground: true);
copied to clipboard
Parameter Definition

shouldBounce - Defaults to True
(Adds animation to bubble-head)
allowDragToClose - Defaults to True
(Enables dragging bubble to bottom screen to exit)
showCloseButton - Defaults to False
(Adds a close button icon to the bubble-head)
sendAppToBackground - Defaults to True
(Sends application to background)

Buy me a Coffee #

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.