@@ -15,7 +15,7 @@ abstract class Utils {
1515 List <BeamLocation > beamLocations, {
1616 Map <String , dynamic > data = const < String , dynamic > {},
1717 }) {
18- for (var beamLocation in beamLocations) {
18+ for (final beamLocation in beamLocations) {
1919 if (canBeamLocationHandleUri (beamLocation, uri)) {
2020 return beamLocation
2121 ..state = beamLocation.createState (
@@ -34,12 +34,12 @@ abstract class Utils {
3434 ///
3535 /// Used in [BeamLocation.canHandle] and [chooseBeamLocation] .
3636 static bool canBeamLocationHandleUri (BeamLocation beamLocation, Uri uri) {
37- for (var pathBlueprint in beamLocation.pathBlueprints) {
37+ for (final pathBlueprint in beamLocation.pathBlueprints) {
3838 if (pathBlueprint is String ) {
3939 if (pathBlueprint == uri.path || pathBlueprint == '/*' ) {
4040 return true ;
4141 }
42- final uriPathSegments = List . from ( uri.pathSegments);
42+ final uriPathSegments = uri.pathSegments. toList ( );
4343 if (uriPathSegments.length > 1 && uriPathSegments.last == '' ) {
4444 uriPathSegments.removeLast ();
4545 }
@@ -82,7 +82,7 @@ abstract class Utils {
8282 }) {
8383 if (beamLocation != null ) {
8484 // TODO: abstract this and reuse in canBeamLocationHandleUri
85- for (var pathBlueprint in beamLocation.pathBlueprints) {
85+ for (final pathBlueprint in beamLocation.pathBlueprints) {
8686 if (pathBlueprint is String ) {
8787 if (pathBlueprint == uri.path || pathBlueprint == '/*' ) {
8888 BeamState (
@@ -91,14 +91,14 @@ abstract class Utils {
9191 data: data,
9292 );
9393 }
94- final uriPathSegments = List . from ( uri.pathSegments);
94+ final uriPathSegments = uri.pathSegments. toList ( );
9595 if (uriPathSegments.length > 1 && uriPathSegments.last == '' ) {
9696 uriPathSegments.removeLast ();
9797 }
9898 final beamLocationPathBlueprintSegments =
9999 Uri .parse (pathBlueprint).pathSegments;
100100 var pathSegments = < String > [];
101- var pathParameters = < String , String > {};
101+ final pathParameters = < String , String > {};
102102 if (uriPathSegments.length >
103103 beamLocationPathBlueprintSegments.length &&
104104 ! beamLocationPathBlueprintSegments.contains ('*' )) {
@@ -107,7 +107,7 @@ abstract class Utils {
107107 var checksPassed = true ;
108108 for (int i = 0 ; i < uriPathSegments.length; i++ ) {
109109 if (beamLocationPathBlueprintSegments[i] == '*' ) {
110- pathSegments = List < String >. from (uriPathSegments );
110+ pathSegments = uriPathSegments. toList ( );
111111 checksPassed = true ;
112112 break ;
113113 }
@@ -133,12 +133,12 @@ abstract class Utils {
133133 }
134134 } else {
135135 final regexp = tryCastToRegExp (pathBlueprint);
136- var pathParameters = < String , String > {};
136+ final pathParameters = < String , String > {};
137137 final url = uri.toString ();
138138
139139 if (regexp.hasMatch (url)) {
140140 regexp.allMatches (url).forEach ((match) {
141- for (String groupName in match.groupNames) {
141+ for (final groupName in match.groupNames) {
142142 pathParameters[groupName] = match.namedGroup (groupName) ?? '' ;
143143 }
144144 });
@@ -159,10 +159,10 @@ abstract class Utils {
159159 );
160160 }
161161
162- static bool urisMatch (dynamic blueprint, Uri exact) {
162+ static bool urisMatch (Pattern blueprint, Uri exact) {
163163 if (blueprint is String ) {
164- blueprint = Uri .parse (blueprint);
165- final blueprintSegments = blueprint .pathSegments;
164+ final uriBlueprint = Uri .parse (blueprint);
165+ final blueprintSegments = uriBlueprint .pathSegments;
166166 final exactSegment = exact.pathSegments;
167167 if (blueprintSegments.length != exactSegment.length) {
168168 return false ;
@@ -177,14 +177,14 @@ abstract class Utils {
177177 }
178178 return true ;
179179 } else {
180- blueprint = tryCastToRegExp (blueprint);
181- return blueprint .hasMatch (exact.toString ());
180+ final regExpBlueprint = tryCastToRegExp (blueprint);
181+ return regExpBlueprint .hasMatch (exact.toString ());
182182 }
183183 }
184184
185185 /// Wraps the casting of pathBlueprint to RegExp inside a try-catch
186186 /// and throws a nice FlutterError.
187- static RegExp tryCastToRegExp (dynamic pathBlueprint) {
187+ static RegExp tryCastToRegExp (Pattern pathBlueprint) {
188188 try {
189189 return pathBlueprint as RegExp ;
190190 } on TypeError catch (_) {
0 commit comments