Skip to content

CupertinoNavigationBar flickers when previousPageTitle more than 4 characters #149905

@jonmountjoy

Description

@jonmountjoy

Also related to #90589

Steps to reproduce

You can see it clearly if you run this code on dartpad:

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 const CupertinoApp(
        home: MyHomePage(title: "Home", backButtonText: ""));
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage(
      {super.key, required this.title, required this.backButtonText});

  final String title;
  final String backButtonText;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return CupertinoPageScaffold(
      navigationBar: CupertinoNavigationBar(
        previousPageTitle: widget.backButtonText,
        // automaticallyImplyLeading: true,
        middle: Text(widget.title),
        trailing: const Row(
          mainAxisSize: MainAxisSize.min,
          children: [],
        ),
      ),
      child: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            ElevatedButton(
              child: const Text("Go"),
              onPressed: () {
                Navigator.of(context).push(CupertinoPageRoute(
                    builder: (c) => MyHomePage(
                          title: "Oh dear",
                          backButtonText: "${widget.backButtonText}Back",
                        )));
              },
            ),
          ],
        ),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

Expected results

I don't expect it to flicker

Actual results

Screen.Recording.2024-06-07.at.16.58.50.mov

Code sample

Code sample
[Paste your code here]

Screenshots or Video

Screenshots / Video demonstration
Screen.Recording.2024-06-07.at.16.58.50.mov

Logs

Logs
[Paste your logs here]

Flutter Doctor output

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listf: cupertinoflutter/packages/flutter/cupertino repositoryf: routesNavigator, Router, and related APIs.found in release: 3.22Found to occur in 3.22found in release: 3.23Found to occur in 3.23frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: 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