checkWiring method

Map<String, dynamic> checkWiring()

Whether the Dart half of the install actually reached the app.

Every other section here checks a platform file, and all of them can pass on a project where this package is a dependency and nothing more: the entitlement, the intent filter and both association files are correct, the domain resolves, and no link ever opens the app because no provider was registered. That is the state a half-applied install leaves behind, and it is also what a human gets by adding the dependency by hand, so a green report that cannot see it is the most misleading answer this command can give.

Three things, each of which alone makes the feature inert: the provider in lib/config/app.dart, the config factory in lib/main.dart, and at least one registerHandler call somewhere under lib/. The last is a WARNING rather than a failure: a consumer may register handlers from a provider this scan cannot recognise, and failing a correct project is worse than under-reporting on an unusual one.

Implementation

Map<String, dynamic> checkWiring() {
  final issues = <String>[];
  final warnings = <String>[];

  final appConfig = '$projectRoot/lib/config/app.dart';
  if (!FileHelper.fileExists(appConfig)) {
    issues.add('lib/config/app.dart not found, so the provider list could '
        'not be read');
  } else if (!_mentions(appConfig, 'DeeplinkServiceProvider')) {
    issues.add('DeeplinkServiceProvider is not registered in '
        'lib/config/app.dart. Without it no driver is created and no link '
        'ever reaches a handler.');
  }

  final main = '$projectRoot/lib/main.dart';
  if (!FileHelper.fileExists(main)) {
    issues.add('lib/main.dart not found, so the config factory could not be '
        'read');
  } else if (!_mentions(main, 'deeplinkConfig')) {
    issues.add('deeplinkConfig is not passed to Magic.init in lib/main.dart. '
        'Every value this report just validated is then invisible at '
        'runtime.');
  }

  if (!_libMentions('registerHandler(')) {
    warnings.add('No registerHandler( call found under lib/. A link that '
        'reaches the manager with no handler registered is dropped without '
        'an error. Ignore this if handlers are registered somewhere this '
        'scan cannot see.');
  }

  return {
    'configured': issues.isEmpty,
    'exists': true,
    'issues': issues,
    'warnings': warnings,
  };
}