Skip to content

[google_fonts] Reduce size #184337

Description

@TheCarpetMerchant

Use case

I'm wondering if there is any ongoing work to potentially reduce the size of the google_fonts package. flutter build apk --analyze-size --target-platform=android-arm64 gives me this result :

 lib/
    arm64-v8a                                                              32 MB
    Dart AOT symbols accounted decompressed size                           20 MB
      package:google_fonts                                                  7 MB
      package:flutter                                                       4 MB

7MB is enormous, almost twice the size of the flutter package itself. And I'm not even on the latest google_fonts.

Proposal

Is there an alternative to google_fonts that will only download the font as needed and not include all the code in such files as google_fonts_parts/part_b.dart and google_fonts_all_parts.dart ? We'd have to use the getFont('Font') only which would download as needed. Basically, remove the static data and keep only the dynamic path.

Activity

  1. saurabh-mirajkar commented on Mar 31, 2026

    @saurabh-mirajkar
    Contributor

    @TheCarpetMerchant Thanks for the report!

    This looks like a feature request regarding reducing the bundled size ofgoogle_fonts package.

    To better understand and make this actionable, could you please:

    • Confirm if this occurs on the latest version of google_fonts
    • Provide a minimal reproducible example
    • Clarify how many fonts are being used in your app

    Also, are you observing that unused fonts are not tree-shaken from the final build?

    Thanks!

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    and removed
    in triagePresently being triaged by the triage team
    on Mar 31, 2026
  3. TheCarpetMerchant commented on Apr 2, 2026

    @TheCarpetMerchant
    Author
    * Confirm if this occurs on the latest version of `google_fonts`
    

    Yes, it's worse at 8MB

    * Provide a minimal reproducible example
    

    google_fonts_sample_app
    Clone and run flutter build apk --analyze-size --target-platform=android-arm64

    * Clarify how many fonts are being used in your app
    

    None, users can choose (code uses getFont()). Roboto is used by default but that's shipped with Flutter itself

    Also, are you observing that unused fonts are not tree-shaken from the final build?
    No

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Apr 2, 2026
  5. saurabh-mirajkar commented on Apr 2, 2026

    @saurabh-mirajkar
    Contributor

    @TheCarpetMerchant Thanks for the clarification and providing the details.

    I am able to see the same behavior locally on the latest Flutter stable version 3.41.6. Kindly refer the below result:

    example % flutter build apk --analyze-size --target-platform=android-arm64
    -------
    Font asset "MaterialIcons-Regular.otf" was tree-shaken, reducing it from 1645184 to 1576 bytes (99.9% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
    Running Gradle task 'assembleRelease'...                           18.4s
    ✓ Built build/app/outputs/flutter-apk/app-release.apk (25.2MB)
    ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
    app-release.apk (total compressed)                                         24 MB
    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
      META-INF/
        androidx                                                                3 KB
      assets/
        flutter_assets                                                        370 KB
      classes.dex                                                             233 KB
      lib/
        arm64-v8a                                                              23 MB
        Dart AOT symbols accounted decompressed size                           13 MB
          package:google_fonts                                                  8 MB
          package:flutter                                                       2 MB
          dart:mixin_deduplication                                            255 KB
          dart:core                                                           246 KB
          dart:ui                                                             214 KB
          dart:typed_data                                                     163 KB
          dart:io                                                             121 KB
          dart:async                                                           93 KB
          package:material_color_utilities                                     68 KB
          dart:collection                                                      58 KB
          dart:convert                                                         53 KB
          package:characters                                                   34 KB
          dart:isolate                                                         25 KB
          package:vector_math/
            vector_math_64.dart                                                23 KB
          package:http                                                         11 KB
          dart:ffi                                                             11 KB
          package:crypto                                                        9 KB
          package:google_fonts_tester                                           7 KB
          dart:math                                                             3 KB
          package:path_provider_android                                         3 KB
      kotlin/
        collections                                                             2 KB
        concurrent                                                              1 KB
        kotlin.kotlin_builtins                                                  5 KB
        ranges                                                                  1 KB
        reflect                                                                 1 KB
      AndroidManifest.xml                                                       2 KB
      res/
        o-.png                                                                  1 KB
      resources.arsc                                                           10 KB
    ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
    A summary of your APK analysis can be found at: /Users/admin/.flutter-devtools/apk-code-size-analysis_02.json
    
    To analyze your app size in Dart DevTools, run the following command:
    dart devtools --appSizeBase=/Users/admin/.flutter-devtools/apk-code-size-analysis_02.json

    Labelling this to team-framework to investigate further.

  6. added
    c: new featureNothing broken; request for a new capability
    frameworkflutter/packages/flutter repository. See also f: labels.
    packageflutter/packages repository. See also p: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    p: google_fontsPackage to use fonts from fonts.google.com. Supports HTTP fetching, caching, and asset bundling.
    and removed
    in triagePresently being triaged by the triage team
    on Apr 2, 2026
  7. added
    P2Important issues not at the top of the work list
    on Apr 7, 2026
  8. added
    team-designOwned by Design Languages team
    triaged-designTriaged by Design Languages team
    and removed
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Aug 26, 2026
  9. Piinks commented on Sep 24, 2026

    @Piinks
    Contributor

    I think this was resolve in the new Lite features in google_fonts, let us know if that is not the case!

  10. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Sep 24, 2026
  11. TheCarpetMerchant commented on Sep 28, 2026

    @TheCarpetMerchant
    Author

    Forgot I had opened an issue for this, closed

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: new featureNothing broken; request for a new capabilityhas reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: google_fontsPackage to use fonts from fonts.google.com. Supports HTTP fetching, caching, and asset bundling.packageflutter/packages repository. See also p: labels.team-designOwned by Design Languages teamtriaged-designTriaged by Design Languages teamwaiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions