SystemAlertWindow
SystemAlertWindow copied to clipboard
Overlay Buttons
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.
Thanks in advance
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.
- 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.
- 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");
}
}); }
its already resolved thanks @aryaveer0710