devToolsInspectorUri method Null safety
- String inspectorRef
visibleForTesting">@visibleForTesting
Returns the DevTools inspector uri for the given vm service connection and inspector reference.
Implementation
@visibleForTesting
String devToolsInspectorUri(String inspectorRef) {
assert(activeDevToolsServerAddress != null);
assert(connectedVmServiceUri != null);
final Uri uri = Uri.parse(activeDevToolsServerAddress!).replace(
queryParameters: <String, dynamic>{
'uri': connectedVmServiceUri,
'inspectorRef': inspectorRef,
},
);
// We cannot add the '/#/inspector' path by means of
// [Uri.replace(path: '/#/inspector')] because the '#' character will be
// encoded when we try to print the url as a string. DevTools will not
// load properly if this character is encoded in the url.
// Related: https://github.com/flutter/devtools/issues/2475.
final String devToolsInspectorUri = uri.toString();
final int startQueryParamIndex = devToolsInspectorUri.indexOf('?');
// The query parameter character '?' should be present because we manually
// added query parameters above.
assert(startQueryParamIndex != -1);
return '${devToolsInspectorUri.substring(0, startQueryParamIndex)}'
'/#/inspector'
'${devToolsInspectorUri.substring(startQueryParamIndex)}';
}