@@ -864,6 +864,26 @@ class PlatformDispatcher {
864864 _onPlatformBrightnessChangedZone = Zone .current;
865865 }
866866
867+ /// The setting indicating the current system font of the host platform.
868+ String ? get systemFontFamily => configuration.systemFontFamily;
869+
870+ /// A callback that is invoked whenever [systemFontFamily] changes value.
871+ ///
872+ /// The framework invokes this callback in the same zone in which the callback
873+ /// was set.
874+ ///
875+ /// See also:
876+ ///
877+ /// * [WidgetsBindingObserver] , for a mechanism at the widgets layer to
878+ /// observe when this callback is invoked.
879+ VoidCallback ? get onSystemFontFamilyChanged => _onSystemFontFamilyChanged;
880+ VoidCallback ? _onSystemFontFamilyChanged;
881+ Zone _onSystemFontFamilyChangedZone = Zone .root;
882+ set onSystemFontFamilyChanged (VoidCallback ? callback) {
883+ _onSystemFontFamilyChanged = callback;
884+ _onSystemFontFamilyChangedZone = Zone .current;
885+ }
886+
867887 // Called from the engine, via hooks.dart
868888 void _updateUserSettingsData (String jsonData) {
869889 final Map <String , Object ?> data = json.decode (jsonData) as Map <String , Object ?>;
@@ -880,19 +900,23 @@ class PlatformDispatcher {
880900 }
881901 final Brightness platformBrightness =
882902 data['platformBrightness' ]! as String == 'dark' ? Brightness .dark : Brightness .light;
903+ final String ? systemFontFamily = data['systemFontFamily' ] as String ? ;
883904 final PlatformConfiguration previousConfiguration = configuration;
884905 final bool platformBrightnessChanged =
885906 previousConfiguration.platformBrightness != platformBrightness;
886907 final bool textScaleFactorChanged = previousConfiguration.textScaleFactor != textScaleFactor;
887908 final bool alwaysUse24HourFormatChanged =
888909 previousConfiguration.alwaysUse24HourFormat != alwaysUse24HourFormat;
889- if (! platformBrightnessChanged && ! textScaleFactorChanged && ! alwaysUse24HourFormatChanged) {
910+ final bool systemFontFamilyChanged =
911+ previousConfiguration.systemFontFamily != systemFontFamily;
912+ if (! platformBrightnessChanged && ! textScaleFactorChanged && ! alwaysUse24HourFormatChanged && ! systemFontFamilyChanged) {
890913 return ;
891914 }
892915 _configuration = previousConfiguration.copyWith (
893916 textScaleFactor: textScaleFactor,
894917 alwaysUse24HourFormat: alwaysUse24HourFormat,
895918 platformBrightness: platformBrightness,
919+ systemFontFamily: systemFontFamily,
896920 );
897921 _invoke (onPlatformConfigurationChanged, _onPlatformConfigurationChangedZone);
898922 if (textScaleFactorChanged) {
@@ -901,6 +925,9 @@ class PlatformDispatcher {
901925 if (platformBrightnessChanged) {
902926 _invoke (onPlatformBrightnessChanged, _onPlatformBrightnessChangedZone);
903927 }
928+ if (systemFontFamilyChanged) {
929+ _invoke (onSystemFontFamilyChanged, _onSystemFontFamilyChangedZone);
930+ }
904931 }
905932
906933 /// Whether the user has requested that [updateSemantics] be called when the
@@ -1032,6 +1059,7 @@ class PlatformConfiguration {
10321059 this .textScaleFactor = 1.0 ,
10331060 this .locales = const < Locale > [],
10341061 this .defaultRouteName,
1062+ this .systemFontFamily,
10351063 });
10361064
10371065 /// Copy a [PlatformConfiguration] with some fields replaced.
@@ -1043,6 +1071,7 @@ class PlatformConfiguration {
10431071 double ? textScaleFactor,
10441072 List <Locale >? locales,
10451073 String ? defaultRouteName,
1074+ String ? systemFontFamily,
10461075 }) {
10471076 return PlatformConfiguration (
10481077 accessibilityFeatures: accessibilityFeatures ?? this .accessibilityFeatures,
@@ -1052,6 +1081,7 @@ class PlatformConfiguration {
10521081 textScaleFactor: textScaleFactor ?? this .textScaleFactor,
10531082 locales: locales ?? this .locales,
10541083 defaultRouteName: defaultRouteName ?? this .defaultRouteName,
1084+ systemFontFamily: systemFontFamily ?? this .systemFontFamily,
10551085 );
10561086 }
10571087
@@ -1080,6 +1110,9 @@ class PlatformConfiguration {
10801110 /// The route or path that the embedder requested when the application was
10811111 /// launched.
10821112 final String ? defaultRouteName;
1113+
1114+ /// The system-reported default font family.
1115+ final String ? systemFontFamily;
10831116}
10841117
10851118/// An immutable view configuration.
0 commit comments