@@ -732,6 +732,26 @@ class PlatformDispatcher {
732732 _onPlatformBrightnessChangedZone = Zone .current;
733733 }
734734
735+ /// The setting indicating the current system font of the host platform.
736+ String ? get systemFontFamily => configuration.systemFontFamily;
737+
738+ /// A callback that is invoked whenever [systemFontFamily] changes value.
739+ ///
740+ /// The framework invokes this callback in the same zone in which the callback
741+ /// was set.
742+ ///
743+ /// See also:
744+ ///
745+ /// * [WidgetsBindingObserver] , for a mechanism at the widgets layer to
746+ /// observe when this callback is invoked.
747+ VoidCallback ? get onSystemFontFamilyChanged => _onSystemFontFamilyChanged;
748+ VoidCallback ? _onSystemFontFamilyChanged;
749+ Zone _onSystemFontFamilyChangedZone = Zone .root;
750+ set onSystemFontFamilyChanged (VoidCallback ? callback) {
751+ _onSystemFontFamilyChanged = callback;
752+ _onSystemFontFamilyChangedZone = Zone .current;
753+ }
754+
735755 // Called from the engine, via hooks.dart
736756 void _updateUserSettingsData (String jsonData) {
737757 final Map <String , dynamic > data = json.decode (jsonData) as Map <String , dynamic >;
@@ -743,19 +763,23 @@ class PlatformDispatcher {
743763 final bool alwaysUse24HourFormat = data['alwaysUse24HourFormat' ] as bool ;
744764 final Brightness platformBrightness =
745765 data['platformBrightness' ] as String == 'dark' ? Brightness .dark : Brightness .light;
766+ final String ? systemFontFamily = data['systemFontFamily' ] as String ? ;
746767 final PlatformConfiguration previousConfiguration = configuration;
747768 final bool platformBrightnessChanged =
748769 previousConfiguration.platformBrightness != platformBrightness;
749770 final bool textScaleFactorChanged = previousConfiguration.textScaleFactor != textScaleFactor;
750771 final bool alwaysUse24HourFormatChanged =
751772 previousConfiguration.alwaysUse24HourFormat != alwaysUse24HourFormat;
752- if (! platformBrightnessChanged && ! textScaleFactorChanged && ! alwaysUse24HourFormatChanged) {
773+ final bool systemFontFamilyChanged =
774+ previousConfiguration.systemFontFamily != systemFontFamily;
775+ if (! platformBrightnessChanged && ! textScaleFactorChanged && ! alwaysUse24HourFormatChanged && ! systemFontFamilyChanged) {
753776 return ;
754777 }
755778 _configuration = previousConfiguration.copyWith (
756779 textScaleFactor: textScaleFactor,
757780 alwaysUse24HourFormat: alwaysUse24HourFormat,
758781 platformBrightness: platformBrightness,
782+ systemFontFamily: systemFontFamily,
759783 );
760784 _invoke (onPlatformConfigurationChanged, _onPlatformConfigurationChangedZone);
761785 if (textScaleFactorChanged) {
@@ -764,6 +788,9 @@ class PlatformDispatcher {
764788 if (platformBrightnessChanged) {
765789 _invoke (onPlatformBrightnessChanged, _onPlatformBrightnessChangedZone);
766790 }
791+ if (systemFontFamilyChanged) {
792+ _invoke (onSystemFontFamilyChanged, _onSystemFontFamilyChangedZone);
793+ }
767794 }
768795
769796 /// Whether the user has requested that [updateSemantics] be called when the
@@ -872,6 +899,7 @@ class PlatformConfiguration {
872899 this .textScaleFactor = 1.0 ,
873900 this .locales = const < Locale > [],
874901 this .defaultRouteName,
902+ this .systemFontFamily,
875903 });
876904
877905 /// Copy a [PlatformConfiguration] with some fields replaced.
@@ -883,6 +911,7 @@ class PlatformConfiguration {
883911 double ? textScaleFactor,
884912 List <Locale >? locales,
885913 String ? defaultRouteName,
914+ String ? systemFontFamily,
886915 }) {
887916 return PlatformConfiguration (
888917 accessibilityFeatures: accessibilityFeatures ?? this .accessibilityFeatures,
@@ -892,6 +921,7 @@ class PlatformConfiguration {
892921 textScaleFactor: textScaleFactor ?? this .textScaleFactor,
893922 locales: locales ?? this .locales,
894923 defaultRouteName: defaultRouteName ?? this .defaultRouteName,
924+ systemFontFamily: systemFontFamily ?? this .systemFontFamily,
895925 );
896926 }
897927
@@ -920,6 +950,9 @@ class PlatformConfiguration {
920950 /// The route or path that the embedder requested when the application was
921951 /// launched.
922952 final String ? defaultRouteName;
953+
954+ /// The system-reported default font family.
955+ final String ? systemFontFamily;
923956}
924957
925958/// An immutable view configuration.
0 commit comments