Only call setApplicationLocale for application-level Localizations (#194892)

Guard `PlatformDispatcher.setApplicationLocale` in
[`_LocalizationsState.locale`](https://github.com/flutter/flutter/blob/115a15fbf1fd9c6ae4173fff892fd0075eef069d/packages/flutter/lib/src/widgets/localizations.dart#L641-L648)
behind `widget.isApplicationLevel` so subtree `Localizations` and
`Localizations.override` widgets do not overwrite the application-wide
locale (`<html lang>` on Web and fallback accessibility locales on
Android/iOS).

Fixes https://github.com/flutter/flutter/issues/194696

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant in-code documentation (doc comments with
`///`).
- [x] If this PR introduces a new feature or capability, I created and
linked a website documentation issue or PR in [flutter/website] (or
verified none is needed).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/CONTRIBUTING.ai.md
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[flutter/website]: https://github.com/flutter/website
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
diff --git a/packages/flutter/lib/src/widgets/localizations.dart b/packages/flutter/lib/src/widgets/localizations.dart
index afae44e..4cb1de3 100644
--- a/packages/flutter/lib/src/widgets/localizations.dart
+++ b/packages/flutter/lib/src/widgets/localizations.dart
@@ -643,7 +643,9 @@
     if (_locale == locale) {
       return;
     }
-    WidgetsBinding.instance.platformDispatcher.setApplicationLocale(locale!);
+    if (widget.isApplicationLevel) {
+      WidgetsBinding.instance.platformDispatcher.setApplicationLocale(locale!);
+    }
     _locale = locale;
   }
 
diff --git a/packages/flutter/test/widgets/localizations_test.dart b/packages/flutter/test/widgets/localizations_test.dart
index 4b5e6bd..903f6c6 100644
--- a/packages/flutter/test/widgets/localizations_test.dart
+++ b/packages/flutter/test/widgets/localizations_test.dart
@@ -79,6 +79,25 @@
     expect(tester.binding.platformDispatcher.applicationLocale, const Locale('fo'));
   });
 
+  testWidgets('Locale is not sent to engine if Localizations is not application level', (
+    WidgetTester tester,
+  ) async {
+    await tester.pumpWidget(
+      WidgetsApp(
+        color: const Color(0xFF000000),
+        locale: const Locale('en', 'US'),
+        builder: (BuildContext context, _) {
+          return Localizations.override(
+            context: context,
+            locale: const Locale('es', 'US'),
+            child: const Text('Hola'),
+          );
+        },
+      ),
+    );
+    expect(tester.binding.platformDispatcher.applicationLocale, const Locale('en', 'US'));
+  });
+
   testWidgets('Localizations.localeOf throws when no localizations exist', (
     WidgetTester tester,
   ) async {