SystemAlertWindow icon indicating copy to clipboard operation
SystemAlertWindow copied to clipboard

Overlay Buttons

Open iQ-ashish opened this issue 1 year ago • 1 comments

hay there i just want to add buttons on my overlay i have created a custom ui for it i want when i tap on any button then it ll open apps particular section right now its not opening anything how to do that.

iQ-ashish avatar Oct 11 '24 20:10 iQ-ashish

Thanks in advance

iQ-ashish avatar Oct 11 '24 20:10 iQ-ashish

Hi,

Yes, you can add buttons on your overlay and launch the app’s specific section when a button is tapped. you need to use combination of package android intent plus , go router and unilinks Open android/app/src/main/AndroidManifest.xml, and inside your <activity android:name=".MainActivity" ...> add:

Now any URI like myapp://open/orders or myapp://open/profile will launch your Flutter app.

  1. Launch deep link from your overlay (Flutter overlay code)

When a button is tapped on your overlay, use android_intent_plus :

import 'package:android_intent_plus/android_intent.dart';

void openOrdersSection() async { final intent = AndroidIntent( action: 'action_view', data: Uri.parse("myapp://open/orders").toString(), ); await intent.launch(); }

void openProfileSection() async { final intent = AndroidIntent( action: 'action_view', data: Uri.parse("myapp://open/profile").toString(), ); await intent.launch(); }

So each overlay button just launches the right intent.

  1. Handle deep links inside Flutter app If you’re using GoRouter

GoRouter automatically parses deep links like myapp://open/orders → /orders.

final router = GoRouter( routes: [ GoRoute(path: '/orders', builder: (, __) => OrdersPage()), GoRoute(path: '/profile', builder: (, __) => ProfilePage()), ], );

void main() { runApp(MaterialApp.router(routerConfig: router)); }

If you prefer manual control (with uni_links) import 'package:uni_links/uni_links.dart';

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

linkStream.listen((String? link) { if (link == null) return; final uri = Uri.parse(link);

if (uri.pathSegments.contains("orders")) {
  context.go("/orders");
} else if (uri.pathSegments.contains("profile")) {
  context.go("/profile");
}

}); }

aryaveer0710 avatar Sep 08 '25 07:09 aryaveer0710

its already resolved thanks @aryaveer0710

iQ-ashish avatar Sep 08 '25 07:09 iQ-ashish