1.18.0-11.1.pre beta cherrypicks (#57058)

* Always remove the workspace settings (#56703)

* [flutter_tools] hide tree-shake-icons (#56924)

* fix pushAndRemoveUntil incorrectly removes the routes below the first… (#56732)

* let the embedding maven engine dependency reference the storage proxy (#56164)

* typo fix on the FLUTTER_STORAGE_BASE_URL usage (#56685)

* Update engine hash for 1.18.0-11.1.pre

Co-authored-by: Jenn Magder <magder@google.com>
Co-authored-by: Jonah Williams <campfish91@gmail.com>
Co-authored-by: chunhtai <47866232+chunhtai@users.noreply.github.com>
Co-authored-by: xster <xster@google.com>
Co-authored-by: Luke Cheng <chenglu@users.noreply.github.com>
diff --git a/bin/internal/engine.version b/bin/internal/engine.version
index 3b280c3..27eb42c 100644
--- a/bin/internal/engine.version
+++ b/bin/internal/engine.version
@@ -1 +1 @@
-33d2367950154e7f8daf9ce9992a450016289a5f
+ef9215ceb2884ddf520d321bcd822d1461330876
diff --git a/dev/devicelab/bin/tasks/android_engine_dependency_proxy_test.dart b/dev/devicelab/bin/tasks/android_engine_dependency_proxy_test.dart
new file mode 100644
index 0000000..e5e1665
--- /dev/null
+++ b/dev/devicelab/bin/tasks/android_engine_dependency_proxy_test.dart
@@ -0,0 +1,75 @@
+// Copyright 2014 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import 'dart:async';
+import 'dart:io';
+
+import 'package:flutter_devicelab/framework/apk_utils.dart';
+import 'package:flutter_devicelab/framework/framework.dart';
+import 'package:flutter_devicelab/framework/utils.dart';
+import 'package:path/path.dart' as path;
+
+final String gradlew = Platform.isWindows ? 'gradlew.bat' : 'gradlew';
+final String gradlewExecutable = Platform.isWindows ? '.\\$gradlew' : './$gradlew';
+
+/// Tests that we respect storage proxy URLs in gradle dependencies.
+Future<void> main() async {
+  await task(() async {
+    section('Find Java');
+
+    final String javaHome = await findJavaHome();
+    if (javaHome == null)
+      return TaskResult.failure('Could not find Java');
+    print('\nUsing JAVA_HOME=$javaHome');
+
+    section('Create project');
+    await runProjectTest((FlutterProject flutterProject) async {
+      await inDirectory(path.join(flutterProject.rootPath, 'android'), () async {
+        section('Insert gradle testing script');
+        final File build = File(path.join(
+            flutterProject.rootPath, 'android', 'app', 'build.gradle'));
+        build.writeAsStringSync(
+          '''
+task printEngineMavenUrl() {
+    doLast {
+        println project.repositories.find { it.name == 'maven' }.url
+    }
+}
+          ''',
+          mode: FileMode.append,
+          flush: true,
+        );
+
+        section('Checking default maven URL');
+        String mavenUrl = await eval(
+          gradlewExecutable,
+          <String>['printEngineMavenUrl', '-q'],
+        );
+
+        if (mavenUrl != 'https://storage.googleapis.com/download.flutter.io') {
+          throw TaskResult.failure('Expected Android engine maven dependency URL to '
+          'resolve to https://storage.googleapis.com/download.flutter.io. Got '
+          '$mavenUrl instead');
+        }
+
+        section('Checking overriden maven URL');
+        mavenUrl = await eval(
+          gradlewExecutable,
+          <String>['printEngineMavenUrl', '-q'],
+          environment: <String, String>{
+            'FLUTTER_STORAGE_BASE_URL': 'https://my.special.proxy',
+          }
+        );
+
+        if (mavenUrl != 'https://my.special.proxy/download.flutter.io') {
+          throw TaskResult.failure('Expected overriden Android engine maven '
+          'dependency URL to resolve to proxy location '
+          'https://my.special.proxy/download.flutter.io. Got '
+          '$mavenUrl instead');
+        }
+      });
+    });
+    return TaskResult.success(null);
+  });
+}
diff --git a/packages/flutter/lib/src/widgets/navigator.dart b/packages/flutter/lib/src/widgets/navigator.dart
index b57d352..5e48bb5 100644
--- a/packages/flutter/lib/src/widgets/navigator.dart
+++ b/packages/flutter/lib/src/widgets/navigator.dart
@@ -3412,9 +3412,8 @@
     assert(predicate != null);
     int index = _history.length - 1;
     _history.add(_RouteEntry(newRoute, initialState: _RouteLifecycle.push));
-    while (index >= 0) {
-      final _RouteEntry entry = _history[index];
-      if (entry.isPresent && !predicate(entry.route))
+    while (index >= 0 && !predicate(_history[index].route)) {
+      if (_history[index].isPresent)
         _history[index].remove();
       index -= 1;
     }
diff --git a/packages/flutter/test/widgets/navigator_test.dart b/packages/flutter/test/widgets/navigator_test.dart
index 51855e6..b06007f 100644
--- a/packages/flutter/test/widgets/navigator_test.dart
+++ b/packages/flutter/test/widgets/navigator_test.dart
@@ -682,6 +682,42 @@
     expect(find.text('B'), isOnstage);
   });
 
+  testWidgets('pushAndRemoveUntil does not remove routes below the first route that pass the predicate', (WidgetTester tester) async {
+    // Regression https://github.com/flutter/flutter/issues/56688
+    final GlobalKey<NavigatorState> navigator = GlobalKey<NavigatorState>();
+    final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
+      '/': (BuildContext context) => const Text('home'),
+      '/A': (BuildContext context) => const Text('page A'),
+      '/A/B': (BuildContext context) => OnTapPage(
+        id: 'B',
+        onTap: () {
+          Navigator.of(context).pushNamedAndRemoveUntil('/D', ModalRoute.withName('/A'));
+        },
+      ),
+      '/D': (BuildContext context) => const Text('page D'),
+    };
+
+    await tester.pumpWidget(
+      MaterialApp(
+        navigatorKey: navigator,
+        routes: routes,
+        initialRoute: '/A/B',
+      )
+    );
+    await tester.pumpAndSettle();
+    await tester.tap(find.text('B'));
+    await tester.pumpAndSettle();
+    expect(find.text('page D'), isOnstage);
+
+    navigator.currentState.pop();
+    await tester.pumpAndSettle();
+    expect(find.text('page A'), isOnstage);
+
+    navigator.currentState.pop();
+    await tester.pumpAndSettle();
+    expect(find.text('home'), isOnstage);
+  });
+
   testWidgets('replaceNamed returned value', (WidgetTester tester) async {
     Future<String> value;
 
diff --git a/packages/flutter_tools/gradle/aar_init_script.gradle b/packages/flutter_tools/gradle/aar_init_script.gradle
index 030d9b2..06b0f62 100644
--- a/packages/flutter_tools/gradle/aar_init_script.gradle
+++ b/packages/flutter_tools/gradle/aar_init_script.gradle
@@ -53,11 +53,12 @@
             "See: https://github.com/flutter/flutter/issues/40866")
     }
 
+    String storageUrl = System.getenv('FLUTTER_STORAGE_BASE_URL') ?: "https://storage.googleapis.com"
     // This is a Flutter plugin project. Plugin projects don't apply the Flutter Gradle plugin,
     // as a result, add the dependency on the embedding.
     project.repositories {
         maven {
-            url "https://storage.googleapis.com/download.flutter.io"
+            url "$storageUrl/download.flutter.io"
         }
     }
     String engineVersion = Paths.get(getFlutterRoot(project), "bin", "internal", "engine.version")
diff --git a/packages/flutter_tools/gradle/flutter.gradle b/packages/flutter_tools/gradle/flutter.gradle
index 8ac0448..3c223e9 100644
--- a/packages/flutter_tools/gradle/flutter.gradle
+++ b/packages/flutter_tools/gradle/flutter.gradle
@@ -41,7 +41,7 @@
 apply plugin: FlutterPlugin
 
 class FlutterPlugin implements Plugin<Project> {
-    private static final String MAVEN_REPO      = "https://storage.googleapis.com/download.flutter.io";
+    private static final String DEFAULT_MAVEN_HOST = "https://storage.googleapis.com";
 
     // The platforms that can be passed to the `--Ptarget-platform` flag.
     private static final String PLATFORM_ARM32  = "android-arm";
@@ -200,10 +200,10 @@
         if (!supportsBuildMode(flutterBuildMode)) {
             return
         }
+        String hostedRepository = System.env.FLUTTER_STORAGE_BASE_URL ?: DEFAULT_MAVEN_HOST
         String repository = useLocalEngine()
             ? project.property('local-engine-repo')
-            : MAVEN_REPO
-
+            : "$hostedRepository/download.flutter.io"
         project.rootProject.allprojects {
             repositories {
                 maven {
diff --git a/packages/flutter_tools/gradle/resolve_dependencies.gradle b/packages/flutter_tools/gradle/resolve_dependencies.gradle
index 3ee4ab2..508fb49 100644
--- a/packages/flutter_tools/gradle/resolve_dependencies.gradle
+++ b/packages/flutter_tools/gradle/resolve_dependencies.gradle
@@ -14,11 +14,13 @@
 
 import java.nio.file.Paths
 
+String storageUrl = System.getenv('FLUTTER_STORAGE_BASE_URL') ?: "https://storage.googleapis.com"
+
 repositories {
     google()
     jcenter()
     maven {
-        url "https://storage.googleapis.com/download.flutter.io"
+        url "$storageUrl/download.flutter.io"
     }
 }
 
diff --git a/packages/flutter_tools/lib/src/android/gradle.dart b/packages/flutter_tools/lib/src/android/gradle.dart
index 6dff174..06a7d99 100644
--- a/packages/flutter_tools/lib/src/android/gradle.dart
+++ b/packages/flutter_tools/lib/src/android/gradle.dart
@@ -648,12 +648,13 @@
   1. Open ${fileSystem.path.join('<host>', 'app', 'build.gradle')}
   2. Ensure you have the repositories configured, otherwise add them:
 
+      String storageUrl = System.env.FLUTTER_STORAGE_BASE_URL ?: "https://storage.googleapis.com"
       repositories {
         maven {
             url '${repoDirectory.path}'
         }
         maven {
-            url 'https://storage.googleapis.com/download.flutter.io'
+            url '\$storageUrl/download.flutter.io'
         }
       }
 
diff --git a/packages/flutter_tools/lib/src/ios/migrations/xcode_build_system_migration.dart b/packages/flutter_tools/lib/src/ios/migrations/xcode_build_system_migration.dart
index da2bbaa..f5e8e0b 100644
--- a/packages/flutter_tools/lib/src/ios/migrations/xcode_build_system_migration.dart
+++ b/packages/flutter_tools/lib/src/ios/migrations/xcode_build_system_migration.dart
@@ -28,14 +28,10 @@
 
     final String contents = _xcodeWorkspaceSharedSettings.readAsStringSync();
 
-    // Only delete this file when it matches the original Flutter template.
+    // Only delete this file when it is pointing to the legacy build system.
     const String legacyBuildSettingsWorkspace = '''
-<plist version="1.0">
-<dict>
 	<key>BuildSystemType</key>
-	<string>Original</string>
-</dict>
-</plist>''';
+	<string>Original</string>''';
 
     // contains instead of equals to ignore newline file ending variance.
     if (contents.contains(legacyBuildSettingsWorkspace)) {
diff --git a/packages/flutter_tools/lib/src/runner/flutter_command.dart b/packages/flutter_tools/lib/src/runner/flutter_command.dart
index c0d8d69..ab90c80 100644
--- a/packages/flutter_tools/lib/src/runner/flutter_command.dart
+++ b/packages/flutter_tools/lib/src/runner/flutter_command.dart
@@ -445,6 +445,7 @@
       defaultsTo: enabledByDefault
         ?? kIconTreeShakerEnabledDefault,
       help: 'Tree shake icon fonts so that only glyphs used by the application remain.',
+      hide: true,
     );
   }
 
diff --git a/packages/flutter_tools/test/general.shard/android/gradle_test.dart b/packages/flutter_tools/test/general.shard/android/gradle_test.dart
index da3e5c8..364e0b6 100644
--- a/packages/flutter_tools/test/general.shard/android/gradle_test.dart
+++ b/packages/flutter_tools/test/general.shard/android/gradle_test.dart
@@ -2343,12 +2343,13 @@
           '  1. Open <host>/app/build.gradle\n'
           '  2. Ensure you have the repositories configured, otherwise add them:\n'
           '\n'
+          '      String storageUrl = System.env.FLUTTER_STORAGE_BASE_URL ?: "https://storage.googleapis.com"\n'
           '      repositories {\n'
           '        maven {\n'
           "            url 'build/'\n"
           '        }\n'
           '        maven {\n'
-          "            url 'https://storage.googleapis.com/download.flutter.io'\n"
+          "            url '\$storageUrl/download.flutter.io'\n"
           '        }\n'
           '      }\n'
           '\n'
@@ -2393,12 +2394,13 @@
           '  1. Open <host>/app/build.gradle\n'
           '  2. Ensure you have the repositories configured, otherwise add them:\n'
           '\n'
+          '      String storageUrl = System.env.FLUTTER_STORAGE_BASE_URL ?: "https://storage.googleapis.com"\n'
           '      repositories {\n'
           '        maven {\n'
           "            url 'build/'\n"
           '        }\n'
           '        maven {\n'
-          "            url 'https://storage.googleapis.com/download.flutter.io'\n"
+          "            url '\$storageUrl/download.flutter.io'\n"
           '        }\n'
           '      }\n'
           '\n'
@@ -2430,12 +2432,13 @@
           '  1. Open <host>/app/build.gradle\n'
           '  2. Ensure you have the repositories configured, otherwise add them:\n'
           '\n'
+          '      String storageUrl = System.env.FLUTTER_STORAGE_BASE_URL ?: "https://storage.googleapis.com"\n'
           '      repositories {\n'
           '        maven {\n'
           "            url 'build/'\n"
           '        }\n'
           '        maven {\n'
-          "            url 'https://storage.googleapis.com/download.flutter.io'\n"
+          "            url '\$storageUrl/download.flutter.io'\n"
           '        }\n'
           '      }\n'
           '\n'
@@ -2468,12 +2471,13 @@
           '  1. Open <host>/app/build.gradle\n'
           '  2. Ensure you have the repositories configured, otherwise add them:\n'
           '\n'
+          '      String storageUrl = System.env.FLUTTER_STORAGE_BASE_URL ?: "https://storage.googleapis.com"\n'
           '      repositories {\n'
           '        maven {\n'
           "            url 'build/'\n"
           '        }\n'
           '        maven {\n'
-          "            url 'https://storage.googleapis.com/download.flutter.io'\n"
+          "            url '\$storageUrl/download.flutter.io'\n"
           '        }\n'
           '      }\n'
           '\n'
diff --git a/packages/flutter_tools/test/general.shard/ios/ios_project_migration_test.dart b/packages/flutter_tools/test/general.shard/ios/ios_project_migration_test.dart
index b7b8df0..8fb672e 100644
--- a/packages/flutter_tools/test/general.shard/ios/ios_project_migration_test.dart
+++ b/packages/flutter_tools/test/general.shard/ios/ios_project_migration_test.dart
@@ -322,6 +322,8 @@
 <dict>
 	<key>BuildSystemType</key>
 	<string>Original</string>
+	<key>PreviewsEnabled</key>
+	<false/>
 </dict>
 </plist>''';
         xcodeWorkspaceSharedSettings.writeAsStringSync(contents);