Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
848cb83b
Unverified
Commit
848cb83b
authored
Aug 06, 2020
by
Norbert Kozsir
Committed by
GitHub
Aug 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make _isLocalCreationLocation public (#62891)
parent
c54b15b6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
6 deletions
+42
-6
widget_inspector.dart
packages/flutter/lib/src/widgets/widget_inspector.dart
+13
-6
widget_inspector_test.dart
packages/flutter/test/widgets/widget_inspector_test.dart
+29
-0
No files found.
packages/flutter/lib/src/widgets/widget_inspector.dart
View file @
848cb83b
...
...
@@ -2860,7 +2860,7 @@ Iterable<DiagnosticsNode> _describeRelevantUserCode(Element element) {
bool
processElement
(
Element
target
)
{
// TODO(chunhtai): should print out all the widgets that are about to cross
// package boundaries.
if
(
_i
sLocalCreationLocation
(
target
))
{
if
(
debugI
sLocalCreationLocation
(
target
))
{
nodes
.
add
(
DiagnosticsBlock
(
name:
'The relevant error-causing widget was'
,
...
...
@@ -2881,15 +2881,22 @@ Iterable<DiagnosticsNode> _describeRelevantUserCode(Element element) {
/// Returns if an object is user created.
///
/// This always returns false if it is not called in debug mode.
///
/// {@macro widgets.inspector.trackCreation}
///
/// Currently is local creation locations are only available for
/// [Widget] and [Element].
bool
_isLocalCreationLocation
(
Object
object
)
{
final
_Location
location
=
_getCreationLocation
(
object
);
if
(
location
==
null
)
return
false
;
return
WidgetInspectorService
.
instance
.
_isLocalCreationLocation
(
location
);
bool
debugIsLocalCreationLocation
(
Object
object
)
{
bool
isLocal
=
false
;
assert
(()
{
final
_Location
location
=
_getCreationLocation
(
object
);
if
(
location
==
null
)
isLocal
=
false
;
isLocal
=
WidgetInspectorService
.
instance
.
_isLocalCreationLocation
(
location
);
return
true
;
}());
return
isLocal
;
}
/// Returns the creation location of an object in String format if one is available.
...
...
packages/flutter/test/widgets/widget_inspector_test.dart
View file @
848cb83b
...
...
@@ -2748,6 +2748,35 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {
);
expect
(
node
.
toJsonMap
(
emptyDelegate
),
node
.
toJsonMap
(
defaultDelegate
));
});
testWidgets
(
'debugIsLocalCreationLocation test'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
key
=
GlobalKey
();
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Container
(
padding:
const
EdgeInsets
.
all
(
8
),
child:
Text
(
'target'
,
key:
key
,
textDirection:
TextDirection
.
ltr
),
),
),
);
final
Element
element
=
key
.
currentContext
as
Element
;
expect
(
debugIsLocalCreationLocation
(
element
),
isTrue
);
expect
(
debugIsLocalCreationLocation
(
element
.
widget
),
isTrue
);
// Padding is inside container
final
Finder
paddingFinder
=
find
.
byType
(
Padding
);
final
Element
paddingElement
=
paddingFinder
.
evaluate
().
first
;
expect
(
debugIsLocalCreationLocation
(
paddingElement
),
isFalse
);
expect
(
debugIsLocalCreationLocation
(
paddingElement
.
widget
),
isFalse
);
},
skip:
!
WidgetInspectorService
.
instance
.
isWidgetCreationTracked
());
// Test requires --track-widget-creation flag.
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment