flutter-packages icon indicating copy to clipboard operation
flutter-packages copied to clipboard

IntrinsicHeight not working with GoogleFonts

Open Ortes opened this issue 9 months ago • 1 comments

Package

google_fonts

Existing issue?

What happened?

Expected vs actual result:

The IntrinsicHeight should be calculated with the real font character width (and recalculated when the font is loaded for example)

The actual result is this, for some sizes the text overflows: Image

Steps to reproduce:

Copy and paste the following code in a 3.24.5 project Edit: also present in 3.29.2

main.dart
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';

void main() {
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({super.key});

@override
Widget build(BuildContext context) {
  return const MaterialApp(home: ThreeTilesScreen());
}
}

class ThreeTilesScreen extends StatelessWidget {
const ThreeTilesScreen({super.key});

@override
Widget build(BuildContext context) {
  return const Scaffold(
    body: Center(
      child: IntrinsicHeight(
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            Expanded(
              child: _DomainShortcutCard(
                title: 'Title 1',
                subtitle: 'Some long subtitle that is very long and should wrap',
              ),
            ),
            SizedBox(width: 16),
            Expanded(
              child: _DomainShortcutCard(
                title: 'Title 2',
                subtitle: 'Some long subtitle that is very long and should wrap, but it is even longer than the first one',
              ),
            ),
          ],
        ),
      ),
    ),
  );
}
}

class _DomainShortcutCard extends StatelessWidget {
const _DomainShortcutCard({
  required this.title,
  required this.subtitle,
});

final String title;
final String subtitle;

@override
Widget build(BuildContext context) {
  return Container(
    decoration: BoxDecoration(
      border: Border.all(color: Colors.black),
    ),
    child: Column(
      children: [
        Text(title),
        const SizedBox(height: 12),
        Text(
          subtitle,
          style: TextStyle(fontFamily: GoogleFonts.albertSans().fontFamily),
        ),
      ],
    ),
  );
}
}

flutter doctor:

flutter doctor -v ``` [!] Flutter (Channel [user-branch], 3.24.5, on macOS 15.3.1 24D70 darwin-arm64, locale en-US) ! Flutter version 3.24.5 on channel [user-branch] at /Users/ortes/flutter Currently on an unknown channel. Run `flutter channel` to switch to an official channel. If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/setup. ! Upstream repository unknown source is not a standard remote. Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error. • Framework revision dec2ee5c1f (4 months ago), 2024-11-13 11:13:06 -0800 • Engine revision a18df97ca5 • Dart version 3.5.4 • DevTools version 2.37.3 • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[!] Android toolchain - develop for Android devices (Android SDK version 35.0.1) • Android SDK at /Users/ortes/Library/Android/sdk ✗ cmdline-tools component is missing Run path/to/sdkmanager --install "cmdline-tools;latest" See https://developer.android.com/studio/command-line for more details. ✗ Android license status unknown. Run flutter doctor --android-licenses to accept the SDK licenses. See https://flutter.dev/to/macos-android-setup for more details.

[!] Xcode - develop for iOS and macOS (Xcode 16.2) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 16C5032a ✗ CocoaPods not installed. CocoaPods is a package manager for iOS or macOS platform code. Without CocoaPods, plugins will not work on iOS or macOS. For more info, see https://flutter.dev/to/platform-plugins For installation instructions, see https://guides.cocoapods.org/using/getting-started.html#installation

[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.2) • Android Studio at /Users/ortes/Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)

[✓] VS Code (version 1.97.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension can be installed from: 🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available) • macOS (desktop) • macos • darwin-arm64 • macOS 15.3.1 24D70 darwin-arm64 • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 15.3.1 24D70 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 133.0.6943.142

[✓] Network resources • All expected network resources are available.

! Doctor found issues in 3 categories.

</details>

### Relevant log output

```shell
[!] Flutter (Channel [user-branch], 3.24.5, on macOS 15.3.1 24D70 darwin-arm64, locale en-US)
    ! Flutter version 3.24.5 on channel [user-branch] at /Users/ortes/flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/setup.
    ! Upstream repository unknown source is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
    • Framework revision dec2ee5c1f (4 months ago), 2024-11-13 11:13:06 -0800
    • Engine revision a18df97ca5
    • Dart version 3.5.4
    • DevTools version 2.37.3
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[!] Android toolchain - develop for Android devices (Android SDK version 35.0.1)
    • Android SDK at /Users/ortes/Library/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/to/macos-android-setup for more details.

[!] Xcode - develop for iOS and macOS (Xcode 16.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16C5032a
    ✗ CocoaPods not installed.
        CocoaPods is a package manager for iOS or macOS platform code.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/to/platform-plugins
      For installation instructions, see https://guides.cocoapods.org/using/getting-started.html#installation

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.2)
    • Android Studio at /Users/ortes/Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)

[✓] VS Code (version 1.97.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available)
    • macOS (desktop)                 • macos                 • darwin-arm64   • macOS 15.3.1 24D70 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         • macOS 15.3.1 24D70 darwin-arm64
    • Chrome (web)                    • chrome                • web-javascript • Google Chrome 133.0.6943.142

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 3 categories.

Ortes avatar Mar 05 '25 09:03 Ortes