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

Remove outdated Flutter Version checks in the Inspector #3671

Merged
merged 2 commits into from
Feb 11, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ import '../primitives/auto_dispose.dart';
import '../primitives/utils.dart';
import '../shared/globals.dart';
import '../shared/service_extensions.dart' as extensions;
import '../shared/service_registrations.dart' as registrations;
import '../shared/version.dart';
import 'diagnostics_node.dart';
import 'inspector_screen.dart';
import 'inspector_service.dart';
Expand Down Expand Up @@ -77,8 +75,6 @@ class InspectorController extends DisposableController
@required this.treeType,
this.parent,
this.isSummaryTree = true,
this.onExpandCollapseSupported,
this.onLayoutExplorerSupported,
}) : _treeGroups = InspectorObjectGroupManager(
serviceManager.inspectorService,
'tree',
Expand Down Expand Up @@ -110,9 +106,6 @@ class InspectorController extends DisposableController
details = null;
}

_checkForExpandCollapseSupport();
_checkForLayoutExplorerSupport();

addAutoDisposeListener(serviceManager.isolateManager.mainIsolate, () {
final isolate = serviceManager.isolateManager.mainIsolate.value;
if (isolate != _mainIsolate) {
Expand Down Expand Up @@ -200,10 +193,6 @@ class InspectorController extends DisposableController

final bool isSummaryTree;

final VoidCallback onExpandCollapseSupported;

final VoidCallback onLayoutExplorerSupported;

/// Parent InspectorController if this is a details subtree.
InspectorController parent;

Expand Down Expand Up @@ -980,43 +969,4 @@ class InspectorController extends DisposableController
details.inspectorTree.collapseToSelected();
details.animateTo(details.inspectorTree.selection);
}

/// execute given [callback] when minimum Flutter [version] is met.
void _onVersionSupported(
SemanticVersion version,
VoidCallback callback,
) {
final flutterVersionServiceListenable = serviceManager
.registeredServiceListenable(registrations.flutterVersion.service);
addAutoDisposeListener(flutterVersionServiceListenable, () async {
final registered = flutterVersionServiceListenable.value;
if (registered) {
final flutterVersion =
FlutterVersion.parse((await serviceManager.flutterVersion).json);
if (_disposed) return;
if (flutterVersion.isSupported(supportedVersion: version)) {
callback();
}
}
});
}

void _checkForExpandCollapseSupport() {
if (onExpandCollapseSupported == null) return;
// Configurable subtree depth is available in versions of Flutter
// greater than or equal to 1.9.7, but the flutterVersion service is
// not available until 1.10.1, so we will check for 1.10.1 here.
_onVersionSupported(
SemanticVersion(major: 1, minor: 10, patch: 1),
onExpandCollapseSupported,
);
}

void _checkForLayoutExplorerSupport() {
if (onLayoutExplorerSupported == null) return;
_onVersionSupported(
SemanticVersion(major: 1, minor: 13, patch: 1),
onLayoutExplorerSupported,
);
}
}
20 changes: 0 additions & 20 deletions packages/devtools_app/lib/src/inspector/inspector_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ class InspectorScreenBodyState extends State<InspectorScreenBody>
BlockingActionMixin,
AutoDisposeMixin,
SearchFieldMixin<InspectorScreenBody> {
bool _expandCollapseSupported = false;
bool _layoutExplorerSupported = false;

InspectorController inspectorController;

InspectorTreeController get summaryTreeController =>
Expand Down Expand Up @@ -123,8 +120,6 @@ class InspectorScreenBodyState extends State<InspectorScreenBody>
inspectorTree: inspectorTreeController,
detailsTree: detailsTree,
treeType: FlutterTreeType.widget,
onExpandCollapseSupported: _onExpandCollapseSupported,
onLayoutExplorerSupported: _onLayoutExplorerSupported,
);

summaryTreeController.setSearchTarget(searchTarget);
Expand Down Expand Up @@ -184,7 +179,6 @@ class InspectorScreenBodyState extends State<InspectorScreenBody>
detailsTree: detailsTree,
controller: inspectorController,
actionButtons: _expandCollapseButtons(),
layoutExplorerSupported: _layoutExplorerSupported,
),
],
);
Expand Down Expand Up @@ -316,8 +310,6 @@ class InspectorScreenBodyState extends State<InspectorScreenBody>
}

Widget _expandCollapseButtons() {
if (!_expandCollapseSupported) return null;

return Container(
alignment: Alignment.centerRight,
decoration: BoxDecoration(
Expand Down Expand Up @@ -355,18 +347,6 @@ class InspectorScreenBodyState extends State<InspectorScreenBody>
);
}

void _onExpandCollapseSupported() {
setState(() {
_expandCollapseSupported = true;
});
}

void _onLayoutExplorerSupported() {
setState(() {
_layoutExplorerSupported = true;
});
}

void _refreshInspector() {
ga.select(analytics_constants.inspector, analytics_constants.refresh);
blockWhileInProgress(() async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ class InspectorDetailsTabController extends StatefulWidget {
this.detailsTree,
this.actionButtons,
this.controller,
this.layoutExplorerSupported,
Key key,
}) : super(key: key);

final Widget detailsTree;
final Widget actionButtons;
final InspectorController controller;
final bool layoutExplorerSupported;

@override
_InspectorDetailsTabControllerState createState() =>
Expand All @@ -37,39 +35,30 @@ class _InspectorDetailsTabControllerState
with TickerProviderStateMixin, AutoDisposeMixin {
static const _detailsTreeTabIndex = 1;
static const _tabsLengthWithLayoutExplorer = 2;
static const _tabsLengthWithoutLayoutExplorer = 1;

TabController _tabControllerWithLayoutExplorer;
TabController _tabControllerWithoutLayoutExplorer;
TabController _tabController;

@override
void initState() {
super.initState();
addAutoDisposeListener(
_tabControllerWithLayoutExplorer =
TabController(length: _tabsLengthWithLayoutExplorer, vsync: this),
);
addAutoDisposeListener(
_tabControllerWithoutLayoutExplorer =
TabController(length: _tabsLengthWithoutLayoutExplorer, vsync: this),
_tabController = TabController(
length: _tabsLengthWithLayoutExplorer,
vsync: this,
),
);
}

@override
Widget build(BuildContext context) {
final tabs = <Tab>[
if (widget.layoutExplorerSupported) _buildTab('Layout Explorer'),
_buildTab('Layout Explorer'),
_buildTab('Widget Details Tree'),
];
final tabViews = <Widget>[
if (widget.layoutExplorerSupported)
LayoutExplorerTab(controller: widget.controller),
LayoutExplorerTab(controller: widget.controller),
widget.detailsTree,
];
final _tabController = widget.layoutExplorerSupported
? _tabControllerWithLayoutExplorer
: _tabControllerWithoutLayoutExplorer;

final theme = Theme.of(context);
final focusColor = theme.focusColor;
final borderSide = BorderSide(color: focusColor);
Expand Down
3 changes: 2 additions & 1 deletion packages/devtools_app/test/inspector_screen_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ void main() {
fakeExtensionManager.fakeFrame();
}

testWidgets('builds its tab', (WidgetTester tester) async {
testWidgetsWithWindowSize('builds its tab', windowSize,
(WidgetTester tester) async {
await tester.pumpWidget(buildInspectorScreen());
await tester.pumpAndSettle();
expect(find.byType(InspectorScreenBody), findsOneWidget);
Expand Down