Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 637a8e7

Browse files
authored
Revert method channel platform resolved locale (#19136)
1 parent 11927c6 commit 637a8e7

File tree

13 files changed

+1
-130
lines changed

13 files changed

+1
-130
lines changed

lib/ui/hooks.dart

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -88,22 +88,6 @@ void _updateLocales(List<String> locales) {
8888
_invoke(window.onLocaleChanged, window._onLocaleChangedZone);
8989
}
9090

91-
@pragma('vm:entry-point')
92-
// ignore: unused_element
93-
void _updatePlatformResolvedLocale(List<String> localeData) {
94-
if (localeData.length != 4) {
95-
return;
96-
}
97-
final String countryCode = localeData[1];
98-
final String scriptCode = localeData[2];
99-
100-
window._platformResolvedLocale = Locale.fromSubtags(
101-
languageCode: localeData[0],
102-
countryCode: countryCode.isEmpty ? null : countryCode,
103-
scriptCode: scriptCode.isEmpty ? null : scriptCode,
104-
);
105-
}
106-
10791
@pragma('vm:entry-point')
10892
// ignore: unused_element
10993
void _updateUserSettingsData(String jsonData) {

lib/ui/window.dart

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -796,19 +796,6 @@ class Window {
796796
List<Locale>? get locales => _locales;
797797
List<Locale>? _locales;
798798

799-
/// The locale that the platform's native locale resolution system resolves to.
800-
///
801-
/// This value may differ between platforms and is meant to allow Flutter's locale
802-
/// resolution algorithms access to a locale that is consistent with other apps
803-
/// on the device. Using this property is optional.
804-
///
805-
/// This value may be used in a custom [localeListResolutionCallback] or used directly
806-
/// in order to arrive at the most appropriate locale for the app.
807-
///
808-
/// See [locales], which is the list of locales the user/device prefers.
809-
Locale? get platformResolvedLocale => _platformResolvedLocale;
810-
Locale? _platformResolvedLocale;
811-
812799
/// Performs the platform-native locale resolution.
813800
///
814801
/// Each platform may return different results.

lib/ui/window/window.cc

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -224,19 +224,6 @@ void Window::UpdateLocales(const std::vector<std::string>& locales) {
224224
}));
225225
}
226226

227-
void Window::UpdatePlatformResolvedLocale(
228-
const std::vector<std::string>& locale) {
229-
std::shared_ptr<tonic::DartState> dart_state = library_.dart_state().lock();
230-
if (!dart_state)
231-
return;
232-
tonic::DartState::Scope scope(dart_state);
233-
tonic::LogIfError(tonic::DartInvokeField(
234-
library_.value(), "_updatePlatformResolvedLocale",
235-
{
236-
tonic::ToDart<std::vector<std::string>>(locale),
237-
}));
238-
}
239-
240227
void Window::UpdateUserSettingsData(const std::string& data) {
241228
std::shared_ptr<tonic::DartState> dart_state = library_.dart_state().lock();
242229
if (!dart_state)

lib/ui/window/window.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ class Window final {
7878
void DidCreateIsolate();
7979
void UpdateWindowMetrics(const ViewportMetrics& metrics);
8080
void UpdateLocales(const std::vector<std::string>& locales);
81-
void UpdatePlatformResolvedLocale(const std::vector<std::string>& locale);
8281
void UpdateUserSettingsData(const std::string& data);
8382
void UpdateLifecycleState(const std::string& data);
8483
void UpdateSemanticsEnabled(bool enabled);

lib/web_ui/lib/src/engine/window.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,6 @@ class EngineWindow extends ui.Window {
303303
return locales;
304304
}
305305

306-
/// On the web "platform" is the browser, so it's the same as [locale].
307-
@override
308-
ui.Locale get platformResolvedLocale => locale;
309-
310306
/// Engine code should use this method instead of the callback directly.
311307
/// Otherwise zones won't work properly.
312308
void invokeOnLocaleChanged() {

lib/web_ui/lib/src/ui/window.dart

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -604,18 +604,6 @@ abstract class Window {
604604
/// observe when this value changes.
605605
List<Locale>? get locales;
606606

607-
/// The locale that the platform's native locale resolution system resolves to.
608-
///
609-
/// This value may differ between platforms and is meant to allow flutter locale
610-
/// resolution algorithms to into resolving consistently with other apps on the
611-
/// device.
612-
///
613-
/// This value may be used in a custom [localeListResolutionCallback] or used directly
614-
/// in order to arrive at the most appropriate locale for the app.
615-
///
616-
/// See [locales], which is the list of locales the user/device prefers.
617-
Locale? get platformResolvedLocale;
618-
619607
/// Performs the platform-native locale resolution.
620608
///
621609
/// Each platform may return different results.

runtime/runtime_controller.cc

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,6 @@ std::unique_ptr<RuntimeController> RuntimeController::Clone() const {
131131
bool RuntimeController::FlushRuntimeStateToIsolate() {
132132
return SetViewportMetrics(window_data_.viewport_metrics) &&
133133
SetLocales(window_data_.locale_data) &&
134-
SetPlatformResolvedLocale(
135-
window_data_.platform_resolved_locale_data) &&
136134
SetSemanticsEnabled(window_data_.semantics_enabled) &&
137135
SetAccessibilityFeatures(window_data_.accessibility_feature_flags_) &&
138136
SetUserSettingsData(window_data_.user_settings_data) &&
@@ -161,18 +159,6 @@ bool RuntimeController::SetLocales(
161159
return false;
162160
}
163161

164-
bool RuntimeController::SetPlatformResolvedLocale(
165-
const std::vector<std::string>& locale_data) {
166-
window_data_.platform_resolved_locale_data = locale_data;
167-
168-
if (auto* window = GetWindowIfAvailable()) {
169-
window->UpdatePlatformResolvedLocale(locale_data);
170-
return true;
171-
}
172-
173-
return false;
174-
}
175-
176162
bool RuntimeController::SetUserSettingsData(const std::string& data) {
177163
window_data_.user_settings_data = data;
178164

runtime/runtime_controller.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -161,23 +161,6 @@ class RuntimeController final : public WindowClient {
161161
///
162162
bool SetLocales(const std::vector<std::string>& locale_data);
163163

164-
//----------------------------------------------------------------------------
165-
/// @brief Forward the specified locale data to the running isolate. If
166-
/// the isolate is not running, this data will be saved and
167-
/// flushed to the isolate when it starts running.
168-
///
169-
///
170-
/// @deprecated The persistent isolate data must be used for this purpose
171-
/// instead.
172-
///
173-
/// @param[in] locale_data The locale data. This should consist of a vector
174-
/// of 4 strings, representing languageCode, contryCode,
175-
/// scriptCode, and variant of the locale.
176-
///
177-
/// @return If the locale data was forwarded to the running isolate.
178-
///
179-
bool SetPlatformResolvedLocale(const std::vector<std::string>& locale_data);
180-
181164
//----------------------------------------------------------------------------
182165
/// @brief Forward the user settings data to the running isolate. If the
183166
/// isolate is not running, this data will be saved and flushed to

runtime/window_data.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ struct WindowData {
3636
std::string script_code;
3737
std::string variant_code;
3838
std::vector<std::string> locale_data;
39-
std::vector<std::string> platform_resolved_locale_data;
4039
std::string user_settings_data = "{}";
4140
std::string lifecycle_state;
4241
bool semantics_enabled = false;

shell/common/engine.cc

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -388,24 +388,6 @@ bool Engine::HandleLocalizationPlatformMessage(PlatformMessage* message) {
388388
}
389389

390390
return runtime_controller_->SetLocales(locale_data);
391-
} else if (method->value == "setPlatformResolvedLocale") {
392-
// Decode and pass the single locale data onwards to dart.
393-
auto args = root.FindMember("args");
394-
if (args == root.MemberEnd() || !args->value.IsArray())
395-
return false;
396-
397-
if (args->value.Size() != strings_per_locale)
398-
return false;
399-
400-
std::vector<std::string> locale_data;
401-
if (!args->value[0].IsString() || !args->value[1].IsString())
402-
return false;
403-
locale_data.push_back(args->value[0].GetString());
404-
locale_data.push_back(args->value[1].GetString());
405-
locale_data.push_back(args->value[2].GetString());
406-
locale_data.push_back(args->value[3].GetString());
407-
408-
return runtime_controller_->SetPlatformResolvedLocale(locale_data);
409391
}
410392
return false;
411393
}

0 commit comments

Comments
 (0)