From cf1e5745d81bd003194aafa2f05070b7ddab0022 Mon Sep 17 00:00:00 2001 From: hangyu Date: Tue, 20 Aug 2024 17:37:50 -0700 Subject: [PATCH 1/9] Add tests --- .../src/screens/deep_link_validation/deep_links_controller.dart | 1 + .../devtools_app/test/test_infra/utils/deep_links_utils.dart | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_controller.dart b/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_controller.dart index ee12603a122..7911b6a3fa9 100644 --- a/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_controller.dart +++ b/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_controller.dart @@ -9,6 +9,7 @@ import 'package:devtools_app_shared/utils.dart'; import 'package:devtools_shared/devtools_deeplink.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:http/http.dart'; import '../../shared/analytics/analytics.dart' as ga; import '../../shared/analytics/constants.dart' as gac; diff --git a/packages/devtools_app/test/test_infra/utils/deep_links_utils.dart b/packages/devtools_app/test/test_infra/utils/deep_links_utils.dart index 5ddc45eac17..b473b71d131 100644 --- a/packages/devtools_app/test/test_infra/utils/deep_links_utils.dart +++ b/packages/devtools_app/test/test_infra/utils/deep_links_utils.dart @@ -5,6 +5,7 @@ import 'package:devtools_app/devtools_app.dart'; import 'package:devtools_app/src/screens/deep_link_validation/deep_links_model.dart'; import 'package:devtools_app/src/screens/deep_link_validation/deep_links_services.dart'; +import 'package:devtools_shared/devtools_deeplink.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:http/http.dart'; import 'package:http/testing.dart'; From 3e26cc0905121e4761a7687bea19e3f1f6bfb3f9 Mon Sep 17 00:00:00 2001 From: hangyu Date: Thu, 22 Aug 2024 17:02:54 -0700 Subject: [PATCH 2/9] add key --- .../src/screens/deep_link_validation/deep_links_services.dart | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_services.dart b/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_services.dart index 8401423b971..7998923a797 100644 --- a/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_services.dart +++ b/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_services.dart @@ -59,6 +59,8 @@ const _teamIdKey = 'team_id'; const _universalLinkDomainsKey = 'universal_link_domains'; const _iosDomainNameKey = 'domain_name'; const _iosValidationResultsKey = 'validationResults'; +const _aasaAppPathsKey = 'aasaAppPaths'; +const _aasaPathsKey = 'aasaPaths'; const iosCheckNameToDomainError = { 'EXISTENCE': IosDomainError.existence, @@ -130,6 +132,8 @@ class DeepLinksService { final domainName = domainResult[_domainNameKey] as String; final failedChecks = (domainResult[_failedChecksKey] as List?) ?.cast>(); + final aasaPaths = (domainResult[_aasaAppPathsKey] as List?) + ?.cast>(); if (failedChecks != null) { for (final failedCheck in failedChecks) { final checkName = failedCheck[_checkNameKey] as String; From 14396f2251b871e7431267b6386b21c44d248c76 Mon Sep 17 00:00:00 2001 From: hangyu Date: Tue, 27 Aug 2024 15:13:25 -0700 Subject: [PATCH 3/9] 1 --- .../deep_links_controller.dart | 6 +++++ .../deep_links_services.dart | 26 ++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_controller.dart b/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_controller.dart index 7911b6a3fa9..466469d8c53 100644 --- a/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_controller.dart +++ b/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_controller.dart @@ -512,6 +512,9 @@ class DeepLinksController extends DisposableController late final Map> androidDomainErrors; Map> iosDomainErrors = >{}; + + Map> iosDomainPaths = + >{}; try { final androidResult = await deepLinksService.validateAndroidDomain( domains: domains, @@ -528,6 +531,7 @@ class DeepLinksController extends DisposableController domains: domains, ); iosDomainErrors = iosResult.domainErrors; + iosDomainPaths= iosResult.paths; } } catch (_) { // TODO(hangyujin): Add more error handling for cases like RPC error and invalid json. @@ -542,6 +546,8 @@ class DeepLinksController extends DisposableController if (linkdata.os.contains(PlatformOS.ios)) ...(iosDomainErrors[linkdata.domain] ?? []), ]; + final iosPaths= iosDomainPaths[linkdata.domain] ?? []; + if (errors.isNotEmpty) { return LinkData( domain: linkdata.domain, diff --git a/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_services.dart b/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_services.dart index 7998923a797..42e5346ed93 100644 --- a/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_services.dart +++ b/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_services.dart @@ -61,6 +61,7 @@ const _iosDomainNameKey = 'domain_name'; const _iosValidationResultsKey = 'validationResults'; const _aasaAppPathsKey = 'aasaAppPaths'; const _aasaPathsKey = 'aasaPaths'; +const _pathKey = 'path'; const iosCheckNameToDomainError = { 'EXISTENCE': IosDomainError.existence, @@ -71,9 +72,10 @@ const iosCheckNameToDomainError = { }; class ValidateIosDomainResult { - ValidateIosDomainResult(this.errorCode, this.domainErrors); + ValidateIosDomainResult(this.errorCode, this.domainErrors, this.paths); final String errorCode; final Map> domainErrors; + final Map> paths; } class GenerateAssetLinksResult { @@ -132,8 +134,6 @@ class DeepLinksService { final domainName = domainResult[_domainNameKey] as String; final failedChecks = (domainResult[_failedChecksKey] as List?) ?.cast>(); - final aasaPaths = (domainResult[_aasaAppPathsKey] as List?) - ?.cast>(); if (failedChecks != null) { for (final failedCheck in failedChecks) { final checkName = failedCheck[_checkNameKey] as String; @@ -160,6 +160,10 @@ class DeepLinksService { final domainErrors = >{ for (final domain in domains) domain: [], }; + + final paths = >{ + for (final domain in domains) domain: [], + }; // TODO(hangyujin): Add error code to the result. const errorCode = ''; @@ -196,6 +200,21 @@ class DeepLinksService { } } } + final aasaAppPaths = (domainResult[_aasaAppPathsKey] as List?) + ?.cast>(); + if (aasaAppPaths != null) { + for (final aasaAppPath in aasaAppPaths) { + final aasaPaths= (aasaAppPath[_aasaPathsKey] as List?)?.cast>(); + if (aasaPaths != null) { + for(final aasaPath in aasaPaths) + { + paths[domainName]!.add( aasaPath[_pathKey] as String); + } + continue; + } + } + + } } // TODO(hangyujin): Add path from AASA file check result. } @@ -203,6 +222,7 @@ class DeepLinksService { return ValidateIosDomainResult( errorCode, domainErrors, + paths, ); } From 861bb0a60cc69ffee0a653a4bc5bf79f0f4bfe4f Mon Sep 17 00:00:00 2001 From: hangyu Date: Fri, 30 Aug 2024 12:36:33 -0700 Subject: [PATCH 4/9] add aasa path --- .../deep_links_controller.dart | 77 ++++++++++++------- .../deep_links_model.dart | 23 +++++- .../deep_links_services.dart | 2 +- .../lib/src/shared/feature_flags.dart | 2 +- .../deep_links_screen_test.dart | 9 ++- .../test_data/deep_link/fake_responses.dart | 68 +++++++++++++++- 6 files changed, 148 insertions(+), 33 deletions(-) diff --git a/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_controller.dart b/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_controller.dart index 466469d8c53..fd93e289051 100644 --- a/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_controller.dart +++ b/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_controller.dart @@ -499,9 +499,9 @@ class DeepLinksController extends DisposableController } Future> _validateDomain( - List linkdatas, + List rawLinkdatas, ) async { - final domains = linkdatas + final domains = rawLinkdatas .where( (linkdata) => linkdata.domain != null, ) @@ -513,8 +513,7 @@ class DeepLinksController extends DisposableController Map> iosDomainErrors = >{}; - Map> iosDomainPaths = - >{}; + Map> iosDomainPaths = >{}; try { final androidResult = await deepLinksService.validateAndroidDomain( domains: domains, @@ -531,43 +530,67 @@ class DeepLinksController extends DisposableController domains: domains, ); iosDomainErrors = iosResult.domainErrors; - iosDomainPaths= iosResult.paths; + iosDomainPaths = iosResult.paths; } } catch (_) { // TODO(hangyujin): Add more error handling for cases like RPC error and invalid json. pagePhase.value = PagePhase.validationErrorPage; - return linkdatas; + return rawLinkdatas; } - return linkdatas.map((linkdata) { + final validatedLinkDatas = []; + + for (final linkdata in rawLinkdatas) { final errors = [ if (linkdata.os.contains(PlatformOS.android)) ...(androidDomainErrors[linkdata.domain] ?? []), if (linkdata.os.contains(PlatformOS.ios)) ...(iosDomainErrors[linkdata.domain] ?? []), ]; - final iosPaths= iosDomainPaths[linkdata.domain] ?? []; - - if (errors.isNotEmpty) { - return LinkData( - domain: linkdata.domain, - domainErrors: errors, - path: linkdata.path, - pathErrors: linkdata.pathErrors, - os: linkdata.os, - scheme: linkdata.scheme, - associatedDomains: linkdata.associatedDomains, - associatedPath: linkdata.associatedPath, - hasAndroidAssetLinksFile: !(androidDomainErrors[linkdata.domain] - ?.contains(AndroidDomainError.existence) ?? - false), - hasIosAasaFile: !(iosDomainErrors[linkdata.domain] - ?.contains(IosDomainError.existence) ?? - false), + final hasAndroidAssetLinksFile = !(androidDomainErrors[linkdata.domain] + ?.contains(AndroidDomainError.existence) ?? + false); + final hasIosAasaFile = !(iosDomainErrors[linkdata.domain] + ?.contains(IosDomainError.existence) ?? + false); + + if (linkdata.os.contains(PlatformOS.ios)) { + final List iosPaths = iosDomainPaths[linkdata.domain] ?? []; + + for (final iosPath in iosPaths) { + validatedLinkDatas.add( + linkdata.copyWith( + path: iosPath, + domainErrors: errors, + hasAndroidAssetLinksFile: hasAndroidAssetLinksFile, + hasIosAasaFile: hasIosAasaFile, + ), + ); + } + + // If no path is provided, we will still show the domain just with domain errors. + if (iosPaths.isEmpty) { + validatedLinkDatas.add( + linkdata.copyWith( + domainErrors: errors, + hasAndroidAssetLinksFile: hasAndroidAssetLinksFile, + hasIosAasaFile: hasIosAasaFile, + ), + ); + } + } + + if (linkdata.os.contains(PlatformOS.android)) { + validatedLinkDatas.add( + linkdata.copyWith( + domainErrors: errors, + hasAndroidAssetLinksFile: hasAndroidAssetLinksFile, + hasIosAasaFile: hasIosAasaFile, + ), ); } - return linkdata; - }).toList(); + } + return validatedLinkDatas; } Future> _validatePath(List linkdatas) async { diff --git a/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_model.dart b/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_model.dart index 48d5d1f2986..7b4283c0359 100644 --- a/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_model.dart +++ b/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_model.dart @@ -278,10 +278,31 @@ class LinkData with SearchableDataMixin { } @override - String toString() => 'LinkData($domain $path)'; + String toString() => 'LinkData($domain $path $os)'; String get safePath => path ?? ''; String get safeDomain => domain ?? ''; + + LinkData copyWith({ + String? path, + List? domainErrors, + bool? hasAndroidAssetLinksFile, + bool? hasIosAasaFile, + }) { + return LinkData( + domain: domain, + path: path ?? this.path, + os: os, + scheme: scheme, + domainErrors: domainErrors ?? this.domainErrors, + pathErrors: pathErrors, + associatedPath: associatedPath, + associatedDomains: associatedDomains, + hasAndroidAssetLinksFile: + hasAndroidAssetLinksFile ?? this.hasAndroidAssetLinksFile, + hasIosAasaFile: hasIosAasaFile ?? this.hasIosAasaFile, + ); + } } class _ErrorAwareText extends StatelessWidget { diff --git a/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_services.dart b/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_services.dart index 42e5346ed93..2b2c73e4bc5 100644 --- a/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_services.dart +++ b/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_services.dart @@ -200,6 +200,7 @@ class DeepLinksService { } } } + paths[domainName] ??= []; final aasaAppPaths = (domainResult[_aasaAppPathsKey] as List?) ?.cast>(); if (aasaAppPaths != null) { @@ -216,7 +217,6 @@ class DeepLinksService { } } - // TODO(hangyujin): Add path from AASA file check result. } } return ValidateIosDomainResult( diff --git a/packages/devtools_app/lib/src/shared/feature_flags.dart b/packages/devtools_app/lib/src/shared/feature_flags.dart index 1f2785e5908..a5a764e4088 100644 --- a/packages/devtools_app/lib/src/shared/feature_flags.dart +++ b/packages/devtools_app/lib/src/shared/feature_flags.dart @@ -76,7 +76,7 @@ abstract class FeatureFlags { /// Flag to enable ios checks in deep link validation. /// /// https://github.com/flutter/devtools/issues/7799 - static bool deepLinkIosCheck = false; + static bool deepLinkIosCheck = true; /// Flag to enable DevTools extensions. /// diff --git a/packages/devtools_app/test/deep_link_vlidation/deep_links_screen_test.dart b/packages/devtools_app/test/deep_link_vlidation/deep_links_screen_test.dart index 1442fe50d52..511da4e96ec 100644 --- a/packages/devtools_app/test/deep_link_vlidation/deep_links_screen_test.dart +++ b/packages/devtools_app/test/deep_link_vlidation/deep_links_screen_test.dart @@ -559,7 +559,8 @@ void main() { hasPathError: true, ), androidDeepLinkJson('www.domain3.com', path: '/path3'), - ]; + ] + ..fakeIosDomains = [defaultDomain]; await pumpDeepLinkScreen( tester, @@ -572,6 +573,8 @@ void main() { expect(find.text('/path1'), findsOneWidget); expect(find.text('/path2'), findsOneWidget); expect(find.text('/path3'), findsOneWidget); + expect(find.text('/ios-path1'), findsOneWidget); + expect(find.text('/ios-path2'), findsOneWidget); // Only show links with path error. deepLinksController.updateDisplayOptions( @@ -583,6 +586,8 @@ void main() { expect(find.text('/path1'), findsNothing); expect(find.text('/path2'), findsOneWidget); expect(find.text('/path3'), findsNothing); + expect(find.text('/ios-path1'), findsNothing); + expect(find.text('/ios-path2'), findsNothing); // Only show links with no issue. deepLinksController.updateDisplayOptions( @@ -597,6 +602,8 @@ void main() { expect(find.text('/path1'), findsOneWidget); expect(find.text('/path2'), findsNothing); expect(find.text('/path3'), findsOneWidget); + expect(find.text('/ios-path1'), findsOneWidget); + expect(find.text('/ios-path2'), findsOneWidget); }, ); }); diff --git a/packages/devtools_app/test/test_infra/test_data/deep_link/fake_responses.dart b/packages/devtools_app/test/test_infra/test_data/deep_link/fake_responses.dart index 4f2ef0024ce..eeae0a01817 100644 --- a/packages/devtools_app/test/test_infra/test_data/deep_link/fake_responses.dart +++ b/packages/devtools_app/test/test_infra/test_data/deep_link/fake_responses.dart @@ -137,7 +137,39 @@ const iosValidationResponseWithNoError = ''' "severityLevel": "ERROR" } ], - "status": "VALIDATION_COMPLETE" + "status": "VALIDATION_COMPLETE", + "aasaAppPaths": [ + { + "aasaAppId": { + "bundleId": "bundle.id", + "teamId": "AAABBB" + }, + "aasaPaths": [ + { + "path": "/ios-path1", + "queryParams": [ + { + "key": "dplnk", + "value": "?*" + } + ], + "isCaseSensitive": true, + "isPercentEncoded": true + }, + { + "path": "/ios-path2", + "queryParams": [ + { + "key": "dplnk", + "value": "?*" + } + ], + "isCaseSensitive": true, + "isPercentEncoded": true + } + ] + } + ] } ] } @@ -177,7 +209,39 @@ const iosValidationResponseWithError = ''' "severityLevel": "ERROR" } ], - "status": "VALIDATION_COMPLETE" + "status": "VALIDATION_COMPLETE", + "aasaAppPaths": [ + { + "aasaAppId": { + "bundleId": "bundle.id", + "teamId": "AAABBB" + }, + "aasaPaths": [ + { + "path": "/ios-path1", + "queryParams": [ + { + "key": "dplnk", + "value": "?*" + } + ], + "isCaseSensitive": true, + "isPercentEncoded": true + }, + { + "path": "/ios-path2", + "queryParams": [ + { + "key": "dplnk", + "value": "?*" + } + ], + "isCaseSensitive": true, + "isPercentEncoded": true + } + ] + } + ] } ] } From 75f1d5a543c8c5ff35fad76916911bbc1eb24595 Mon Sep 17 00:00:00 2001 From: hangyu Date: Fri, 30 Aug 2024 12:48:47 -0700 Subject: [PATCH 5/9] 1 --- packages/devtools_app/lib/src/shared/feature_flags.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/devtools_app/lib/src/shared/feature_flags.dart b/packages/devtools_app/lib/src/shared/feature_flags.dart index a5a764e4088..1f2785e5908 100644 --- a/packages/devtools_app/lib/src/shared/feature_flags.dart +++ b/packages/devtools_app/lib/src/shared/feature_flags.dart @@ -76,7 +76,7 @@ abstract class FeatureFlags { /// Flag to enable ios checks in deep link validation. /// /// https://github.com/flutter/devtools/issues/7799 - static bool deepLinkIosCheck = true; + static bool deepLinkIosCheck = false; /// Flag to enable DevTools extensions. /// From 9663e5e27904f77d59707fc9edd765c2f5266e4c Mon Sep 17 00:00:00 2001 From: hangyu Date: Fri, 30 Aug 2024 12:54:15 -0700 Subject: [PATCH 6/9] lint --- .../src/screens/deep_link_validation/deep_links_controller.dart | 2 +- .../devtools_app/test/test_infra/utils/deep_links_utils.dart | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_controller.dart b/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_controller.dart index fd93e289051..da76b57c832 100644 --- a/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_controller.dart +++ b/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_controller.dart @@ -9,7 +9,6 @@ import 'package:devtools_app_shared/utils.dart'; import 'package:devtools_shared/devtools_deeplink.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:http/http.dart'; import '../../shared/analytics/analytics.dart' as ga; import '../../shared/analytics/constants.dart' as gac; @@ -557,6 +556,7 @@ class DeepLinksController extends DisposableController if (linkdata.os.contains(PlatformOS.ios)) { final List iosPaths = iosDomainPaths[linkdata.domain] ?? []; + // If there are multiple paths for the same domain, we will show the domain with each path. for (final iosPath in iosPaths) { validatedLinkDatas.add( linkdata.copyWith( diff --git a/packages/devtools_app/test/test_infra/utils/deep_links_utils.dart b/packages/devtools_app/test/test_infra/utils/deep_links_utils.dart index b473b71d131..5ddc45eac17 100644 --- a/packages/devtools_app/test/test_infra/utils/deep_links_utils.dart +++ b/packages/devtools_app/test/test_infra/utils/deep_links_utils.dart @@ -5,7 +5,6 @@ import 'package:devtools_app/devtools_app.dart'; import 'package:devtools_app/src/screens/deep_link_validation/deep_links_model.dart'; import 'package:devtools_app/src/screens/deep_link_validation/deep_links_services.dart'; -import 'package:devtools_shared/devtools_deeplink.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:http/http.dart'; import 'package:http/testing.dart'; From 61d03925b3219137a213cde05e17a21d0be82bc7 Mon Sep 17 00:00:00 2001 From: hangyu Date: Fri, 30 Aug 2024 12:55:36 -0700 Subject: [PATCH 7/9] lint --- .../deep_links_controller.dart | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_controller.dart b/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_controller.dart index da76b57c832..0a97efe0c60 100644 --- a/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_controller.dart +++ b/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_controller.dart @@ -556,18 +556,6 @@ class DeepLinksController extends DisposableController if (linkdata.os.contains(PlatformOS.ios)) { final List iosPaths = iosDomainPaths[linkdata.domain] ?? []; - // If there are multiple paths for the same domain, we will show the domain with each path. - for (final iosPath in iosPaths) { - validatedLinkDatas.add( - linkdata.copyWith( - path: iosPath, - domainErrors: errors, - hasAndroidAssetLinksFile: hasAndroidAssetLinksFile, - hasIosAasaFile: hasIosAasaFile, - ), - ); - } - // If no path is provided, we will still show the domain just with domain errors. if (iosPaths.isEmpty) { validatedLinkDatas.add( @@ -577,6 +565,18 @@ class DeepLinksController extends DisposableController hasIosAasaFile: hasIosAasaFile, ), ); + } else { + // If there are multiple paths for the same domain, we will show the domain with each path. + for (final iosPath in iosPaths) { + validatedLinkDatas.add( + linkdata.copyWith( + path: iosPath, + domainErrors: errors, + hasAndroidAssetLinksFile: hasAndroidAssetLinksFile, + hasIosAasaFile: hasIosAasaFile, + ), + ); + } } } From b183cb4fbcd1b39ac638e51a53f31879aa455306 Mon Sep 17 00:00:00 2001 From: hangyu Date: Thu, 5 Sep 2024 14:29:24 -0700 Subject: [PATCH 8/9] lint --- .../deep_link_validation/deep_links_services.dart | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_services.dart b/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_services.dart index 2b2c73e4bc5..0c05288ed5b 100644 --- a/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_services.dart +++ b/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_services.dart @@ -161,7 +161,7 @@ class DeepLinksService { for (final domain in domains) domain: [], }; - final paths = >{ + final paths = >{ for (final domain in domains) domain: [], }; // TODO(hangyujin): Add error code to the result. @@ -202,19 +202,18 @@ class DeepLinksService { } paths[domainName] ??= []; final aasaAppPaths = (domainResult[_aasaAppPathsKey] as List?) - ?.cast>(); + ?.cast>(); if (aasaAppPaths != null) { for (final aasaAppPath in aasaAppPaths) { - final aasaPaths= (aasaAppPath[_aasaPathsKey] as List?)?.cast>(); + final aasaPaths = (aasaAppPath[_aasaPathsKey] as List?) + ?.cast>(); if (aasaPaths != null) { - for(final aasaPath in aasaPaths) - { - paths[domainName]!.add( aasaPath[_pathKey] as String); + for (final aasaPath in aasaPaths) { + paths[domainName]!.add(aasaPath[_pathKey] as String); } continue; } } - } } } From 16c757a1ef2d9b99a54c8fc953c48e61cba5a146 Mon Sep 17 00:00:00 2001 From: hangyu Date: Fri, 6 Sep 2024 11:09:49 -0700 Subject: [PATCH 9/9] resolve comments --- .../deep_links_controller.dart | 6 ++---- .../deep_links_services.dart | 18 ++++++++---------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_controller.dart b/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_controller.dart index 0a97efe0c60..c41e61d92b9 100644 --- a/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_controller.dart +++ b/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_controller.dart @@ -497,9 +497,7 @@ class DeepLinksController extends DisposableController } } - Future> _validateDomain( - List rawLinkdatas, - ) async { + Future> _validateDomain(List rawLinkdatas) async { final domains = rawLinkdatas .where( (linkdata) => linkdata.domain != null, @@ -512,7 +510,7 @@ class DeepLinksController extends DisposableController Map> iosDomainErrors = >{}; - Map> iosDomainPaths = >{}; + late final Map> iosDomainPaths; try { final androidResult = await deepLinksService.validateAndroidDomain( domains: domains, diff --git a/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_services.dart b/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_services.dart index 0c05288ed5b..6d5888ad233 100644 --- a/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_services.dart +++ b/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_services.dart @@ -157,13 +157,8 @@ class DeepLinksService { required String teamId, required List domains, }) async { - final domainErrors = >{ - for (final domain in domains) domain: [], - }; - - final paths = >{ - for (final domain in domains) domain: [], - }; + final domainErrors = >{}; + final paths = >{}; // TODO(hangyujin): Add error code to the result. const errorCode = ''; @@ -196,11 +191,12 @@ class DeepLinksService { final checkName = failedCheck[_checkNameKey] as String; final domainError = iosCheckNameToDomainError[checkName]; if (domainError != null) { - domainErrors[domainName]!.add(domainError); + domainErrors + .putIfAbsent(domainName, () => []) + .add(domainError); } } } - paths[domainName] ??= []; final aasaAppPaths = (domainResult[_aasaAppPathsKey] as List?) ?.cast>(); if (aasaAppPaths != null) { @@ -209,7 +205,9 @@ class DeepLinksService { ?.cast>(); if (aasaPaths != null) { for (final aasaPath in aasaPaths) { - paths[domainName]!.add(aasaPath[_pathKey] as String); + paths + .putIfAbsent(domainName, () => []) + .add(aasaPath[_pathKey] as String); } continue; }