Implementing Locale.toLanguageTag in flutter web. (flutter/engine#17131)

This commit is contained in:
MennaFadali 2020-03-13 16:57:53 +01:00 committed by GitHub
parent 7b484fb1e4
commit 77db1c8e9e

View File

@ -478,19 +478,17 @@ class Locale {
int get hashCode => hashValues(languageCode, scriptCode, countryCode);
@override
String toString() {
final StringBuffer out = StringBuffer(languageCode);
if (scriptCode != null) {
out.write('_$scriptCode');
}
if (_countryCode != null) {
out.write('_$countryCode');
}
return out.toString();
}
String toString() => _rawToString('_');
// TODO(yjbanov): implement to match flutter native.
String toLanguageTag() => '_';
String toLanguageTag() => _rawToString('-');
String _rawToString(String separator) {
final StringBuffer out = StringBuffer(languageCode);
if (scriptCode != null) out.write('$separator$scriptCode');
if (_countryCode != null) out.write('$separator$countryCode');
return out.toString();
}
}
/// The most basic interface to the host operating system's user interface.