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

Edit mixin private properties #3010

Merged
merged 11 commits into from
May 12, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.

import 'package:code_size_images/main.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:code_size_images/main.dart';

void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.

import 'package:code_size_package/main.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:code_size_package/main.dart';

void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.

import 'package:code_size_images/main.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:code_size_images/main.dart';

void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.

import 'package:code_size_package/main.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:code_size_package/main.dart';

void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
Expand Down
2 changes: 1 addition & 1 deletion case_study/platform_channel/lib/channel_demo.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/services.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';

class ChannelDemo extends StatefulWidget {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,16 +415,28 @@ Future<List<ObjectField>> _parseFields(
final fields = instance.fields.map((field) async {
final owner = await eval.getClass(field.decl.owner, isAlive);

final ownerPackageName = tryParsePackageName(owner.library.uri);
String ownerUri;
String ownerName;
if (owner.mixin == null) {
ownerUri = owner.library.uri;
ownerName = owner.name;
} else {
final mixinClass = await eval.getClass(owner.mixin.typeClass, isAlive);

ownerUri = mixinClass.library.uri;
ownerName = mixinClass.name;
}

final ownerPackageName = tryParsePackageName(ownerUri);

return ObjectField(
name: field.decl.name,
isFinal: field.decl.isFinal,
ref: parseSentinel<InstanceRef>(field.value),
ownerName: owner.name,
ownerUri: owner.library.uri,
ownerName: ownerName,
ownerUri: ownerUri,
eval: await ref.watch(libraryEvalProvider(owner.library.uri).future),
isDefinedByDependency: ownerPackageName == appName,
isDefinedByDependency: ownerPackageName != appName,
);
}).toList();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,11 @@ class InstanceViewer extends StatefulWidget {
const InstanceViewer({
Key key,
this.rootPath,
@required this.showInternalProperties,
}) : super(key: key);

final InstancePath rootPath;
final bool showInternalProperties;

@override
_InstanceViewerState createState() => _InstanceViewerState();
Expand Down Expand Up @@ -351,6 +353,13 @@ class _InstanceViewerState extends State<InstanceViewer> {
@required InstancePath path,
}) sync* {
for (final field in instance.fields) {
if (!widget.showInternalProperties &&
field.isDefinedByDependency &&
field.isPrivate) {
// Hide private properties from classes defined by dependencies
continue;
}

final children = _buildListViewItems(
context,
watch,
Expand Down
60 changes: 58 additions & 2 deletions packages/devtools_app/lib/src/provider/provider_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:provider/provider.dart' as provider show Provider;

import '../banner_messages.dart';
import '../common_widgets.dart';
import '../dialogs.dart';
import '../screen.dart';
import '../split.dart';
import './instance_viewer/instance_details.dart';
Expand Down Expand Up @@ -39,6 +40,8 @@ final _selectedProviderNode = AutoDisposeProvider<ProviderNode>((ref) {
);
});

final _showInternals = StateProvider<bool>((ref) => false);

class ProviderScreen extends Screen {
const ProviderScreen()
: super.conditional(
Expand Down Expand Up @@ -82,8 +85,8 @@ class ProviderScreenBody extends ConsumerWidget {
child: Column(
children: const [
AreaPaneHeader(
title: Text('Providers'),
needsTopBorder: false,
title: Text('Providers'),
),
Expanded(
child: ProviderList(),
Expand All @@ -95,13 +98,25 @@ class ProviderScreenBody extends ConsumerWidget {
child: Column(
children: [
AreaPaneHeader(
title: Text(detailsTitleText),
needsTopBorder: false,
title: Text(detailsTitleText),
actions: [
SettingsOutlinedButton(
onPressed: () {
showDialog(
context: context,
builder: (_) => _StateInspectorSettingsDialog(),
);
},
tooltip: 'State inspector configurations',
),
],
),
if (selectedProviderId != null)
Expanded(
child: InstanceViewer(
rootPath: InstancePath.fromProviderId(selectedProviderId),
showInternalProperties: watch(_showInternals).state,
),
)
],
Expand All @@ -122,3 +137,44 @@ void showProviderErrorBanner(BuildContext context) {
.build(context),
);
}

class _StateInspectorSettingsDialog extends ConsumerWidget {
@override
Widget build(BuildContext context, ScopedReader watch) {
final theme = Theme.of(context);

return DevToolsDialog(
title: dialogTitleText(theme, 'State inspector configurations'),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Tooltip(
message: 'Show private properties inherited from SDKs/packages',
waitDuration: tooltipWait,
child: InkWell(
onTap: () => _toggleShowInternals(context),
child: Row(
children: [
Checkbox(
value: watch(_showInternals).state,
onChanged: (_) => _toggleShowInternals(context),
),
const Text('Show internals'),
],
),
),
)
],
),
actions: [
DialogCloseButton(),
],
);
}

void _toggleShowInternals(BuildContext context) {
final showInternals = context.read(_showInternals);
showInternals.state = !showInternals.state;
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading