Match PlatformConfiguration properties to PlatformDispatcher ones (flutter/engine#39685)

* Match PlatformConfiguration properties to PlatformDispatcher ones

* Updated PlatformDispatcher to use PlatformConfiguration to back `nativeSpellCheckServiceDefined` and `brieflyShowPassword`
* Updated web PlatformDispatcher/Configuration to match new API

* Added a test to ensure `PlatformDispatcher` and `PlatformConfig` have the same getters with exceptions.

* Removed test that required adding `analyzer` as a dependency.
This commit is contained in:
pdblasi-google
2023-02-23 13:42:19 -08:00
committed by GitHub
parent ad4b72c30f
commit 4086753035
2 changed files with 36 additions and 14 deletions

View File

@@ -981,8 +981,7 @@ class PlatformDispatcher {
/// This option is used by [EditableTextState] to define its
/// [SpellCheckConfiguration] when a default spell check service
/// is requested.
bool get nativeSpellCheckServiceDefined => _nativeSpellCheckServiceDefined;
bool _nativeSpellCheckServiceDefined = false;
bool get nativeSpellCheckServiceDefined => configuration.nativeSpellCheckServiceDefined;
/// Whether briefly displaying the characters as you type in obscured text
/// fields is enabled in system settings.
@@ -991,8 +990,7 @@ class PlatformDispatcher {
///
/// * [EditableText.obscureText], which when set to true hides the text in
/// the text field.
bool get brieflyShowPassword => _brieflyShowPassword;
bool _brieflyShowPassword = true;
bool get brieflyShowPassword => configuration.brieflyShowPassword;
/// The setting indicating the current brightness mode of the host platform.
/// If the platform has no preference, [platformBrightness] defaults to
@@ -1046,16 +1044,8 @@ class PlatformDispatcher {
final double textScaleFactor = (data['textScaleFactor']! as num).toDouble();
final bool alwaysUse24HourFormat = data['alwaysUse24HourFormat']! as bool;
final bool? nativeSpellCheckServiceDefined = data['nativeSpellCheckServiceDefined'] as bool?;
if (nativeSpellCheckServiceDefined != null) {
_nativeSpellCheckServiceDefined = nativeSpellCheckServiceDefined;
} else {
_nativeSpellCheckServiceDefined = false;
}
// This field is optional.
final bool? brieflyShowPassword = data['brieflyShowPassword'] as bool?;
if (brieflyShowPassword != null) {
_brieflyShowPassword = brieflyShowPassword;
}
final Brightness platformBrightness =
data['platformBrightness']! as String == 'dark' ? Brightness.dark : Brightness.light;
final String? systemFontFamily = data['systemFontFamily'] as String?;
@@ -1072,6 +1062,8 @@ class PlatformDispatcher {
_configuration = previousConfiguration.copyWith(
textScaleFactor: textScaleFactor,
alwaysUse24HourFormat: alwaysUse24HourFormat,
nativeSpellCheckServiceDefined: nativeSpellCheckServiceDefined ?? false,
brieflyShowPassword: brieflyShowPassword,
platformBrightness: platformBrightness,
systemFontFamily: systemFontFamily,
);
@@ -1259,6 +1251,8 @@ class PlatformConfiguration {
this.semanticsEnabled = false,
this.platformBrightness = Brightness.light,
this.textScaleFactor = 1.0,
this.nativeSpellCheckServiceDefined = false,
this.brieflyShowPassword = true,
this.locales = const <Locale>[],
this.defaultRouteName,
this.systemFontFamily,
@@ -1271,6 +1265,8 @@ class PlatformConfiguration {
bool? semanticsEnabled,
Brightness? platformBrightness,
double? textScaleFactor,
bool? nativeSpellCheckServiceDefined,
bool? brieflyShowPassword,
List<Locale>? locales,
String? defaultRouteName,
String? systemFontFamily,
@@ -1281,6 +1277,8 @@ class PlatformConfiguration {
semanticsEnabled: semanticsEnabled ?? this.semanticsEnabled,
platformBrightness: platformBrightness ?? this.platformBrightness,
textScaleFactor: textScaleFactor ?? this.textScaleFactor,
nativeSpellCheckServiceDefined: nativeSpellCheckServiceDefined ?? this.nativeSpellCheckServiceDefined,
brieflyShowPassword: brieflyShowPassword ?? this.brieflyShowPassword,
locales: locales ?? this.locales,
defaultRouteName: defaultRouteName ?? this.defaultRouteName,
systemFontFamily: systemFontFamily ?? this.systemFontFamily,
@@ -1306,6 +1304,22 @@ class PlatformConfiguration {
/// The system-reported text scale.
final double textScaleFactor;
/// Whether the spell check service is supported on the current platform.
///
/// This option is used by [EditableTextState] to define its
/// [SpellCheckConfiguration] when a default spell check service
/// is requested.
final bool nativeSpellCheckServiceDefined;
/// Whether briefly displaying the characters as you type in obscured text
/// fields is enabled in system settings.
///
/// See also:
///
/// * [EditableText.obscureText], which when set to true hides the text in
/// the text field.
final bool brieflyShowPassword;
/// The full system-reported supported locales of the device.
final List<Locale> locales;

View File

@@ -110,9 +110,9 @@ abstract class PlatformDispatcher {
double get textScaleFactor => configuration.textScaleFactor;
bool get nativeSpellCheckServiceDefined => false;
bool get nativeSpellCheckServiceDefined => configuration.nativeSpellCheckServiceDefined;
bool get brieflyShowPassword => true;
bool get brieflyShowPassword => configuration.brieflyShowPassword;
VoidCallback? get onTextScaleFactorChanged;
set onTextScaleFactorChanged(VoidCallback? callback);
@@ -153,6 +153,8 @@ class PlatformConfiguration {
this.semanticsEnabled = false,
this.platformBrightness = Brightness.light,
this.textScaleFactor = 1.0,
this.nativeSpellCheckServiceDefined = false,
this.brieflyShowPassword = true,
this.locales = const <Locale>[],
this.defaultRouteName = '/',
this.systemFontFamily,
@@ -164,6 +166,8 @@ class PlatformConfiguration {
bool? semanticsEnabled,
Brightness? platformBrightness,
double? textScaleFactor,
bool? nativeSpellCheckServiceDefined,
bool? brieflyShowPassword,
List<Locale>? locales,
String? defaultRouteName,
String? systemFontFamily,
@@ -174,6 +178,8 @@ class PlatformConfiguration {
semanticsEnabled: semanticsEnabled ?? this.semanticsEnabled,
platformBrightness: platformBrightness ?? this.platformBrightness,
textScaleFactor: textScaleFactor ?? this.textScaleFactor,
nativeSpellCheckServiceDefined: nativeSpellCheckServiceDefined ?? this.nativeSpellCheckServiceDefined,
brieflyShowPassword: brieflyShowPassword ?? this.brieflyShowPassword,
locales: locales ?? this.locales,
defaultRouteName: defaultRouteName ?? this.defaultRouteName,
systemFontFamily: systemFontFamily ?? this.systemFontFamily,
@@ -185,6 +191,8 @@ class PlatformConfiguration {
final bool semanticsEnabled;
final Brightness platformBrightness;
final double textScaleFactor;
final bool nativeSpellCheckServiceDefined;
final bool brieflyShowPassword;
final List<Locale> locales;
final String defaultRouteName;
final String? systemFontFamily;