Skip to content

fix: clarify widget rebuild counts require debug mode - #9985

Open
enesbugrahankilic wants to merge 1 commit into
flutter:masterfrom
enesbugrahankilic:fix/rebuild-counts-debug-mode-only
Open

fix: clarify widget rebuild counts require debug mode#9985
enesbugrahankilic wants to merge 1 commit into
flutter:masterfrom
enesbugrahankilic:fix/rebuild-counts-debug-mode-only

Conversation

@enesbugrahankilic

@enesbugrahankilic enesbugrahankilic commented Aug 30, 2026

Copy link
Copy Markdown

Summary

  • When the app is in profile mode (or the rebuild-count service extension is unavailable), the frame analysis pane no longer shows a disabled Count widget builds checkbox
  • Shows: "Rebuild information not available for this frame. Widget rebuild counts are only available when running an app in debug-mode."

Fixes #9730

Test plan

  • Run a Flutter app in profile mode, open DevTools Performance → select a frame → confirm debug-mode-only message (no disabled checkbox)
  • Run in debug mode with Count widget builds off → confirm enable checkbox still appears
  • Enable Count widget builds in debug → confirm rebuild table / empty-state messages still work

@google-cla

google-cla Bot commented Aug 30, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the Flutter frame analysis view to handle profile builds and unavailable service extensions by displaying an informative message instead of a disabled checkbox. The review feedback suggests removing the unnecessary Builder widget and instead using Dart's collection-if/else directly in the widget list to reduce nesting and improve readability.

Comment on lines +94 to 152
Builder(
builder: (context) {
final isProfileBuild =
serviceConnection
.serviceManager
.connectedApp
?.isProfileBuildNow ??
false;
final rebuildCountsAvailable = serviceConnection
.serviceManager
.serviceExtensionManager
.isServiceExtensionAvailable(
extensions.countWidgetBuilds.extension,
);

// Widget rebuild counts rely on debug-only service extensions.
// Avoid showing a disabled checkbox in profile mode.
if (isProfileBuild || !rebuildCountsAvailable) {
return const Text(
'Rebuild information not available for this frame. Widget '
'rebuild counts are only available when running an app in '
'debug-mode.',
);
}
return const SizedBox();

return ValueListenableBuilder<ServiceExtensionState>(
valueListenable: serviceConnection
.serviceManager
.serviceExtensionManager
.getServiceExtensionState(
extensions.countWidgetBuilds.extension,
),
builder: (context, extensionState, _) {
if (!extensionState.enabled) {
return Row(
children: [
const Text(
'To see widget rebuilds for Flutter frames, enable',
),
Flexible(
child: ServiceExtensionCheckbox(
serviceExtension: extensions.countWidgetBuilds,
showDescription: false,
),
),
],
);
}
// Extension is on, but this frame still has no rebuild data.
if (rebuilds == null) {
return const Text(
'Rebuild information not available for this frame.',
);
}
return const SizedBox();
},
);
},
),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

[CONCERN] The Builder widget here is unnecessary and introduces extra nesting and closure allocations. We can use Dart's collection-if/else support directly within the widget list by inlining the conditions, which makes the code cleaner and more idiomatic.

            if ((serviceConnection.serviceManager.connectedApp?.isProfileBuildNow ?? false) ||
                !serviceConnection.serviceManager.serviceExtensionManager
                    .isServiceExtensionAvailable(
                  extensions.countWidgetBuilds.extension,
                ))
              const Text(
                'Rebuild information not available for this frame. Widget '
                'rebuild counts are only available when running an app in '
                'debug-mode.',
              )
            else
              ValueListenableBuilder<ServiceExtensionState>(
                valueListenable: serviceConnection
                    .serviceManager
                    .serviceExtensionManager
                    .getServiceExtensionState(
                      extensions.countWidgetBuilds.extension,
                    ),
                builder: (context, extensionState, _) {
                  if (!extensionState.enabled) {
                    return Row(
                      children: [
                        const Text(
                          'To see widget rebuilds for Flutter frames, enable',
                        ),
                        Flexible(
                          child: ServiceExtensionCheckbox(
                            serviceExtension: extensions.countWidgetBuilds,
                            showDescription: false,
                          ),
                        ),
                      ],
                    );
                  }
                  // Extension is on, but this frame still has no rebuild data.
                  if (rebuilds == null) {
                    return const Text(
                      'Rebuild information not available for this frame.',
                    );
                  }
                  return const SizedBox();
                },
              ),
References
  1. Avoid unnecessary widget nesting and use idiomatic Dart collection-if/else for cleaner widget structure. (link)

@enesbugrahankilic

Copy link
Copy Markdown
Author

Signed the Google CLA — please re-check when convenient.

@enesbugrahankilic
enesbugrahankilic force-pushed the fix/rebuild-counts-debug-mode-only branch from 4396edc to a68a2c6 Compare August 31, 2026 06:09
@enesbugrahankilic

Copy link
Copy Markdown
Author

Updated Google Individual CLA with eneskilicresmi@gmail.com and GitHub username enesbugrahankilic — please re-check.

@enesbugrahankilic

Copy link
Copy Markdown
Author

I signed it!

@enesbugrahankilic
enesbugrahankilic force-pushed the fix/rebuild-counts-debug-mode-only branch from 3d7e4cc to b1f1521 Compare August 31, 2026 06:32
In profile mode, stop showing a disabled Count widget builds checkbox
and explain that rebuild counts are only available in debug mode.

Fixes flutter#9730
@enesbugrahankilic
enesbugrahankilic force-pushed the fix/rebuild-counts-debug-mode-only branch from b1f1521 to 042bf57 Compare August 31, 2026 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Specify that widget rebuilds is only available when running in debug-mode

1 participant