data static method

Map<String, Object?> data({
  1. String? target,
})

The state.data reply: the state target names, or the page on screen.

Throws a LiveException when nothing on screen is a NyPage or NyState, or when target names no state that is.

Implementation

static Map<String, Object?> data({String? target}) {
  final String? route = Nylo.getCurrentRouteName();
  final List<NyBaseState> states = statesOnScreen();
  if (states.isEmpty) {
    nyLiveInspectedState = null;
    throw LiveException(
      route == null
          ? 'Nothing on screen is a NyPage or NyState yet. Wait for the app '
                'to load, then try again.'
          : 'The page on "$route" isn\'t a NyPage or NyState, so it holds '
                'no Nylo state to show.',
    );
  }

  final NyBaseState state = target == null
      ? states.first
      : _match(states, target);
  nyLiveInspectedState = state;

  return {
    'route': route,
    'state': describe(state),
    'states': [
      for (final NyBaseState found in states.take(stateLimit)) summary(found),
    ],
    'inspect': {
      'library': libraryUri,
      'variable': 'nyLiveInspectedState',
      'encoder': 'nyLiveInspectJson',
      'skip': frameworkStateClasses,
    },
  };
}