Skip to content

Commit

Permalink
feat: open rtsp from app
Browse files Browse the repository at this point in the history
  • Loading branch information
bdlukaa committed Nov 6, 2023
1 parent b09d8a1 commit 7319fa3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Future<void> main(List<String> args) async {
WidgetsFlutterBinding.ensureInitialized();

app_links.register('rtsp');
app_links.init();
app_links.listen();

// https://github.com/flutter/flutter/issues/41980#issuecomment-1231760866
Expand Down
15 changes: 15 additions & 0 deletions lib/utils/app_links.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -31,6 +32,20 @@ Future<void> register(String scheme) async {
}
}

Future<void> 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;
Expand Down

0 comments on commit 7319fa3

Please sign in to comment.