Skip to content

Refactor/use geist from google fonts#591

Open
nank1ro wants to merge 10 commits intomainfrom
refactor/use-geist-from-google-fonts
Open

Refactor/use geist from google fonts#591
nank1ro wants to merge 10 commits intomainfrom
refactor/use-geist-from-google-fonts

Conversation

@nank1ro
Copy link
Owner

@nank1ro nank1ro commented Jan 21, 2026

Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.

List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.

Testing this PR

To try this branch, add the following to your pubspec.yaml:

shadcn_ui:
    git:
      url: https://github.com/nank1ro/flutter-shadcn-ui
      ref: refactor/use-geist-from-google-fonts

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read and followed the Flutter Style Guide.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making.
  • I followed the Data Driven Fixes where supported.
  • All existing and new tests are passing.
  • I bumped the package version following the Semantic Versioning guidelines (For now the major is the second number and the minor the third, because the package is not feature complete). For example, if the package is at version 0.18.0 and you introduced a breaking change or a new feature, bump it to 0.19.0, if you just added a fix or a chore bump it to 0.18.1.
  • I updated the CHANGELOG.md file with a summary of changes made following the format already used.

If you need help, consider asking for advice on Discord.

Summary by CodeRabbit

  • New Features

    • Integrated Google Fonts support and exposed font utilities in the public API.
  • Documentation

    • Added a docs entry for the google_fonts package and updated the changelog with migration notes.
  • Chores

    • Switched from bundled Geist/GeistMono assets to runtime font loading; version bumped and packaging ignore updated.
  • Tests

    • Added test config to use bundled fonts during tests (disables runtime fetching).
  • Breaking Changes

    • Runtime font fetching is now the default; offline bundling and SDK constraints noted.

✏️ Tip: You can customize this high-level summary in your review settings.

@nank1ro nank1ro requested a review from 9dan January 21, 2026 16:44
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 21, 2026

Walkthrough

Migrates font handling to the google_fonts package: adds dependency and re-exports it, switches default text styles to GoogleFonts.geist/geistMono, makes theme family nullable and updates theme factories/propagation, updates components and example to use Google Fonts, adds test config to disable runtime fetching in tests, and updates docs/changelog/pubspec.

Changes

Cohort / File(s) Summary
Package manifest & assets
pubspec.yaml, example/pubspec.yaml, .pubignore
Bumped package to 0.44.0, added google_fonts: ^7.1.0, moved font asset paths to test/fonts/, added uses-material-design: true, registered UbuntuMono in example pubspec, and added test/fonts to .pubignore.
Public API exports
lib/shadcn_ui.dart
Re-exported package:google_fonts/google_fonts.dart from the library public surface.
Core text styles
lib/src/theme/text_theme/text_styles_default.dart
Removed per-method family params; style builders now call GoogleFonts.geist(...) directly, use .fallback(...), and kDefaultFontFamily set to 'Geist'. Public method signatures changed to no longer accept family.
Theme implementation
lib/src/theme/text_theme/theme.dart
family made nullable; googleFontBuilder defaulted to GoogleFonts.geist; constructors/factory/copyWith/merge/apply updated to compute and propagate nullable fontFamily appropriately and to handle GoogleFontTextStyle copyWith(fontFamily: ...).
Default theme variants
lib/src/theme/themes/.../default_theme_variant.dart, .../default_theme_no_secondary_border_variant.dart
Stopped passing explicit family into default text theme constructors; input OTP style now uses GoogleFonts.geistMono() merged with muted styles and color override.
Components
lib/src/components/input_otp.dart
Imported google_fonts and replaced mono/default slot styles to use GoogleFonts.geistMono() merged with theme muted style and color override; removed old inline style docs.
Example & docs
example/lib/pages/typography.dart, docs/src/content/docs/packages.md
Example: myCustomStyle getter changed to nullable TextStyle?; Docs: added google_fonts package entry under Packages.
Tests & test config
test/flutter_test_config.dart
Added test helper testExecutable to initialize bindings and disable runtime font fetching (GoogleFonts.config.allowRuntimeFetching = false) so bundled fonts are used in tests.
Changelog
CHANGELOG.md
Added 0.44.0 entry documenting breaking change: removal of bundled Geist/GeistMono and migration to runtime google_fonts usage; bumped Dart SDK minimum note.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant App
participant ShadTextTheme
participant GoogleFonts
participant FontsServer
App->>ShadTextTheme: request TextStyle (theme lookup)
ShadTextTheme->>GoogleFonts: call googleFontBuilder (e.g., GoogleFonts.geist)
alt runtime fetching allowed
GoogleFonts->>FontsServer: request font assets
FontsServer-->>GoogleFonts: font bytes
GoogleFonts-->>ShadTextTheme: TextStyle with fetched fontFamily
else runtime fetching disabled / bundled
GoogleFonts-->>ShadTextTheme: TextStyle using bundled font family or fallback
end
ShadTextTheme-->>App: resolved TextStyle

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 I swapped my bundled coats for clouds of type,
Geist and Mono fetched and hopping through the night.
I nibble bytes of fonts, sew styles just right,
A joyful hop of code — the UI feels light! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description contains only placeholder template text and does not provide substantive information about the changes, rationale, or issues being fixed despite listing required checklist items. Replace the placeholder paragraph with a clear description of what is being changed (removing bundled Geist fonts, switching to google_fonts package) and why, then list at least one issue being fixed.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'Refactor/use geist from google fonts' accurately reflects the main change: refactoring the codebase to use the Geist font from Google Fonts instead of bundled assets.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 21, 2026

Deploying shadcn-ui-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 972b853
Status: ✅  Deploy successful!
Preview URL: https://d3c0fce5.flutter-shadcn-ui.pages.dev
Branch Preview URL: https://refactor-use-geist-from-goog.flutter-shadcn-ui.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 21, 2026

Deploying shadcn-ui-playground with  Cloudflare Pages  Cloudflare Pages

Latest commit: e852a1e
Status: ✅  Deploy successful!
Preview URL: https://50b60137.shadcn-ui-playground.pages.dev
Branch Preview URL: https://refactor-use-geist-from-goog.shadcn-ui-playground.pages.dev

View logs

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Fix all issues with AI agents
In `@docs/src/content/docs/packages.md`:
- Around line 35-38: Change the package entry heading "## [google_fonts](...)"
to a level-3 heading (prefix with ###) so it matches the other package entries,
and fix the description sentence by capitalizing "Google" in "fonts.google.com"
(e.g., "any of the fonts from fonts.google.com" → "any of the fonts from Google
Fonts (fonts.google.com)" or at minimum capitalize "Google"). Ensure you update
the heading token "## [google_fonts]" and the description line that mentions
"fonts.google.com".

In `@example/lib/pages/typography.dart`:
- Line 10: The getter myCustomStyle currently returns a nullable TextStyle?
(TextStyle? get myCustomStyle => custom['myCustomStyle'];) but is used without
null-check in the Text widget; change the getter to return a non-nullable
TextStyle by force-unwrapping the map value (TextStyle get myCustomStyle =>
custom['myCustomStyle']!;) so callers like
ShadTheme.of(context).textTheme.myCustomStyle can pass it directly to
Text(style: ...) without nullable handling.

In `@lib/src/theme/text_theme/theme.dart`:
- Around line 200-210: The code currently prefixes package even when family is
null, producing 'packages/<pkg>/null'; modify the logic around effectiveFamily
and package so prefixing only happens when a non-null, non-empty family is
present: keep the existing googleFontBuilder nullification (googleFontBuilder,
family) but change the package prefix block to check effectiveFamily != null &&
effectiveFamily != '' (or equivalent) before setting effectiveFamily =
'packages/$package/$effectiveFamily'; reference symbols: googleFontBuilder,
family, package, effectiveFamily.

In `@pubspec.yaml`:
- Line 26: Update the Dart SDK constraint in the pubspec environment to match
google_fonts 7.1.0 requirements: locate the environment sdk entry (currently
allowing ">=3.8.0") and change it to enforce ">=3.9.0 <4.0.0" so the project
Dart SDK minimum meets google_fonts 7.1.0's requirement; ensure the env block's
sdk string is updated accordingly.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @.pubignore:
- Line 11: Remove the entry "test/fonts" from .pubignore or alternatively remove
the matching asset and font declarations from pubspec.yaml (the flutter.assets
and flutter.fonts sections) so published packages don’t reference assets that
are excluded; specifically either delete "test/fonts" from .pubignore to ensure
the font files declared in pubspec.yaml are included in the package, or remove
the test font asset lines under flutter.assets and the corresponding
flutter.fonts entries in pubspec.yaml so no missing-asset references remain.
♻️ Duplicate comments (2)
pubspec.yaml (1)

26-26: Align Dart SDK constraint with google_fonts requirements.

If google_fonts ^7.1.0 requires Dart ≥ 3.9, the current sdk: ">=3.8.0 <4.0.0" allows unsupported versions and will fail pub resolution for users on 3.8.x. Please confirm the dependency’s SDK constraint and bump the project’s minimum Dart version if needed.

🔧 Proposed fix (if google_fonts requires Dart ≥ 3.9)
 environment:
-  sdk: ">=3.8.0 <4.0.0"
+  sdk: ">=3.9.0 <4.0.0"
   flutter: ">=3.35.0"
google_fonts 7.1.0 pubspec environment sdk constraint
lib/src/theme/text_theme/theme.dart (1)

203-209: Avoid prefixing package when family is null.

effectiveFamily != '' is true when effectiveFamily is null, which yields packages/<pkg>/null. Guard against null or empty before prefixing.

🐛 Proposed fix
-    if (package != null && effectiveFamily != '') {
+    if (package != null &&
+        package.isNotEmpty &&
+        (effectiveFamily?.isNotEmpty ?? false)) {
       effectiveFamily = 'packages/$package/$effectiveFamily';
     }
🧹 Nitpick comments (1)
lib/src/theme/text_theme/theme.dart (1)

258-287: Apply fontFamily to p style for consistency.

All other styles copy the resolved fontFamily, but p doesn’t. If the default p style has no weight/style, it may keep a null family. Consider applying the same copyWith as the others.

♻️ Suggested tweak
-    final p = GoogleFontTextStyle(
+    final p = GoogleFontTextStyle(
       effectiveTextTheme.p.omitFamilyAndPackage,
       builder: fontBuilder,
-    );
+    ).copyWith(fontFamily: fontFamily);

web
linux
fonts.zip
test/fonts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Find and display pubspec.yaml content
find . -name "pubspec.yaml" -type f | head -5

Repository: nank1ro/flutter-shadcn-ui

Length of output: 151


🏁 Script executed:

# Also check .pubignore file
find . -name ".pubignore" -type f

Repository: nank1ro/flutter-shadcn-ui

Length of output: 81


🏁 Script executed:

cat -n ./pubspec.yaml

Repository: nank1ro/flutter-shadcn-ui

Length of output: 3149


🏁 Script executed:

cat -n ./.pubignore

Repository: nank1ro/flutter-shadcn-ui

Length of output: 220


Don't ignore assets that are declared in pubspec.yaml.

test/fonts is listed under flutter.assets and the font files are declared in flutter.fonts in pubspec.yaml (lines 45-87). Adding it to .pubignore will exclude these font files from the published package, but the font declarations will remain. This causes missing-asset failures for consumers at runtime.

Either keep the fonts in the published package or remove both the asset declarations and font definitions from pubspec.yaml if they're only for internal testing.

💡 Proposed fix (keep fonts published)
- test/fonts
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test/fonts
🤖 Prompt for AI Agents
In @.pubignore at line 11, Remove the entry "test/fonts" from .pubignore or
alternatively remove the matching asset and font declarations from pubspec.yaml
(the flutter.assets and flutter.fonts sections) so published packages don’t
reference assets that are excluded; specifically either delete "test/fonts" from
.pubignore to ensure the font files declared in pubspec.yaml are included in the
package, or remove the test font asset lines under flutter.assets and the
corresponding flutter.fonts entries in pubspec.yaml so no missing-asset
references remain.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@pubspec.yaml`:
- Around line 47-87: pubspec.yaml currently declares font families "Geist" and
"GeistMono" with assets under test/fonts/, which are excluded from publication
and will point to missing files in published packages; remove the entire fonts
block for the "Geist" and "GeistMono" declarations (the entries under fonts:
referencing test/fonts/*) so published packages no longer reference non-existent
assets, or alternatively stop excluding test/fonts in .pubignore if you
intentionally want to publish them (recommended: delete the font family
declarations).

Comment on lines 47 to 87
fonts:
- family: Geist
fonts:
- asset: fonts/Geist-Thin.otf
- asset: test/fonts/Geist-Thin.otf
weight: 100
- asset: fonts/Geist-UltraLight.otf
- asset: test/fonts/Geist-UltraLight.otf
weight: 200
- asset: fonts/Geist-Light.otf
- asset: test/fonts/Geist-Light.otf
weight: 300
- asset: fonts/Geist-Regular.otf
- asset: test/fonts/Geist-Regular.otf
weight: 400
- asset: fonts/Geist-Medium.otf
- asset: test/fonts/Geist-Medium.otf
weight: 500
- asset: fonts/Geist-SemiBold.otf
- asset: test/fonts/Geist-SemiBold.otf
weight: 600
- asset: fonts/Geist-Bold.otf
- asset: test/fonts/Geist-Bold.otf
weight: 700
- asset: fonts/Geist-Black.otf
- asset: test/fonts/Geist-Black.otf
weight: 800
- asset: fonts/Geist-UltraBlack.otf
- asset: test/fonts/Geist-UltraBlack.otf
weight: 900
- family: GeistMono
fonts:
- asset: fonts/GeistMono-Thin.otf
- asset: test/fonts/GeistMono-Thin.otf
weight: 100
- asset: fonts/GeistMono-UltraLight.otf
- asset: test/fonts/GeistMono-UltraLight.otf
weight: 200
- asset: fonts/GeistMono-Light.otf
- asset: test/fonts/GeistMono-Light.otf
weight: 300
- asset: fonts/GeistMono-Regular.otf
- asset: test/fonts/GeistMono-Regular.otf
weight: 400
- asset: fonts/GeistMono-Medium.otf
- asset: test/fonts/GeistMono-Medium.otf
weight: 500
- asset: fonts/GeistMono-SemiBold.otf
- asset: test/fonts/GeistMono-SemiBold.otf
weight: 600
- asset: fonts/GeistMono-Bold.otf
- asset: test/fonts/GeistMono-Bold.otf
weight: 700
- asset: fonts/GeistMono-Black.otf
- asset: test/fonts/GeistMono-Black.otf
weight: 800
- asset: fonts/GeistMono-UltraBlack.otf
- asset: test/fonts/GeistMono-UltraBlack.otf
weight: 900
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if .pubignore exists and whether test/ is excluded
echo "=== Checking .pubignore ==="
if [ -f ".pubignore" ]; then
  cat .pubignore
else
  echo ".pubignore not found"
fi

echo ""
echo "=== Checking .gitignore for test/ exclusion ==="
if [ -f ".gitignore" ]; then
  grep -E "^test/?|test/" .gitignore || echo "test/ not excluded in .gitignore"
else
  echo ".gitignore not found"
fi

echo ""
echo "=== Checking if font files exist in test/fonts/ ==="
if [ -d "test/fonts" ]; then
  echo "test/fonts/ directory exists"
  find test/fonts -type f \( -name "*.otf" -o -name "*.ttf" \) | wc -l | xargs echo "Font file count:"
  find test/fonts -type f \( -name "*.otf" -o -name "*.ttf" \) | head -5
else
  echo "test/fonts/ directory does not exist"
fi

echo ""
echo "=== Checking pubspec.yaml structure ==="
head -50 pubspec.yaml

Repository: nank1ro/flutter-shadcn-ui

Length of output: 1761


Remove font declarations from pubspec.yaml or keep test/fonts in published package.

The test/fonts/ directory is already excluded from pub.dev publication via .pubignore, but pubspec.yaml still declares these fonts with assets pointing to test/fonts/. This creates a mismatch: published packages will have font declarations referencing non-existent files, potentially causing Flutter warnings during initialization.

Since production uses GoogleFonts.geist() for runtime fetching, the bundled fonts in pubspec.yaml (lines 47–87) are only needed for tests. Either:

  • Recommended: Remove the font family declarations from pubspec.yaml (they're unnecessary for published packages), or
  • Remove test/fonts from .pubignore if the fonts should be included in the published package (not recommended due to ~1–2MB added size).
🤖 Prompt for AI Agents
In `@pubspec.yaml` around lines 47 - 87, pubspec.yaml currently declares font
families "Geist" and "GeistMono" with assets under test/fonts/, which are
excluded from publication and will point to missing files in published packages;
remove the entire fonts block for the "Geist" and "GeistMono" declarations (the
entries under fonts: referencing test/fonts/*) so published packages no longer
reference non-existent assets, or alternatively stop excluding test/fonts in
.pubignore if you intentionally want to publish them (recommended: delete the
font family declarations).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants