From 7319fa3210b397af4a39e2a70bbcf8273a99c695 Mon Sep 17 00:00:00 2001 From: Bruno D'Luka Date: Mon, 6 Nov 2023 09:05:01 -0300 Subject: [PATCH] feat: open rtsp from app --- lib/main.dart | 1 + lib/utils/app_links.dart | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/main.dart b/lib/main.dart index 9f1a0d8f..b19bcd35 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -63,6 +63,7 @@ Future main(List args) async { WidgetsFlutterBinding.ensureInitialized(); app_links.register('rtsp'); + app_links.init(); app_links.listen(); // https://github.com/flutter/flutter/issues/41980#issuecomment-1231760866 diff --git a/lib/utils/app_links.dart b/lib/utils/app_links.dart index eec5c3c2..5062ddfd 100644 --- a/lib/utils/app_links.dart +++ b/lib/utils/app_links.dart @@ -4,6 +4,7 @@ import 'package:app_links/app_links.dart'; import 'package:bluecherry_client/main.dart'; import 'package:bluecherry_client/widgets/device_grid/device_grid.dart'; import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; import 'package:win32_registry/win32_registry.dart'; final instance = AppLinks(); @@ -31,6 +32,20 @@ Future register(String scheme) async { } } +Future init() async { + final initialUri = await instance.getInitialAppLink(); + debugPrint('Initial URI: $initialUri'); + if (initialUri != null) { + final url = initialUri.toString(); + WidgetsBinding.instance.addPostFrameCallback((_) { + final context = navigatorKey.currentContext; + if (context != null && context.mounted) { + AddExternalStreamDialog.addStream(context, url); + } + }); + } +} + void listen() { instance.allUriLinkStream.listen((uri) { final navigator = navigatorKey.currentState;