fix: clarify widget rebuild counts require debug mode - #9985
fix: clarify widget rebuild counts require debug mode#9985enesbugrahankilic wants to merge 1 commit into
Conversation
|
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. |
There was a problem hiding this comment.
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.
| 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(); | ||
| }, | ||
| ); | ||
| }, | ||
| ), |
There was a problem hiding this comment.
[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
- Avoid unnecessary widget nesting and use idiomatic Dart collection-if/else for cleaner widget structure. (link)
|
Signed the Google CLA — please re-check when convenient. |
4396edc to
a68a2c6
Compare
|
Updated Google Individual CLA with eneskilicresmi@gmail.com and GitHub username enesbugrahankilic — please re-check. |
|
I signed it! |
3d7e4cc to
b1f1521
Compare
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
b1f1521 to
042bf57
Compare
Summary
Fixes #9730
Test plan