LCOV - code coverage report
Current view: top level - lib/_classes/controller/deep_link - deep_link_handler.dart Coverage Total Hit
Test: lcov.info Lines: 0.0 % 27 0
Test Date: 2026-12-05 10:54:13 Functions: - 0 0

            Line data    Source code
       1              : // Copyright 2026 The terCAD team. All rights reserved.
       2              : // Use of this source code is governed by a CC BY-NC-ND 4.0 license that can be found in the LICENSE file.
       3              : 
       4              : import 'dart:async';
       5              : 
       6              : import 'package:app_finance/_classes/controller/deep_link/url_scheme.dart';
       7              : import 'package:app_links/app_links.dart';
       8              : import 'package:flutter/foundation.dart';
       9              : 
      10              : // Links opening the application
      11              : // > fingrom://integration/enablebanking?... sent back by the bank's authorization
      12              : // > fingrom://integration/teller?token=... sent back by the Teller Connect page
      13              : // > fingrom://integration/monzo?code=...&state=... sent back by the Monzo sign-in
      14              : class DeepLinkHandler {
      15              :   static const scheme = 'fingrom';
      16              :   static const enableBankingPath = '/enablebanking';
      17              :   static const tellerPath = '/teller';
      18              :   static const monzoPath = '/monzo';
      19              : 
      20            0 :   static final enableBankingCallback = ValueNotifier<Uri?>(null);
      21            0 :   static final tellerCallback = ValueNotifier<Uri?>(null);
      22            0 :   static final monzoCallback = ValueNotifier<Uri?>(null);
      23              :   static StreamSubscription<Uri>? _subscription;
      24              : 
      25            0 :   static Future<void> init({Stream<Uri>? links}) async {
      26            0 :     unawaited(registerUrlScheme(scheme).catchError((_) {}));
      27            0 :     await _subscription?.cancel();
      28              :     try {
      29            0 :       _subscription = (links ?? AppLinks().uriLinkStream).listen(handle, onError: (_) {});
      30              :     } catch (_) {
      31              :       // Platform without link support
      32              :     }
      33              :   }
      34              : 
      35            0 :   static bool isEnableBankingCallback(Uri uri) =>
      36            0 :       uri.scheme == scheme && uri.host == 'integration' && uri.path == enableBankingPath;
      37              : 
      38            0 :   static bool isTellerCallback(Uri uri) => uri.scheme == scheme && uri.host == 'integration' && uri.path == tellerPath;
      39              : 
      40            0 :   static bool isMonzoCallback(Uri uri) => uri.scheme == scheme && uri.host == 'integration' && uri.path == monzoPath;
      41              : 
      42            0 :   static bool handle(Uri uri) {
      43            0 :     if (isEnableBankingCallback(uri)) {
      44            0 :       enableBankingCallback.value = uri;
      45              :       return true;
      46              :     }
      47            0 :     if (isTellerCallback(uri)) {
      48            0 :       tellerCallback.value = uri;
      49              :       return true;
      50              :     }
      51            0 :     if (isMonzoCallback(uri)) {
      52            0 :       monzoCallback.value = uri;
      53              :       return true;
      54              :     }
      55              :     return false;
      56              :   }
      57              : 
      58            0 :   static Uri? takeEnableBankingCallback() {
      59            0 :     final value = enableBankingCallback.value;
      60            0 :     enableBankingCallback.value = null;
      61              :     return value;
      62              :   }
      63              : 
      64            0 :   static Uri? takeTellerCallback() {
      65            0 :     final value = tellerCallback.value;
      66            0 :     tellerCallback.value = null;
      67              :     return value;
      68              :   }
      69              : 
      70            0 :   static Uri? takeMonzoCallback() {
      71            0 :     final value = monzoCallback.value;
      72            0 :     monzoCallback.value = null;
      73              :     return value;
      74              :   }
      75              : }
        

Generated by: LCOV version 2.0-1