Skip to content

Failed assertion in widgets library apparently caused by tooltip: RenderBox was not laid out #169126

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

Closed
zetches opened this issue May 20, 2025 · 2 comments
Labels
r: fixed Issue is closed as already fixed in a newer version

Comments

@zetches
Copy link

zetches commented May 20, 2025

Hi. I have encountered a failed assertion error, and the error message asked me to file a bug report. I searched around a bit but couldn't find an obvious duplicate, hence this issue. (Edit: on some more searching, it may be a duplicate of #167722 ?)

════════ Exception caught by widgets library ═══════════════════════════════════
The following assertion was thrown building Builder(dirty):
RenderBox was not laid out: RenderFractionalTranslation#167c0 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 2251 pos 12: 'hasSize'

Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.yml

The relevant error-causing widget was:
    IconButton IconButton:file:///Users/zetches/Documents/test_flutter/my_flutter_app/lib/main.dart:47:36

When the exception was thrown, this was the stack:
#2      RenderBox.size (package:flutter/src/rendering/box.dart:2251:12)
box.dart:2251
#3      RenderFractionalTranslation.applyPaintTransform (package:flutter/src/rendering/proxy_box.dart:2974:42)
proxy_box.dart:2974
#4      RenderObject.getTransformTo (package:flutter/src/rendering/object.dart:3520:25)
object.dart:3520
#5      RenderBox.localToGlobal (package:flutter/src/rendering/box.dart:3082:39)
box.dart:3082
#6      TooltipState._buildTooltipOverlay (package:flutter/src/material/tooltip.dart:793:31)
tooltip.dart:793
#7      Builder.build (package:flutter/src/widgets/basic.dart:7818:48)
basic.dart:7818
#8      StatelessElement.build (package:flutter/src/widgets/framework.dart:5799:49)
framework.dart:5799
#9      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5733:15)
framework.dart:5733
#10     Element.rebuild (package:flutter/src/widgets/framework.dart:5445:7)
framework.dart:5445
#11     StatelessElement.update (package:flutter/src/widgets/framework.dart:5805:5)
framework.dart:5805
#12     Element.updateChild (package:flutter/src/widgets/framework.dart:3998:15)
framework.dart:3998
#13     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:7034:14)
framework.dart:7034
#14     Element.updateChild (package:flutter/src/widgets/framework.dart:3998:15)

Here's some minimal code that will reproduce it on my setup quite consistently:

import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

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

  @override
  Widget build(BuildContext context) => MaterialApp(
        title: 'Dialog push bug',
        home: const HomePage(),
      );
}

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

  @override
  Widget build(BuildContext context) => Scaffold(
        appBar: AppBar(title: const Text('Home')),
        body: Center(
          child: ElevatedButton(
            onPressed: () => _openPicker(context),
            child: const Text('Open picker'),
          ),
        ),
      );

  void _openPicker(BuildContext context) {
    showDialog(
      context: context,
      builder: (ctx) {
        String? selected = 'a';
        return StatefulBuilder(
          builder: (ctx, setState) => AlertDialog(
            title: const Text('Choose library'),
            content: ListTileTheme(
              dense: true,
              child: Column(
                mainAxisSize: MainAxisSize.min,
                children: [
                  RadioListTile<String>(
                    value: 'a',
                    groupValue: selected,
                    title: const Text('Custom list A'),
                    onChanged: (v) => setState(() => selected = v),
                    secondary: IconButton(
                      icon: const Icon(Icons.edit),
                      tooltip: 'Edit', // NOTE: removing this line seems to fix it
                      onPressed: () {
                        Navigator.pop(ctx);         
                        Navigator.push(ctx, MaterialPageRoute(
                          builder: (_) => const DummyPage(),
                        ));                             
                      },
                    ),
                  ),
                ],
              ),
            ),
          ),
        );
      },
    );
  }
}

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

  @override
  Widget build(BuildContext context) => Scaffold(
        appBar: AppBar(title: const Text('Edit page')),
        body: const Center(child: Text('Hello')),
      );
}

To reproduce, run the above code, tap “Open picker”, and in the dialog, click or double-click the pencil icon next to the only list item. The assertion error is thrown relatively often when the icon is single-clicked. It happens almost every time if you double-click the icon.

I worked around it by removing the tooltip (as I noticed the occurrence of "tooltip" in the stack trace, so figured that might have something to do with it). That appears to fix it, so it is not blocking me.

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.29.2, on macOS 15.4.1 24E263 darwin-arm64, locale en-US)
(...)

Hope this helps!

@tirth-patel-nc tirth-patel-nc added the in triage Presently being triaged by the triage team label May 20, 2025
@tirth-patel-nc
Copy link
Member

Triage Report

I was able to reproduce the issue on iOS using the provided code sample with the stable (3.29.3) channel.

However, I could not reproduce it on the master (3.33.0-1.0.pre.138) channel.

It works as expected on Android, macOS, and Web.

@zetches, this does appear to be a duplicate of #167722. Could you please confirm if the issue is resolved on the latest master?

Master Stable
Simulator.Screen.Recording.-.iPhone.16.Plus.-.2025-05-20.at.18.06.51.mp4
Simulator.Screen.Recording.-.iPhone.16.Plus.-.2025-05-20.at.18.24.33.mp4
Code Sample (Same as OP)
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

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

  @override
  Widget build(BuildContext context) =>
      MaterialApp(title: 'Dialog push bug', home: const HomePage());
}

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

  @override
  Widget build(BuildContext context) => Scaffold(
    appBar: AppBar(title: const Text('Home')),
    body: Center(
      child: ElevatedButton(
        onPressed: () => _openPicker(context),
        child: const Text('Open picker'),
      ),
    ),
  );

  void _openPicker(BuildContext context) {
    showDialog(
      context: context,
      builder: (ctx) {
        String? selected = 'a';
        return StatefulBuilder(
          builder:
              (ctx, setState) => AlertDialog(
                title: const Text('Choose library'),
                content: ListTileTheme(
                  dense: true,
                  child: Column(
                    mainAxisSize: MainAxisSize.min,
                    children: [
                      RadioListTile<String>(
                        value: 'a',
                        groupValue: selected,
                        title: const Text('Custom list A'),
                        onChanged: (v) => setState(() => selected = v),
                        secondary: IconButton(
                          icon: const Icon(Icons.edit),
                          tooltip:
                              'Edit', // NOTE: removing this line seems to fix it
                          onPressed: () {
                            Navigator.pop(ctx);
                            Navigator.push(
                              ctx,
                              MaterialPageRoute(
                                builder: (_) => const DummyPage(),
                              ),
                            );
                          },
                        ),
                      ),
                    ],
                  ),
                ),
              ),
        );
      },
    );
  }
}

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

  @override
  Widget build(BuildContext context) => Scaffold(
    appBar: AppBar(title: const Text('Edit page')),
    body: const Center(child: Text('Hello')),
  );
}
stable (3.29.3) - flutter doctor -v
[✓] Flutter (Channel stable, 3.29.3, on macOS 15.4.1 24E263 darwin-arm64, locale
    en-IN) [970ms]
    • Flutter version 3.29.3 on channel stable at
      /Users/tirthpatel/Development/flutter_stable/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ea121f8859 (4 weeks ago), 2025-04-11 19:10:07 +0000
    • Engine revision cf56914b32
    • Dart version 3.7.2
    • DevTools version 2.42.3

[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0)
    [855ms]
    • Android SDK at /Users/tirthpatel/Library/Android/sdk
    • Platform android-36, build-tools 36.0.0
    • Java binary at: /Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on
      this machine.
      To manually set the JDK path, use: `flutter config
      --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13355223-b631.42)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.3) [556ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16E140
    • CocoaPods version 1.16.2

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

[✓] Android Studio (version 2024.3) [9ms]
    • 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 21.0.6+-13355223-b631.42)

[✓] VS Code (version 1.99.3) [8ms]
    • 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) [5.5s]
    • macOS (desktop)                 • macos                 • darwin-arm64   •
      macOS 15.4.1 24E263 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         •
      macOS 15.4.1 24E263 darwin-arm64
    • Chrome (web)                    • chrome                • web-javascript •
      Google Chrome 135.0.7049.115

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

• No issues found!
master (3.33.0-1.0.pre.138) - flutter doctor -v
[✓] Flutter (Channel master, 3.33.0-1.0.pre.138, on macOS 15.4.1 24E263 darwin-arm64, locale en-IN) [1,546ms]
    • Flutter version 3.33.0-1.0.pre.138 on channel master at /Users/tirthpatel/Development/flutter_master/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 35f337ecb4 (4 hours ago), 2025-05-19 17:50:19 -0700
    • Engine revision 35f337ecb4
    • Dart version 3.9.0 (build 3.9.0-138.0.dev)
    • DevTools version 2.46.0

[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [803ms]
    • Android SDK at /Users/tirthpatel/Library/Android/sdk
    • Emulator version 35.4.9.0 (build_id 13025442) (CL:N/A)
    • Platform android-36, build-tools 36.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13355223-b631.42)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.3) [469ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16E140
    • CocoaPods version 1.16.2

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

[✓] Android Studio (version 2024.3) [7ms]
    • 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 21.0.6+-13355223-b631.42)

[✓] VS Code (version 1.100.2) [6ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.110.0

[✓] Connected device (2 available) [5.6s]
    • macOS (desktop) • macos  • darwin-arm64   • macOS 15.4.1 24E263 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 136.0.7103.114

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

• No issues found!

@tirth-patel-nc tirth-patel-nc added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label May 20, 2025
@zetches
Copy link
Author

zetches commented May 20, 2025

I tested on master now and I couldn't reproduce either. So it seems to be fixed, thanks!

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label May 20, 2025
@tirth-patel-nc tirth-patel-nc added r: fixed Issue is closed as already fixed in a newer version and removed in triage Presently being triaged by the triage team labels May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
r: fixed Issue is closed as already fixed in a newer version
Projects
None yet
Development

No branches or pull requests

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy