Allow widget inspector's _Location.file to be null (#81588)
Fixes https://github.com/flutter/flutter/issues/81587
This commit is contained in:
parent
0cc58fd046
commit
a3bcaf226c
@ -1525,7 +1525,7 @@ mixin WidgetInspectorService {
|
|||||||
if (location == null || location.file == null) {
|
if (location == null || location.file == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final String file = Uri.parse(location.file).path;
|
final String file = Uri.parse(location.file!).path;
|
||||||
|
|
||||||
// By default check whether the creation location was within package:flutter.
|
// By default check whether the creation location was within package:flutter.
|
||||||
if (_pubRootDirectories == null) {
|
if (_pubRootDirectories == null) {
|
||||||
@ -2122,12 +2122,14 @@ class _ElementLocationStatsTracker {
|
|||||||
final Map<String, List<int>> locationsJson = <String, List<int>>{};
|
final Map<String, List<int>> locationsJson = <String, List<int>>{};
|
||||||
for (final _LocationCount entry in newLocations) {
|
for (final _LocationCount entry in newLocations) {
|
||||||
final _Location location = entry.location;
|
final _Location location = entry.location;
|
||||||
|
if (location.file != null) {
|
||||||
final List<int> jsonForFile = locationsJson.putIfAbsent(
|
final List<int> jsonForFile = locationsJson.putIfAbsent(
|
||||||
location.file,
|
location.file!,
|
||||||
() => <int>[],
|
() => <int>[],
|
||||||
);
|
);
|
||||||
jsonForFile..add(entry.id)..add(location.line)..add(location.column);
|
jsonForFile..add(entry.id)..add(location.line)..add(location.column);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
json['newLocations'] = locationsJson;
|
json['newLocations'] = locationsJson;
|
||||||
}
|
}
|
||||||
resetCounts();
|
resetCounts();
|
||||||
@ -2844,7 +2846,7 @@ class _Location {
|
|||||||
});
|
});
|
||||||
|
|
||||||
/// File path of the location.
|
/// File path of the location.
|
||||||
final String file;
|
final String? file;
|
||||||
|
|
||||||
/// 1-based line number.
|
/// 1-based line number.
|
||||||
final int line;
|
final int line;
|
||||||
@ -2880,7 +2882,9 @@ class _Location {
|
|||||||
if (name != null) {
|
if (name != null) {
|
||||||
parts.add(name!);
|
parts.add(name!);
|
||||||
}
|
}
|
||||||
parts.add(file);
|
if (file != null) {
|
||||||
|
parts.add(file!);
|
||||||
|
}
|
||||||
parts..add('$line')..add('$column');
|
parts..add('$line')..add('$column');
|
||||||
return parts.join(':');
|
return parts.join(':');
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user