Skip to content

Commit a3bcaf2

Browse files
authored
Allow widget inspector's _Location.file to be null (flutter#81588)
Fixes flutter#81587
1 parent 0cc58fd commit a3bcaf2

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

packages/flutter/lib/src/widgets/widget_inspector.dart

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,7 +1525,7 @@ mixin WidgetInspectorService {
15251525
if (location == null || location.file == null) {
15261526
return false;
15271527
}
1528-
final String file = Uri.parse(location.file).path;
1528+
final String file = Uri.parse(location.file!).path;
15291529

15301530
// By default check whether the creation location was within package:flutter.
15311531
if (_pubRootDirectories == null) {
@@ -2122,11 +2122,13 @@ class _ElementLocationStatsTracker {
21222122
final Map<String, List<int>> locationsJson = <String, List<int>>{};
21232123
for (final _LocationCount entry in newLocations) {
21242124
final _Location location = entry.location;
2125-
final List<int> jsonForFile = locationsJson.putIfAbsent(
2126-
location.file,
2127-
() => <int>[],
2128-
);
2129-
jsonForFile..add(entry.id)..add(location.line)..add(location.column);
2125+
if (location.file != null) {
2126+
final List<int> jsonForFile = locationsJson.putIfAbsent(
2127+
location.file!,
2128+
() => <int>[],
2129+
);
2130+
jsonForFile..add(entry.id)..add(location.line)..add(location.column);
2131+
}
21302132
}
21312133
json['newLocations'] = locationsJson;
21322134
}
@@ -2844,7 +2846,7 @@ class _Location {
28442846
});
28452847

28462848
/// File path of the location.
2847-
final String file;
2849+
final String? file;
28482850

28492851
/// 1-based line number.
28502852
final int line;
@@ -2880,7 +2882,9 @@ class _Location {
28802882
if (name != null) {
28812883
parts.add(name!);
28822884
}
2883-
parts.add(file);
2885+
if (file != null) {
2886+
parts.add(file!);
2887+
}
28842888
parts..add('$line')..add('$column');
28852889
return parts.join(':');
28862890
}

0 commit comments

Comments
 (0)