debugIsLocalCreationLocation function Null safety

bool debugIsLocalCreationLocation(
  1. Object object

Returns if an object is user created.

This always returns false if it is not called in debug mode.

Requires Widget creation locations which are only available for debug mode builds when the --track-widget-creation flag is enabled on the call to the flutter tool. This flag is enabled by default in debug builds.

Currently is local creation locations are only available for Widget and Element.


bool debugIsLocalCreationLocation(Object object) {
  bool isLocal = false;
  assert(() {
    final _Location? location = _getCreationLocation(object);
    if (location != null) {
      isLocal = WidgetInspectorService.instance._isLocalCreationLocation(location.file);
    return true;
  return isLocal;