Skip to content
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

Bubble and reset #2751

Merged
merged 8 commits into from
Feb 28, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions packages/devtools_app/lib/src/memory/memory_heap_tree_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -676,8 +676,6 @@ class HeapTreeViewState extends State<HeapTree>
Timer removeUpdateBubble;

Widget displayTimestampUpdateBubble() {
final themeData = Theme.of(context);

// Build the bubble to show data has changed (new allocation data).
final bubble = AnimatedBuilder(
animation: _animation,
Expand All @@ -701,7 +699,7 @@ class HeapTreeViewState extends State<HeapTree>
controller.monitorTimestamp == null
? 'No allocations tracked'
: 'Allocations Tracked at ${MemoryController.formattedTimestamp(controller.monitorTimestamp)}',
style: themeData.colorScheme.italicTextStyle,
style: Theme.of(context).colorScheme.italicTextStyle,
size: controller.lastMonitorTimestamp.value ==
controller.monitorTimestamp
? 0
Expand Down Expand Up @@ -786,11 +784,16 @@ class HeapTreeViewState extends State<HeapTree>
);
}

static const maxWidth = 800.0;

double textWidgetWidth(String message, {TextStyle style}) {
// self-defined constraint
// Longest message must fit in this width.
const constraints = BoxConstraints(
maxWidth: 800.0, // maxwidth calculated
maxWidth: maxWidth,
);

// TODO(terry): Is there a better (less heavyweight) way of computing text
// width then using the widget pipeline?
terrylucas marked this conversation as resolved.
Show resolved Hide resolved
final richTextWidget = Text.rich(TextSpan(text: message), style: style)
.build(context) as RichText;
final renderObject = richTextWidget.createRenderObject(context);
terrylucas marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -800,7 +803,19 @@ class HeapTreeViewState extends State<HeapTree>
baseOffset: 0,
extentOffset: TextSpan(text: message).toPlainText().length),
);
return boxes.last.right;

final textWidth = boxes.last.right;

if (textWidth > maxWidth) {
// TODO(terry): If message > 800 pixels in width (not possible
// today) but could be more robust.
logger.log(
'Computed text width > $maxWidth ($textWidth)\nmessage=$message.',
logger.LogLevel.warning,
);
}

return textWidth;
}

// WARNING: Do not checkin the debug flag set to true.
Expand Down