From 6ee0230df9d382c6701eb292e7649c1c21e66c11 Mon Sep 17 00:00:00 2001 From: koukibadr Date: Tue, 11 Aug 2026 11:18:38 +0300 Subject: [PATCH 1/2] feat: setup google font support to update app theme --- example/lib/main.dart | 2 +- lib/flutter_skin.dart | 21 ++++++++++++++++++--- lib/models/skin_model.dart | 3 +++ pubspec.yaml | 1 + 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index b8d124c..c5e1ef2 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -6,7 +6,7 @@ void main() async { WidgetsFlutterBinding.ensureInitialized(); await FlutterSkin.init( apiKey: - "fsk_dc0054468a27dde1671142669f2065f93870975bbb773f1af0ab5898797956db", + "fsk_b0ce429cfbded17bbca66eef6e68bd1f0b7fbf9d74be0c3a0ac8b2e0554b7919", ); runApp(const MyApp()); } diff --git a/lib/flutter_skin.dart b/lib/flutter_skin.dart index bb988c4..0c55ba0 100644 --- a/lib/flutter_skin.dart +++ b/lib/flutter_skin.dart @@ -5,6 +5,7 @@ import 'package:flutter_skin/models/project_config.dart'; import 'package:flutter_skin/remote/fskin_remote_config.dart'; import 'package:flutter_skin/services/fskin_logger.dart'; import 'package:flutter_skin/services/fskin_subscriber.dart'; +import 'package:google_fonts/google_fonts.dart'; class FlutterSkin with WidgetsBindingObserver { static FlutterSkin? _instance; @@ -88,13 +89,27 @@ class FlutterSkin with WidgetsBindingObserver { /// Query current active theme from remote config and return as ThemeData. /// When there's no active theme, the result is null or fallbackTheme if provided. - static ThemeData? toThemeData({ThemeData? fallbackTheme}) { + static ThemeData? toThemeData({ + ThemeData? fallbackTheme, + String? fallbackFont, + }) { ProjectConfig? config = remoteConfig.projectConfig; ColorScheme? colors = config?.skin?.colors; - String? fontFamily = config?.skin?.fontFamily; + + String? fontFamily = (config?.skin?.fontFamily?.isEmpty == true) + ? null + : config?.skin?.fontFamily; + String? googleFont = config?.skin?.googleFont?.isEmpty == true + ? null + : config?.skin?.googleFont; + ThemeData remoteTheme = ThemeData( colorScheme: colors, - fontFamily: fontFamily, + fontFamily: + fontFamily ?? + GoogleFonts.getFont( + googleFont ?? fallbackFont ?? 'Roboto', + ).fontFamily, ); if (colors == null) { if (fallbackTheme != null) { diff --git a/lib/models/skin_model.dart b/lib/models/skin_model.dart index 6dae097..d086ec1 100644 --- a/lib/models/skin_model.dart +++ b/lib/models/skin_model.dart @@ -11,6 +11,7 @@ class SkinModel { final DateTime? deletedAt; final ColorScheme? colors; final String? fontFamily; + final String? googleFont; SkinModel({ required this.id, @@ -20,6 +21,7 @@ class SkinModel { required this.createdAt, required this.colors, this.fontFamily, + this.googleFont, this.publishedAt, this.deletedAt, }); @@ -45,6 +47,7 @@ class SkinModel { ? fromSchemaString(tokens)?.colors : null, fontFamily: map['font'] as String?, + googleFont: map['googleFont'] as String?, ); } diff --git a/pubspec.yaml b/pubspec.yaml index c68c1e2..c2a8195 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,6 +15,7 @@ dependencies: flutter: sdk: flutter http: ^1.6.0 + google_fonts: ^8.2.1 dev_dependencies: flutter_test: From 952e317c523742e54b31654b4a6908d4a875d81f Mon Sep 17 00:00:00 2001 From: koukibadr Date: Tue, 11 Aug 2026 11:29:19 +0300 Subject: [PATCH 2/2] chore: setup fallback font usage --- lib/flutter_skin.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/flutter_skin.dart b/lib/flutter_skin.dart index 0c55ba0..a360089 100644 --- a/lib/flutter_skin.dart +++ b/lib/flutter_skin.dart @@ -107,9 +107,9 @@ class FlutterSkin with WidgetsBindingObserver { colorScheme: colors, fontFamily: fontFamily ?? - GoogleFonts.getFont( - googleFont ?? fallbackFont ?? 'Roboto', - ).fontFamily, + (googleFont != null + ? GoogleFonts.getFont(googleFont).fontFamily + : fallbackFont ?? 'Roboto'), ); if (colors == null) { if (fallbackTheme != null) {