Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thai Text inside SliverAppBar in CupertinoApp is bigger than normal. #155373

Closed
PutawanDE opened this issue Sep 18, 2024 · 3 comments
Closed

Thai Text inside SliverAppBar in CupertinoApp is bigger than normal. #155373

PutawanDE opened this issue Sep 18, 2024 · 3 comments
Labels
in triage Presently being triaged by the triage team waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds

Comments

@PutawanDE
Copy link

Steps to reproduce

  1. I was implementing SliverAppBar with dynamic height. I wrapped my text widget inside SliverToBoxAdapter first to measure its height and use this height in expandedHeight property of SliverAppBar.
  2. I noticed that the SliverAppBar's FlexibleSpaceBar is always overflowed on iOS.
  3. I compared the widgets in SliverAppBar and SliverToBoxAdapter and notice the text's size and letter spacing is not the same. I checked and confirmed through the inspector.
  4. On iOS app the top-level widget is CupertinoApp with MediaQuery text scaler set to 1.0. And I also use CupertinoPageScaffold.
  5. The text works as expected on Android with MaterialApp and Scaffold.

Tested on iPhone 15 emulator, iOS 17.5

Expected results

  • Should display text size and letter spacing consistently.

Actual results

  • Text's size and letter-spacing in SliverAppBar is bigger than normal.

Code sample

Code sample
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return CupertinoApp(
      debugShowCheckedModeBanner: false,
      localizationsDelegates: const [
        DefaultMaterialLocalizations.delegate,
        DefaultCupertinoLocalizations.delegate,
        DefaultWidgetsLocalizations.delegate,
      ],
      builder: (context, child) {
        return MediaQuery(
          data: MediaQuery.of(context)
              .copyWith(textScaler: const TextScaler.linear(1.0)),
          child: const CupertinoPageScaffold(
            backgroundColor: Colors.black,
            child: SafeArea(
              child: CustomScrollView(
                slivers: [
                  WxSliverAppBar(child: Header()),
                  SliverPadding(
                      padding: EdgeInsets.all(16),
                      sliver: SliverToBoxAdapter(
                          child: Divider(color: Colors.white))),
                  SliverToBoxAdapter(child: Header()),
                  SliverPadding(
                      padding: EdgeInsets.all(16),
                      sliver: SliverToBoxAdapter(
                          child: Divider(color: Colors.white))),
                  SliverToBoxAdapter(child: Header()),
                ],
              ),
            ),
          ),
        );
      },
    );
  }
}

class WxSliverAppBar extends StatefulWidget {
  const WxSliverAppBar({
    super.key,
    required this.child,
  });

  final Widget child;

  @override
  State<WxSliverAppBar> createState() => _WxSliverAppBarState();
}

class _WxSliverAppBarState extends State<WxSliverAppBar> {
  final _childKey = GlobalKey();
  double _height = 0;

  @override
  void initState() {
    super.initState();
    _updateHeight();
  }

  void _updateHeight() {
    WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
      if (_childKey.currentContext == null) return;
      setState(() {
        _height = (_childKey.currentContext!.findRenderObject()! as RenderBox)
            .size
            .height;
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    if (_height == 0) {
      return SliverToBoxAdapter(
        child: Container(key: _childKey, child: const Header()),
      );
    } else {
      return SliverAppBar(
        expandedHeight: _height,
        primary: false,
        backgroundColor: Colors.transparent,
        flexibleSpace: LayoutBuilder(
          builder: (context, constraints) {
            return const FlexibleSpaceBar(
              background: Header(),
            );
          },
        ),
      );
    }
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Container(
          height: 145,
          decoration: const BoxDecoration(
            borderRadius: BorderRadius.only(
              topLeft: Radius.circular(24),
              topRight: Radius.circular(24),
            ),
            image: DecorationImage(
              image: NetworkImage(
                  'https://live.staticflickr.com/65535/17123251389_80282733ce_z.jpg'),
              fit: BoxFit.cover,
            ),
          ),
        ),
        Padding(
          padding: const EdgeInsets.only(left: 24, right: 24, top: 16),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: [
              const Text(
                'Top Returns กองทุนรวมติดชาร์ต',
                style: TextStyle(
                  fontSize: 24,
                  color: Colors.white,
                ),
              ),
              Text(
                '• ข้อมูล ณ ${DateTime.now()}',
                style: const TextStyle(
                  fontSize: 12,
                  color: Colors.white,
                ),
              ),
              const SizedBox(height: 16),
              const Text(
                'โอกาสเข้าลงทุนหุ้น Healthcare ในจังหวะราคาปรับฐาน แนะนำเน้นกลุ่ม High Quality Growth ที่มีกระแสเงินสดแข็งแกร่ง โอกาสเข้าลงทุนหุ้น Healthcare ในจังหวะราคาปรับฐาน แนะนำเน้นกลุ่ม High Quality Growth ที่มีกระแสเงินสดแข็งแกร่ง โอกาสเข้าลงทุนหุ้น Healthcare ในจังหวะราคาปรับฐาน แนะนำเน้นกลุ่ม High Quality Growth ที่มีกระแสเงินสดแข็งแกร่ง โอกาสเข้าลงทุนหุ้น Healthcare ในจังหวะราคาปรับฐาน แนะนำเน้นกลุ่ม High Quality Growth ที่มีกระแสเงินสดแข็งแกร่ง โอกาสเข้าลงทุนหุ้น Healthcare ในจังหวะราคาปรับฐาน แนะนำเน้นกลุ่ม High Quality Growth ที่มีกระแสเงินสดแข็งแกร่ง โอกาสเข้าลงทุนหุ้น Healthcare ในจังหวะราคาปรับฐาน แนะนำเน้นกลุ่ม High Quality Growth ที่มีกระแสเงินสดแข็งแกร่ง โอกาสเข้าลงทุนหุ้น Healthcare ในจังหวะราคาปรับฐาน แนะนำเน้นกลุ่ม High Quality Growth ที่มีกระแสเงินสดแข็งแกร่ง',
                style: TextStyle(
                  fontSize: 12,
                  color: Colors.white,
                ),
              ),
            ],
          ),
        ),
      ],
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]
Simulator Screenshot - iPhone 15 - 2024-09-19 at 01 17 39

Simulator Screenshot - iPhone 15 - 2024-09-19 at 01 18 29

The top one is SliverAppBar, the bottom is SliverToBoxAdapter. Notice the different line length.

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.22.2, on macOS 14.5 23F79 darwin-x64, locale en-TH)
    • Flutter version 3.22.2 on channel stable at
      /Users/tanadoldeachprapakorn/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 761747bfc5 (4 months ago), 2024-06-05 22:15:13 +0200
    • Engine revision edd8546116
    • Dart version 3.4.3
    • DevTools version 2.34.3

[!] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at /Users/tanadoldeachprapakorn/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/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

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

[✓] Android Studio (version 2024.1)
    • Android Studio at /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 17.0.10+0-17.0.10b1087.21-11609105)

[✓] VS Code (version 1.92.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.94.0

[✓] Connected device (4 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554                        • android-x64    •
      Android 15 (API 35) (emulator)
    • iPhone 15 (mobile)           • 0F70456F-322D-4DBA-83C8-ECECA894273A • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-17-5 (simulator)
    • macOS (desktop)              • macos                                • darwin-x64     •
      macOS 14.5 23F79 darwin-x64
    • Chrome (web)                 • chrome                               • web-javascript •
      Google Chrome 128.0.6613.138

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

! Doctor found issues in 1 category.
@darshankawar darshankawar added the in triage Presently being triaged by the triage team label Sep 19, 2024
@darshankawar
Copy link
Member

Thanks for the report @PutawanDE
Are you saying that the text displayed as shown below is rendered bigger than normal ?

Screenshot 2024-09-19 at 1 31 27 PM

Can you provide us expected behavior wherein the text size should be normal unlike what we are seeing now ?

Maybe it could be related to #52526. Specificially, the root-cause could be #52526 (comment)

@darshankawar darshankawar added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 19, 2024
Copy link

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now.
If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones.
Thanks for your contribution.

Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
in triage Presently being triaged by the triage team waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds
Projects
None yet
Development

No branches or pull requests

2 participants