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

Add tab for inspecting the state of package:provider #2851

Merged
merged 46 commits into from
Apr 29, 2021
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
a1db803
add provider fixture
rrousselGit Feb 15, 2021
1a10b9b
initial provider devtool implementation
rrousselGit Feb 15, 2021
e75a9f2
Merge branch 'master' of https://github.com/flutter/devtools into pro…
rrousselGit Feb 15, 2021
bd7d277
remove dead code
rrousselGit Feb 15, 2021
57b8282
Add tests and riverpod tab
rrousselGit Mar 1, 2021
f8a9180
move Disposable to eval_on_dart_library
rrousselGit Mar 1, 2021
bac816b
update headers
rrousselGit Mar 1, 2021
a9f02d0
use git dependency for provider
rrousselGit Mar 2, 2021
8466b31
Add riverpod fixture
rrousselGit Mar 4, 2021
8bcb7cf
upgrade dependencies
rrousselGit Mar 4, 2021
4cd575a
addd riverpod version banner
rrousselGit Mar 4, 2021
33ffdbd
fully implement isDefinedByDependency
rrousselGit Mar 4, 2021
ad132e4
remame constants
rrousselGit Mar 4, 2021
b19819d
use existing constant for icon size
rrousselGit Mar 4, 2021
5457792
use existing constants for padding/spacing
rrousselGit Mar 4, 2021
5b39e53
sort pub dependencies
rrousselGit Mar 4, 2021
4ff0c91
Fix flicker when refreshing instances
rrousselGit Mar 5, 2021
f3f3ef5
document how to run code-generation
rrousselGit Mar 5, 2021
c19ceec
remove fixtures
rrousselGit Mar 16, 2021
ef4f0d9
Merge branch 'master' of https://github.com/flutter/devtools into pro…
rrousselGit Mar 16, 2021
bcbccbc
skip sentinel exceptions in the logger
rrousselGit Mar 23, 2021
291e36b
Merge branch 'master' of https://github.com/flutter/devtools into pro…
rrousselGit Mar 31, 2021
46a4ed1
Remove riverpod tab
rrousselGit Mar 31, 2021
94eb3d5
Move InstanceViewer in provider folder
rrousselGit Mar 31, 2021
db851a1
fix tests
rrousselGit Apr 1, 2021
69aa0ec
review
rrousselGit Apr 1, 2021
034d687
review
rrousselGit Apr 1, 2021
784f29c
re-add build_runner
rrousselGit Apr 1, 2021
6de95de
remove outdated todos
rrousselGit Apr 1, 2021
90c6120
use shortHash for rendering hashcode
rrousselGit Apr 1, 2021
2acb171
Fix lints
rrousselGit Apr 7, 2021
974cf01
Merge branch 'master' of https://github.com/flutter/devtools into pro…
rrousselGit Apr 7, 2021
237a2ca
share and apply sortFieldsByName to debugger
rrousselGit Apr 7, 2021
5e81d82
skip freezed files from analysis
rrousselGit Apr 7, 2021
a9fe007
remove dead code
rrousselGit Apr 21, 2021
030fd86
Merge branch 'master' of https://github.com/flutter/devtools into pro…
rrousselGit Apr 21, 2021
bd2c785
Use areaPaneHeader and OutlineDecoration
rrousselGit Apr 21, 2021
d94f79b
update goldens
rrousselGit Apr 21, 2021
5dc759d
revert unvoluntary fixture change
rrousselGit Apr 21, 2021
15ca533
fix tests
rrousselGit Apr 21, 2021
0b8d037
Apply review
rrousselGit Apr 29, 2021
3d315fd
Merge branch 'master' of https://github.com/flutter/devtools into pro…
rrousselGit Apr 29, 2021
6fd25b1
use AreaPaneHeader widget
rrousselGit Apr 29, 2021
cea3617
upgrade dependencies
rrousselGit Apr 29, 2021
b2ce525
remove unused import
rrousselGit Apr 29, 2021
6b32788
update getHashCode test
rrousselGit Apr 29, 2021
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
1 change: 1 addition & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ analyzer:
missing_return: warning
exclude:
- build/**
- '**.freezed.dart'

linter:
rules:
Expand Down
7 changes: 6 additions & 1 deletion packages/devtools_app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// found in the LICENSE file.

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

import 'src/analytics/stub_provider.dart'
if (dart.library.html) 'src/analytics/remote_provider.dart';
Expand All @@ -11,6 +12,7 @@ import 'src/config_specific/framework_initialize/framework_initialize.dart';
import 'src/config_specific/ide_theme/ide_theme.dart';
import 'src/debugger/syntax_highlighter.dart';
import 'src/preferences.dart';
import 'src/provider/riverpod_error_logger_observer.dart';

void main() async {
final ideTheme = getIdeTheme();
Expand All @@ -29,6 +31,9 @@ void main() async {

// Now run the app.
runApp(
DevToolsApp(defaultScreens, ideTheme, await analyticsProvider),
ProviderScope(
observers: const [ErrorLoggerObserver()],
child: DevToolsApp(defaultScreens, ideTheme, await analyticsProvider),
),
);
}
5 changes: 5 additions & 0 deletions packages/devtools_app/lib/src/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import 'performance/performance_controller.dart';
import 'performance/performance_screen.dart';
import 'profiler/profiler_screen.dart';
import 'profiler/profiler_screen_controller.dart';
import 'provider/provider_screen.dart';
import 'routing.dart';
import 'scaffold.dart';
import 'screen.dart';
Expand Down Expand Up @@ -565,6 +566,10 @@ List<DevToolsScreen> get defaultScreens => <DevToolsScreen>[
const VMDeveloperToolsScreen(),
createController: () => VMDeveloperToolsController(),
),
DevToolsScreen<void>(
const ProviderScreen(),
createController: () {},
),
// Uncomment to see a sample implementation of a conditional screen.
// DevToolsScreen<ExampleController>(
// const ExampleConditionalScreen(),
Expand Down
22 changes: 22 additions & 0 deletions packages/devtools_app/lib/src/banner_messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,28 @@ Relaunch your application with the '--profile' argument, or ''',
}
}

class ProviderUnknownErrorBanner {
const ProviderUnknownErrorBanner({@required this.screenId});

final String screenId;

BannerMessage build(BuildContext context) {
return _BannerError(
key: Key('ProviderUnknownErrorBanner - $screenId'),
screenId: screenId,
textSpans: const [
TextSpan(
text: '''
The devtool failed to connect with package:provider.

This could be caused by an outdated version of package:provider. Make sure that you are using a version >=5.0.0.''',
style: TextStyle(color: _BannerError.foreground),
),
],
);
}
}

class HighProfileGranularityMessage {
HighProfileGranularityMessage(this.screenId)
: key = Key('HighProfileGranularityMessage - $screenId');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import 'logger.dart';

void log(String message, [LogLevel level = LogLevel.debug]) {
void log(Object message, [LogLevel level = LogLevel.debug]) {
switch (level) {
case LogLevel.debug:
print(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'dart:html';

import 'logger.dart';

void log(String message, [LogLevel level = LogLevel.debug]) {
void log(Object message, [LogLevel level = LogLevel.debug]) {
switch (level) {
case LogLevel.debug:
window.console.log(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import 'logger.dart';

void log(String message, [LogLevel level = LogLevel.debug]) {
void log(Object message, [LogLevel level = LogLevel.debug]) {
switch (level) {
case LogLevel.debug:
print(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,9 @@ class DebuggerController extends DisposableController
}

final variables = frame.vars.map((v) => Variable.create(v)).toList();
variables.forEach(buildVariablesTree);
variables
..forEach(buildVariablesTree)
..sort((a, b) => sortFieldsByName(a.boundVar.name, b.boundVar.name));
return variables;
}

Expand Down
7 changes: 6 additions & 1 deletion packages/devtools_app/lib/src/eval_on_dart_library.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class EvalOnDartLibrary {

Completer<LibraryRef> _libraryRef;
Future<LibraryRef> get libraryRef => _libraryRef.future;

Completer allPendingRequestsDone;

Isolate get isolate => _isolate;
Expand Down Expand Up @@ -203,6 +204,9 @@ class EvalOnDartLibrary {
InstanceRef instance, {
@required Disposable isAlive,
}) async {
// identityHashCode will be -1 if the Flutter SDK is not recent enough
if (instance.identityHashCode != -1) return instance.identityHashCode;

final hash = await evalInstance(
'instance.hashCode',
isAlive: isAlive,
Expand Down Expand Up @@ -298,7 +302,8 @@ class EvalOnDartLibrary {
'() async {'
' final reader = widgetInspectorService.toObject("$readerId", "$readerGroup") as List;'
' try {'
' final result = $expression;'
// Cast as dynamic so that it is possible to await Future<void>
' dynamic result = ($expression) as dynamic;'
' reader.add(result);'
' } catch (err, stack) {'
' reader.add(err);'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/// A few utilities related to evaluating dart code
library eval;

import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../../eval_on_dart_library.dart';
import '../../globals.dart';

/// An [EvalOnDartLibrary] that has access to no specific library in particular
///
/// Not suitable to be used when evaluating third-party objects, as it would
/// otherwise not be possible to read private properties.
final evalProvider = Provider<EvalOnDartLibrary>((ref) {
final eval = EvalOnDartLibrary(['dart:io'], serviceManager.service);
ref.onDispose(eval.dispose);
return eval;
});

/// An [EvalOnDartLibrary] that has access to `provider`
final providerEvalProvider = Provider<EvalOnDartLibrary>((ref) {
final eval = EvalOnDartLibrary(
['package:provider/src/provider.dart'],
serviceManager.service,
);

ref.onDispose(eval.dispose);
return eval;
});

/// An [EvalOnDartLibrary] for custom objects.
final libraryEvalProvider =
AutoDisposeProviderFamily<EvalOnDartLibrary, String>((ref, libraryPath) {
final eval = EvalOnDartLibrary([libraryPath], serviceManager.service);

ref.onDispose(eval.dispose);
return eval;
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// This file contains annotations that behaves like package:freezed_annotation.
// This allows using Freezed without having the devtool depend on the package.
// We could instead remove the annotations, but that would make the process of
// updating the generated files tedious.

export 'package:meta/meta.dart';
export 'package:collection/collection.dart';

const nullable = Object();
const freezed = Object();

class Default {
const Default(Object value);
}

class Assert {
const Assert(String exp);
}

class JsonKey {
const JsonKey({
bool ignore,
Object defaultValue,
});
}
Loading