Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion packages/devtools_app/lib/src/flutter/controllers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Controllers extends StatefulWidget {

static ProvidedControllers of(BuildContext context) {
final _InheritedProvider inherited =
context.inheritFromWidgetOfExactType(_InheritedProvider);
context.dependOnInheritedWidgetOfExactType(aspect: _InheritedProvider);
return inherited.data;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import 'package:flutter/widgets.dart';
import '../../utils.dart';
import '../diagnostics_node.dart';
import '../enum_utils.dart';
import '../inspector_tree.dart';
import 'story_of_your_layout/utils.dart';

const Type boxConstraintsType = BoxConstraints;
Expand Down Expand Up @@ -95,19 +94,19 @@ List<double> computeRenderSizes({
// TODO(albertusangga): Move this to [RemoteDiagnosticsNode] once dart:html app is removed
class LayoutProperties {
LayoutProperties(this.node, {int copyLevel = 1})
: description = node.diagnostic?.description,
size = deserializeSize(node.diagnostic?.size),
constraints = deserializeConstraints(node.diagnostic?.constraints),
isFlex = node.diagnostic?.isFlex,
flexFactor = node.diagnostic?.flexFactor,
: description = node?.description,
size = deserializeSize(node?.size),
constraints = deserializeConstraints(node?.constraints),
isFlex = node?.isFlex,
flexFactor = node?.flexFactor,
children = copyLevel == 0
? []
: node.children
: node?.childrenNow
?.map((child) =>
LayoutProperties(child, copyLevel: copyLevel - 1))
?.toList(growable: false);

final InspectorTreeNode node;
final RemoteDiagnosticsNode node;
final List<LayoutProperties> children;
final BoxConstraints constraints;
final String description;
Expand Down Expand Up @@ -178,7 +177,7 @@ final Expando<FlexLayoutProperties> _flexLayoutExpando = Expando();
/// TODO(albertusangga): Move this to [RemoteDiagnosticsNode] once dart:html app is removed
class FlexLayoutProperties extends LayoutProperties {
FlexLayoutProperties._(
InspectorTreeNode node, {
RemoteDiagnosticsNode node, {
Comment thread
albertusdev marked this conversation as resolved.
this.direction,
this.mainAxisAlignment,
this.mainAxisSize,
Expand All @@ -188,16 +187,15 @@ class FlexLayoutProperties extends LayoutProperties {
this.textBaseline,
}) : super(node);

factory FlexLayoutProperties.fromNode(InspectorTreeNode node) {
factory FlexLayoutProperties.fromDiagnostics(RemoteDiagnosticsNode node) {
// Cache the properties on an expando so that local tweaks to
// FlexLayoutProperties persist across multiple lookups from an
// InspectorTreeNode.
// RemoteDiagnosticsNode.
return _flexLayoutExpando[node] ??= _buildNode(node);
}

static FlexLayoutProperties _buildNode(InspectorTreeNode node) {
final Map<String, Object> renderObjectJson =
node.diagnostic.json['renderObject'];
static FlexLayoutProperties _buildNode(RemoteDiagnosticsNode node) {
final Map<String, Object> renderObjectJson = node.json['renderObject'];
final List<dynamic> properties = renderObjectJson['properties'];
final Map<String, Object> data = Map<String, Object>.fromIterable(
properties,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';

import '../diagnostics_node.dart';
import '../inspector_controller.dart';
import '../inspector_tree.dart';
import 'inspector_data_models.dart';
import 'story_of_your_layout/flex.dart';

Expand Down Expand Up @@ -101,7 +101,7 @@ class _LayoutDetailsTabState extends State<LayoutDetailsTab>
with AutomaticKeepAliveClientMixin<LayoutDetailsTab> {
InspectorController get controller => widget.controller;

InspectorTreeNode get selected => controller?.selectedNode;
RemoteDiagnosticsNode get selected => controller?.selectedNode?.diagnostic;

void onSelectionChanged() {
setState(() {});
Expand All @@ -122,16 +122,15 @@ class _LayoutDetailsTabState extends State<LayoutDetailsTab>
@override
Widget build(BuildContext context) {
super.build(context);
final diagnostic = selected?.diagnostic;
// TODO(albertusangga): Visualize non-flex widget constraint model
if (diagnostic == null ||
(!diagnostic.isFlex && !(diagnostic.parent?.isFlex ?? false)))
if (selected == null ||
(!selected.isFlex && !(selected.parent?.isFlex ?? false)))
return const SizedBox();
final flexLayoutProperties = FlexLayoutProperties.fromNode(
diagnostic.isFlex ? selected : selected.parent);
final highlightChild = diagnostic.isFlex
? null
: diagnostic.parent.childrenNow.indexOf(diagnostic);
final flexLayoutProperties = FlexLayoutProperties.fromDiagnostics(
selected.isFlex ? selected : selected.parent,
);
final highlightChild =
selected.isFlex ? null : selected.parent.childrenNow.indexOf(selected);
return StoryOfYourFlexWidget(
// TODO(albertusangga): Cache this instead of recomputing every build,
flexLayoutProperties,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ class InspectorRowContent extends StatelessWidget {
constraintDisplayController != null)
ConstraintsDescription(
listenable: constraintDisplayController,
properties: LayoutProperties(node),
properties: LayoutProperties(node.diagnostic),
),
],
),
Expand Down
Loading