Skip to content

Title jumps during a CupertinoNavigationBar -> CupertinoNavigationBar hero transition #90589

@henry2man

Description

@henry2man

August 2024 update:


Steps to Reproduce

This issue is very similar to #45068 but it differs in one thing: I can reproduce similar text jumps with non default text Scale when the transition is done between two pages both using CupertinoSliverNavigationBar (in #45068 was a CupertinoSliverNavigationBar -> CupertinoNavigationBar and, in my tests, this issue is not present in the current SDK)

I'm using latest Flutter stable 2.5.1 and iOS 15. The issue is present both on simulator and physical devices.

Steps to reproduce the issue:

  1. Run flutter create bug.
  2. Update the main.dart file as follows:
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';

void main() {
  return runApp(const MainApp());
}

class MainApp extends StatelessWidget {
  const MainApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return const CupertinoApp(
      home: InitPage(),
    );
  }
}

class InitPage extends StatelessWidget {
  const InitPage({
    Key? key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    double textScale = MediaQuery.of(context).textScaleFactor;
    return CupertinoPageScaffold(
        child: CustomScrollView(slivers: [
      CupertinoSliverNavigationBar(
        largeTitle: Text("${textScale == 1.0 ? "Good" : "BUGGY"} header"),
      ),
      SliverFillRemaining(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text(
              "Actual Scale: $textScale",
              style: const TextStyle(fontSize: 30),
            ),
            const Padding(padding: EdgeInsets.only(bottom: 20)),
            CupertinoButton(
                child: const Text("Push page >"),
                color: CupertinoColors.systemRed,
                onPressed: () => Navigator.push(
                    context,
                    CupertinoPageRoute(
                        builder: (context) => const SliverBugHeader(),
                        settings: const RouteSettings(name: "Title")))),
          ],
        ),
      ),
    ]));
  }
}

class SliverBugHeader extends StatelessWidget {
  const SliverBugHeader({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    double textScale = MediaQuery.of(context).textScaleFactor;
    return CupertinoPageScaffold(
      child: CustomScrollView(
        slivers: [
          CupertinoSliverNavigationBar(
            trailing: CupertinoButton(
              child: const Text("Top right"),
              padding: EdgeInsets.zero,
              onPressed: () {},
            ),
            largeTitle: Text("${textScale == 1.0 ? "Good" : "BUGGY"} header"),
          ),
          SliverFillRemaining(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Text(
                  "Actual Scale: $textScale",
                  style: const TextStyle(fontSize: 30),
                ),
                const Padding(padding: EdgeInsets.only(bottom: 20)),
                CupertinoButton(
                    child: const Text("Push new page >"),
                    color: CupertinoColors.systemRed,
                    onPressed: () => Navigator.push(
                          context,
                          CupertinoPageRoute(
                              builder: (context) => const SliverBugHeader(),
                              settings: const RouteSettings(name: "Title")),
                        )),
                CupertinoButton(
                    child: const Text("< Pop page"),
                    color: CupertinoColors.systemBlue,
                    onPressed: () => Navigator.pop(context)),
              ],
            ),
          )
        ],
      ),
    );
  }
}
  1. Navigate with default text scale (1.0) between pages. The header should be fine. Then change the text scale (using ⌥⌘+ and ⌥⌘- on iOS simulator or control center shortcuts on physical devices)
  2. Then navigate again between pages. The issue will be reproduced.

Expected results: Clear transitions like the ones that we're having with default scale.

Actual results: Unexpected text jumps in header elements font size when the transition is going to end.

Simulator Screen Recording - iPhone 13 - 2021-09-23 at 11 59 41

Logs

N/A

[✓] Flutter (Channel stable, 2.5.1, on macOS 11.5.2 20G95 darwin-arm, locale
    es-ES)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.60.1)
[✓] Connected device (3 available)

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: animationAnimation APIsa: fidelityMatching the OEM platforms bettera: qualityA truly polished experiencea: typographyText rendering, possibly libtxtf: cupertinoflutter/packages/flutter/cupertino repositoryf: routesNavigator, Router, and related APIs.found in release: 2.5Found to occur in 2.5found in release: 2.6Found to occur in 2.6frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions