From 3fadf1f900d24d5a8045b1e5f8548842aa861c38 Mon Sep 17 00:00:00 2001 From: Ali Ebrahim Date: Wed, 18 Nov 2026 00:13:05 -0800 Subject: [PATCH 1/2] feat(ui_oauth)!: compile provider icons with vector_graphics_compiler The OAuth provider buttons (Google, Apple, Facebook, Twitter) store their icons as inline SVG strings and render them with `flutter_svg` (`SvgPicture.string`). That means every app parses SVG at runtime and ships `flutter_svg` plus the SVG parser it pulls in, even though the icons are known at build time. This PR moves the icons to SVG assets that are compiled into the `vector_graphics` binary format by the `vector_graphics_compiler` asset transformer when the app is built, and renders them with `VectorGraphic`. Compiling at app build time (rather than committing precompiled `.vec` files) keeps the binary output in sync with the `vector_graphics` / codec version resolved by the consuming app. - **firebase_ui_oauth** - Replace the `flutter_svg` dependency with `vector_graphics`. - Add `OAuthProviderIcon`, which loads `iconSrc` from `assetsPackage` via `AssetBytesLoader`. It is used by the button and by `ThemedOAuthProviderButtonStyle.iconWidget`. The `assetsPackage` getter, which was previously unused, now drives icon loading. - Make `assetsPackage` nullable (`String?`). Returning `null` loads icons from the app's own bundle, so custom provider styles defined in an app (rather than in a package) keep working. Subclasses returning `String` still compile. - Document how custom styles should declare their icon assets. - **firebase_ui_oauth_{google,apple,facebook,twitter}** - Move the inline SVG strings to `assets/icons/*.svg`, declared with the `vector_graphics_compiler` transformer, and point `iconSrc` at them. - Add `vector_graphics_compiler` as a regular dependency. Flutter runs the transformer with `dart run` from the consuming app's directory, so it must be resolvable from the app; as a `dev_dependency` the app build fails with "Could not find package `vector_graphics_compiler`". The compiler is not imported by any Dart code, so it is not compiled into apps. - Google: the unused `assets/google_icon.svg` is moved to `assets/icons/google.svg`. - **Tests**: the `firebase_ui_oauth` widget tests now serve icon bytes produced by `encodeSvg` and look for `VectorGraphic` instead of `SvgPicture`. New tests check that `iconWidget` loads icons from `packages//...`, and from the app bundle when `assetsPackage` is `null`. - `melos run analyze` reports no issues in any workspace package. - `melos run test:unit:all` passes: `flutter test` and `flutter test --platform=chrome` in all 7 packages with tests. - A standalone web app (outside the workspace) depending on `firebase_ui_oauth_google` builds with `flutter build web --release` without depending on the compiler itself, and the bundled `google.svg` asset is the compiled binary (828 bytes). - All four providers' icons render correctly in light and dark themes. Note: after switching branches, `flutter test` may reuse stale assets from `build/unit_test_assets`; delete that directory if icons render blank. Fixes https://github.com/firebase/FirebaseUI-Flutter/issues/247 - [ ] I read the Contributor Guide and followed the process outlined there for submitting PRs. - [x] My PR includes unit or integration tests for _all_ changed/updated/fixed behaviors. - [x] All existing and new tests are passing. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] The analyzer (`melos run analyze`) does not report any problems on my PR. - [x] All unit tests pass (`melos run test:unit:all` doesn't fail). - [ ] I read and followed the Flutter Style Guide. - [ ] I signed the CLA. - [ ] I am willing to follow-up on review comments in a timely manner. - [x] Yes, this is a breaking change. - [ ] No, this is _not_ a breaking change. BREAKING CHANGE: `ThemedIconSrc` values returned by `ThemedOAuthProviderButtonStyle.iconSrc` are now asset paths (relative to `assetsPackage`) of SVG assets declared with the `vector_graphics_compiler` asset transformer, instead of raw SVG strings, and `assetsPackage` is now `String?`. Custom OAuth provider styles must move their SVGs to assets and declare them with the transformer. A package declaring the assets must list `vector_graphics_compiler` under `dependencies`; an app declaring them can use `dev_dependencies` and return `null` from `assetsPackage`. --- .../lib/src/oauth_provider_button_base.dart | 10 ++- .../lib/src/oauth_provider_button_style.dart | 66 +++++++++++++-- packages/firebase_ui_oauth/pubspec.yaml | 3 +- .../test/flutterfire_ui_oauth_test.dart | 82 ++++++++++++++----- .../assets/icons/apple_dark.svg | 8 ++ .../assets/icons/apple_light.svg | 8 ++ .../lib/src/theme.dart | 27 +----- packages/firebase_ui_oauth_apple/pubspec.yaml | 41 +++------- .../assets/icons/facebook.svg | 7 ++ .../lib/src/theme.dart | 12 +-- .../firebase_ui_oauth_facebook/pubspec.yaml | 38 ++------- .../{google_icon.svg => icons/google.svg} | 1 - .../lib/src/theme.dart | 20 +---- .../firebase_ui_oauth_google/pubspec.yaml | 7 ++ .../assets/icons/twitter.svg | 8 ++ .../lib/src/theme.dart | 13 +-- .../firebase_ui_oauth_twitter/pubspec.yaml | 38 ++------- 17 files changed, 203 insertions(+), 186 deletions(-) create mode 100644 packages/firebase_ui_oauth_apple/assets/icons/apple_dark.svg create mode 100644 packages/firebase_ui_oauth_apple/assets/icons/apple_light.svg create mode 100644 packages/firebase_ui_oauth_facebook/assets/icons/facebook.svg rename packages/firebase_ui_oauth_google/assets/{google_icon.svg => icons/google.svg} (99%) create mode 100644 packages/firebase_ui_oauth_twitter/assets/icons/twitter.svg diff --git a/packages/firebase_ui_oauth/lib/src/oauth_provider_button_base.dart b/packages/firebase_ui_oauth/lib/src/oauth_provider_button_base.dart index d6fa7460..cc3d1958 100644 --- a/packages/firebase_ui_oauth/lib/src/oauth_provider_button_base.dart +++ b/packages/firebase_ui_oauth/lib/src/oauth_provider_button_base.dart @@ -5,7 +5,6 @@ import 'package:firebase_auth/firebase_auth.dart' as fba; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_svg/flutter_svg.dart'; import 'package:firebase_ui_auth/firebase_ui_auth.dart'; import 'package:firebase_ui_oauth/firebase_ui_oauth.dart'; @@ -361,7 +360,7 @@ class _ButtonContent extends StatelessWidget { final double height; final String iconSrc; final double iconPadding; - final String assetsPackage; + final String? assetsPackage; final String label; final bool isLoading; final Color textColor; @@ -392,7 +391,12 @@ class _ButtonContent extends StatelessWidget { Widget build(BuildContext context) { final icon = Padding( padding: EdgeInsets.all(iconPadding), - child: SvgPicture.string(iconSrc, width: height, height: height), + child: OAuthProviderIcon( + src: iconSrc, + package: assetsPackage, + width: height, + height: height, + ), ); if (label.isEmpty) { diff --git a/packages/firebase_ui_oauth/lib/src/oauth_provider_button_style.dart b/packages/firebase_ui_oauth/lib/src/oauth_provider_button_style.dart index 5ad02f16..82eb47b5 100644 --- a/packages/firebase_ui_oauth/lib/src/oauth_provider_button_style.dart +++ b/packages/firebase_ui_oauth/lib/src/oauth_provider_button_style.dart @@ -4,19 +4,42 @@ import 'package:flutter/material.dart'; import 'package:firebase_ui_shared/firebase_ui_shared.dart'; -import 'package:flutter_svg/svg.dart'; +import 'package:vector_graphics/vector_graphics.dart'; /// {@template ui.oauth.themed_oauth_provider_button_style} /// An object that is being used to resolve a style of the button. /// {@endtemplate} abstract class ThemedOAuthProviderButtonStyle { + /// Asset paths (relative to [assetsPackage]) of the light and dark icons. + /// + /// Icons must be compiled into the `vector_graphics` binary format. Declare + /// the SVG assets with the `vector_graphics_compiler` asset transformer: + /// + /// ```yaml + /// flutter: + /// assets: + /// - path: assets/icon.svg + /// transformers: + /// - package: vector_graphics_compiler + /// ``` + /// + /// When the assets are declared by a package (see [assetsPackage]), that + /// package must list `vector_graphics_compiler` under `dependencies` (not + /// `dev_dependencies`) so that the transformer can be resolved when + /// building the consuming app. When the assets are declared by the app + /// itself, a `dev_dependencies` entry in the app is enough. ThemedIconSrc get iconSrc; ThemedColor get backgroundColor; ThemedColor get color; ThemedColor get iconBackgroundColor => backgroundColor; ThemedColor get borderColor => backgroundColor; double get iconPadding => 0; - String get assetsPackage; + + /// The name of the package that contains the [iconSrc] assets. + /// + /// Return `null` when the assets are bundled with the app itself, for + /// example for a custom provider style defined in the app. + String? get assetsPackage; /// A custom label string. /// @@ -27,9 +50,9 @@ abstract class ThemedOAuthProviderButtonStyle { /// Profile Screen. ThemedValue get iconWidget => ThemedValue( // Display the light icon on a dark background. - SvgPicture.string(iconSrc.light), + OAuthProviderIcon(src: iconSrc.light, package: assetsPackage), // Display the dark icon on a light background. - SvgPicture.string(iconSrc.dark), + OAuthProviderIcon(src: iconSrc.dark, package: assetsPackage), ); /// {@macro ui.oauth.themed_oauth_provider_button_style} @@ -54,7 +77,7 @@ class OAuthProviderButtonStyle { final Color backgroundColor; final Color color; final Color borderColor; - final String assetsPackage; + final String? assetsPackage; final Color iconBackgroundColor; OAuthProviderButtonStyle({ @@ -67,3 +90,36 @@ class OAuthProviderButtonStyle { required this.iconBackgroundColor, }); } + +/// {@template ui.oauth.oauth_provider_icon} +/// Renders an SVG icon asset compiled by the `vector_graphics_compiler` +/// asset transformer. +/// {@endtemplate} +class OAuthProviderIcon extends StatelessWidget { + /// The asset path of the precompiled icon. + final String src; + + /// The package that contains the [src] asset. + final String? package; + + final double? width; + final double? height; + + /// {@macro ui.oauth.oauth_provider_icon} + const OAuthProviderIcon({ + super.key, + required this.src, + this.package, + this.width, + this.height, + }); + + @override + Widget build(BuildContext context) { + return VectorGraphic( + loader: AssetBytesLoader(src, packageName: package), + width: width, + height: height, + ); + } +} diff --git a/packages/firebase_ui_oauth/pubspec.yaml b/packages/firebase_ui_oauth/pubspec.yaml index cccd0c93..b3af3b9d 100644 --- a/packages/firebase_ui_oauth/pubspec.yaml +++ b/packages/firebase_ui_oauth/pubspec.yaml @@ -13,9 +13,9 @@ dependencies: firebase_auth: ^7.0.0 firebase_ui_auth: ^4.0.0 firebase_ui_shared: ^1.5.0 - flutter_svg: ^2.0.9 flutter_web_auth_2: ^5.1.0 http: ^1.6.0 + vector_graphics: ^1.1.19 flutter: sdk: flutter @@ -23,6 +23,7 @@ dev_dependencies: flutter_test: sdk: flutter flutter_lints: ^6.0.0 + vector_graphics_compiler: ^1.1.19 false_secrets: - "/example/**/google-services.json" diff --git a/packages/firebase_ui_oauth/test/flutterfire_ui_oauth_test.dart b/packages/firebase_ui_oauth/test/flutterfire_ui_oauth_test.dart index 55ec8d78..dc4838db 100644 --- a/packages/firebase_ui_oauth/test/flutterfire_ui_oauth_test.dart +++ b/packages/firebase_ui_oauth/test/flutterfire_ui_oauth_test.dart @@ -6,14 +6,22 @@ import 'package:firebase_auth/firebase_auth.dart' as fba; import 'package:firebase_ui_auth/firebase_ui_auth.dart'; import 'package:firebase_ui_oauth/firebase_ui_oauth.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_svg/flutter_svg.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:vector_graphics/vector_graphics.dart'; +import 'package:vector_graphics_compiler/vector_graphics_compiler.dart' + show encodeSvg; class FakeAssetBundle extends Fake implements AssetBundle { final String svgStr = ''''''; + final List loadedKeys = []; @override - Future loadString(String key, {bool cache = true}) async => svgStr; + Future load(String key) async { + loadedKeys.add(key); + final bytes = encodeSvg(xml: svgStr, debugName: key); + return bytes.buffer.asByteData(); + } } // Duplicated from packages/firebase_ui_oauth_google/lib/src/theme.dart @@ -26,24 +34,9 @@ const _backgroundColor = ThemedColor(_googleBlue, _googleWhite); const _color = ThemedColor(_googleWhite, _googleDark); const _iconBackgroundColor = ThemedColor(_googleWhite, _googleWhite); -const _iconSvg = ''' - - - - - - - - - - - - - - -'''; - -const _iconSrc = ThemedIconSrc(_iconSvg, _iconSvg); +const _iconAsset = 'assets/icons/google.svg'; + +const _iconSrc = ThemedIconSrc(_iconAsset, _iconAsset); class GoogleProviderButtonStyle extends ThemedOAuthProviderButtonStyle { const GoogleProviderButtonStyle(); @@ -67,6 +60,24 @@ class GoogleProviderButtonStyle extends ThemedOAuthProviderButtonStyle { String get assetsPackage => 'firebase_ui_oauth_google'; } +/// A custom provider style whose icon is bundled with the app itself. +class AppBundledButtonStyle extends ThemedOAuthProviderButtonStyle { + const AppBundledButtonStyle(); + + @override + ThemedColor get backgroundColor => _backgroundColor; + + @override + ThemedColor get color => _color; + + @override + ThemedIconSrc get iconSrc => + const ThemedIconSrc('assets/app_icon_dark.svg', 'assets/app_icon.svg'); + + @override + String? get assetsPackage => null; +} + class FakeOAuthProvider extends OAuthProvider { @override ProviderArgs get desktopSignInArgs => throw UnimplementedError(); @@ -193,7 +204,7 @@ void main() { await tester.pumpWidget(renderMaterialButton()); final iconFinder = find.byWidgetPredicate( - (widget) => widget is SvgPicture, + (widget) => widget is VectorGraphic, ); expect(iconFinder, findsOneWidget); @@ -225,4 +236,33 @@ void main() { expect(find.byType(LayoutFlowAwarePadding), findsOneWidget); }); }); + + group('ThemedOAuthProviderButtonStyle.iconWidget', () { + Future> pumpIcon(WidgetTester tester, Widget icon) async { + final bundle = FakeAssetBundle(); + await tester.pumpWidget(DefaultAssetBundle(bundle: bundle, child: icon)); + return bundle.loadedKeys; + } + + testWidgets('loads icons from assetsPackage', (tester) async { + final keys = await pumpIcon( + tester, + style.iconWidget.getValue(Brightness.light), + ); + + expect(keys, ['packages/firebase_ui_oauth_google/$_iconAsset']); + }); + + testWidgets('loads icons from the app bundle when assetsPackage is null', ( + tester, + ) async { + const appStyle = AppBundledButtonStyle(); + final keys = await pumpIcon( + tester, + appStyle.iconWidget.getValue(Brightness.light), + ); + + expect(keys, ['assets/app_icon_dark.svg']); + }); + }); } diff --git a/packages/firebase_ui_oauth_apple/assets/icons/apple_dark.svg b/packages/firebase_ui_oauth_apple/assets/icons/apple_dark.svg new file mode 100644 index 00000000..dc70c8d1 --- /dev/null +++ b/packages/firebase_ui_oauth_apple/assets/icons/apple_dark.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/packages/firebase_ui_oauth_apple/assets/icons/apple_light.svg b/packages/firebase_ui_oauth_apple/assets/icons/apple_light.svg new file mode 100644 index 00000000..5083c7f4 --- /dev/null +++ b/packages/firebase_ui_oauth_apple/assets/icons/apple_light.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/packages/firebase_ui_oauth_apple/lib/src/theme.dart b/packages/firebase_ui_oauth_apple/lib/src/theme.dart index 3fcd9f2f..55219478 100644 --- a/packages/firebase_ui_oauth_apple/lib/src/theme.dart +++ b/packages/firebase_ui_oauth_apple/lib/src/theme.dart @@ -11,29 +11,10 @@ const _appleWhite = Color(0xffffffff); const _backgroundColor = ThemedColor(_appleWhite, _appleBlack); const _color = ThemedColor(_appleBlack, _appleWhite); -const _iconSvgLight = ''' - - - - - - - - -'''; - -const _iconSvgDark = ''' - - - - - - - - -'''; - -const _iconSrc = ThemedIconSrc(_iconSvgLight, _iconSvgDark); +const _iconSrc = ThemedIconSrc( + 'assets/icons/apple_light.svg', + 'assets/icons/apple_dark.svg', +); class AppleProviderButtonStyle extends ThemedOAuthProviderButtonStyle { const AppleProviderButtonStyle(); diff --git a/packages/firebase_ui_oauth_apple/pubspec.yaml b/packages/firebase_ui_oauth_apple/pubspec.yaml index f69ecf1d..96dc2fd3 100644 --- a/packages/firebase_ui_oauth_apple/pubspec.yaml +++ b/packages/firebase_ui_oauth_apple/pubspec.yaml @@ -11,6 +11,7 @@ environment: dependencies: firebase_auth: ^7.0.0 firebase_ui_oauth: ^3.0.0 + vector_graphics_compiler: ^1.1.19 flutter: sdk: flutter @@ -29,34 +30,12 @@ false_secrets: # The following section is specific to Flutter packages. flutter: - - # To add assets to your package, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - # - # For details regarding assets in packages, see - # https://flutter.dev/assets-and-images/#from-packages - # - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware - - # To add custom fonts to your package, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts in packages, see - # https://flutter.dev/custom-fonts/#from-packages + # SVG icons are compiled to the vector_graphics binary format at build + # time, so the output always matches the app's resolved codec version. + assets: + - path: assets/icons/apple_light.svg + transformers: + - package: vector_graphics_compiler + - path: assets/icons/apple_dark.svg + transformers: + - package: vector_graphics_compiler diff --git a/packages/firebase_ui_oauth_facebook/assets/icons/facebook.svg b/packages/firebase_ui_oauth_facebook/assets/icons/facebook.svg new file mode 100644 index 00000000..2faee6f3 --- /dev/null +++ b/packages/firebase_ui_oauth_facebook/assets/icons/facebook.svg @@ -0,0 +1,7 @@ + + + f_logo_RGB-White_1024 + + + + diff --git a/packages/firebase_ui_oauth_facebook/lib/src/theme.dart b/packages/firebase_ui_oauth_facebook/lib/src/theme.dart index a7106c63..4381a82d 100644 --- a/packages/firebase_ui_oauth_facebook/lib/src/theme.dart +++ b/packages/firebase_ui_oauth_facebook/lib/src/theme.dart @@ -11,16 +11,8 @@ const _facebookWhite = Color(0xffffffff); const _backgroundColor = ThemedColor(_facebookBlue, _facebookBlue); const _color = ThemedColor(_facebookWhite, _facebookWhite); -const _iconSvg = ''' - - f_logo_RGB-White_1024 - - - - -'''; - -const _iconSrc = ThemedIconSrc(_iconSvg, _iconSvg); +const _iconAsset = 'assets/icons/facebook.svg'; +const _iconSrc = ThemedIconSrc(_iconAsset, _iconAsset); class FacebookProviderButtonStyle extends ThemedOAuthProviderButtonStyle { const FacebookProviderButtonStyle(); diff --git a/packages/firebase_ui_oauth_facebook/pubspec.yaml b/packages/firebase_ui_oauth_facebook/pubspec.yaml index 04f8dc87..6daa870d 100644 --- a/packages/firebase_ui_oauth_facebook/pubspec.yaml +++ b/packages/firebase_ui_oauth_facebook/pubspec.yaml @@ -11,6 +11,7 @@ environment: dependencies: firebase_auth: ^7.0.0 firebase_ui_oauth: ^3.0.0 + vector_graphics_compiler: ^1.1.19 flutter: sdk: flutter flutter_facebook_auth: ^7.1.2 @@ -32,34 +33,9 @@ false_secrets: # The following section is specific to Flutter packages. flutter: - - # To add assets to your package, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - # - # For details regarding assets in packages, see - # https://flutter.dev/assets-and-images/#from-packages - # - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware - - # To add custom fonts to your package, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts in packages, see - # https://flutter.dev/custom-fonts/#from-packages + # SVG icons are compiled to the vector_graphics binary format at build + # time, so the output always matches the app's resolved codec version. + assets: + - path: assets/icons/facebook.svg + transformers: + - package: vector_graphics_compiler diff --git a/packages/firebase_ui_oauth_google/assets/google_icon.svg b/packages/firebase_ui_oauth_google/assets/icons/google.svg similarity index 99% rename from packages/firebase_ui_oauth_google/assets/google_icon.svg rename to packages/firebase_ui_oauth_google/assets/icons/google.svg index 50d9b896..1033f528 100644 --- a/packages/firebase_ui_oauth_google/assets/google_icon.svg +++ b/packages/firebase_ui_oauth_google/assets/icons/google.svg @@ -1,4 +1,3 @@ - diff --git a/packages/firebase_ui_oauth_google/lib/src/theme.dart b/packages/firebase_ui_oauth_google/lib/src/theme.dart index 70be751f..31e7ffe5 100644 --- a/packages/firebase_ui_oauth_google/lib/src/theme.dart +++ b/packages/firebase_ui_oauth_google/lib/src/theme.dart @@ -13,24 +13,8 @@ const _backgroundColor = ThemedColor(_googleBlue, _googleWhite); const _color = ThemedColor(_googleWhite, _googleDark); const _iconBackgroundColor = ThemedColor(_googleWhite, _googleWhite); -const _iconSvg = ''' - - - - - - - - - - - - - - -'''; - -const _iconSrc = ThemedIconSrc(_iconSvg, _iconSvg); +const _iconAsset = 'assets/icons/google.svg'; +const _iconSrc = ThemedIconSrc(_iconAsset, _iconAsset); class GoogleProviderButtonStyle extends ThemedOAuthProviderButtonStyle { const GoogleProviderButtonStyle(); diff --git a/packages/firebase_ui_oauth_google/pubspec.yaml b/packages/firebase_ui_oauth_google/pubspec.yaml index 015a2bba..f52b1ece 100644 --- a/packages/firebase_ui_oauth_google/pubspec.yaml +++ b/packages/firebase_ui_oauth_google/pubspec.yaml @@ -11,6 +11,7 @@ environment: dependencies: firebase_auth: ^7.0.0 firebase_ui_oauth: ^3.0.0 + vector_graphics_compiler: ^1.1.19 flutter: sdk: flutter google_sign_in: ^7.1.0 @@ -26,3 +27,9 @@ false_secrets: - "/example/**/GoogleService-Info.plist" flutter: + # SVG icons are compiled to the vector_graphics binary format at build + # time, so the output always matches the app's resolved codec version. + assets: + - path: assets/icons/google.svg + transformers: + - package: vector_graphics_compiler diff --git a/packages/firebase_ui_oauth_twitter/assets/icons/twitter.svg b/packages/firebase_ui_oauth_twitter/assets/icons/twitter.svg new file mode 100644 index 00000000..72d0f680 --- /dev/null +++ b/packages/firebase_ui_oauth_twitter/assets/icons/twitter.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/packages/firebase_ui_oauth_twitter/lib/src/theme.dart b/packages/firebase_ui_oauth_twitter/lib/src/theme.dart index 08c42879..cb686148 100644 --- a/packages/firebase_ui_oauth_twitter/lib/src/theme.dart +++ b/packages/firebase_ui_oauth_twitter/lib/src/theme.dart @@ -11,17 +11,8 @@ const _twitterWhite = Color(0xffffffff); const _backgroundColor = ThemedColor(_twitterBlue, _twitterBlue); const _color = ThemedColor(_twitterWhite, _twitterWhite); -const _iconSvg = ''' - - - - - - - -'''; - -const _iconSrc = ThemedIconSrc(_iconSvg, _iconSvg); +const _iconAsset = 'assets/icons/twitter.svg'; +const _iconSrc = ThemedIconSrc(_iconAsset, _iconAsset); class TwitterProviderButtonStyle extends ThemedOAuthProviderButtonStyle { const TwitterProviderButtonStyle(); diff --git a/packages/firebase_ui_oauth_twitter/pubspec.yaml b/packages/firebase_ui_oauth_twitter/pubspec.yaml index d4d93ce7..bf9dca07 100644 --- a/packages/firebase_ui_oauth_twitter/pubspec.yaml +++ b/packages/firebase_ui_oauth_twitter/pubspec.yaml @@ -13,6 +13,7 @@ dependencies: sdk: flutter firebase_auth: ^7.0.0 firebase_ui_oauth: ^3.0.0 + vector_graphics_compiler: ^1.1.19 dev_dependencies: flutter_test: @@ -29,34 +30,9 @@ false_secrets: # The following section is specific to Flutter packages. flutter: - - # To add assets to your package, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - # - # For details regarding assets in packages, see - # https://flutter.dev/assets-and-images/#from-packages - # - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware - - # To add custom fonts to your package, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts in packages, see - # https://flutter.dev/custom-fonts/#from-packages + # SVG icons are compiled to the vector_graphics binary format at build + # time, so the output always matches the app's resolved codec version. + assets: + - path: assets/icons/twitter.svg + transformers: + - package: vector_graphics_compiler From cab8160f6f457e60df58090231a0db32b46e96e4 Mon Sep 17 00:00:00 2001 From: Ali Ebrahim Date: Wed, 18 Nov 2026 00:27:55 -0800 Subject: [PATCH 2/2] fix(ui_oauth_apple): use a transparent background for the Apple icon The Apple icon SVGs draw a full-size background rectangle behind the logo: pure black (`#000000`) in `apple_dark.svg` and pure white (`#FFFFFF`) in `apple_light.svg`. The Apple button itself is `#060708` on the dark variant, so a visibly different black square shows behind the logo. The icon also ignores `iconBackgroundColor`, because the rectangle always covers it. This removes the rectangles so the logo is drawn on a transparent background and blends with the button. The logo paths are unchanged. On the white variant there is no visible difference, since the rectangle was white on white. - Rendered the Apple button in the `firebase_ui_oauth` example app on web before and after. The square behind the logo on the black button is gone. - `melos run analyze` and `melos run test:unit:all` pass. Depends on https://github.com/firebase/FirebaseUI-Flutter/pull/752, which moves the Apple icons into `assets/icons/*.svg`. This PR is based on that branch; only the last commit is new. Please merge #752 first. - [x] I read the Contributor Guide and followed the process outlined there for submitting PRs. - [x] My PR includes unit or integration tests for _all_ changed/updated/fixed behaviors. - [x] All existing and new tests are passing. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] The analyzer (`melos run analyze`) does not report any problems on my PR. - [x] All unit tests pass (`melos run test:unit:all` doesn't fail). - [x] I read and followed the Flutter Style Guide. - [x] I signed the CLA. - [s] I am willing to follow-up on review comments in a timely manner. - [ ] Yes, this is a breaking change. - [x] No, this is _not_ a breaking change. --- packages/firebase_ui_oauth_apple/assets/icons/apple_dark.svg | 1 - packages/firebase_ui_oauth_apple/assets/icons/apple_light.svg | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/firebase_ui_oauth_apple/assets/icons/apple_dark.svg b/packages/firebase_ui_oauth_apple/assets/icons/apple_dark.svg index dc70c8d1..b563dada 100644 --- a/packages/firebase_ui_oauth_apple/assets/icons/apple_dark.svg +++ b/packages/firebase_ui_oauth_apple/assets/icons/apple_dark.svg @@ -1,7 +1,6 @@ - diff --git a/packages/firebase_ui_oauth_apple/assets/icons/apple_light.svg b/packages/firebase_ui_oauth_apple/assets/icons/apple_light.svg index 5083c7f4..051f05ce 100644 --- a/packages/firebase_ui_oauth_apple/assets/icons/apple_light.svg +++ b/packages/firebase_ui_oauth_apple/assets/icons/apple_light.svg @@ -1,7 +1,6 @@ -