onCreateBloc method

void onCreateBloc(
  1. BlocBase bloc
)

Implementation

void onCreateBloc(BlocBase bloc) async {
  if (!enabled) {
    _logDebug("Inspector is disabled");
    return;
  }

  String? data;

  try {
    data = json.encode(InvestigativePacket(
      type: PacketType.blocCreated,
      blocName: bloc.runtimeType.toString(),
      state: bloc.state.toJson(),
      identity: identity,
    ));
  } catch (error) {
    data = json.encode(InvestigativePacket(
      type: PacketType.blocFallbackCreated,
      blocName: bloc.runtimeType.toString(),
      fallbackState: bloc.state.toString(),
      identity: identity,
    ));
  } finally {
    if (data != null) {
      buffer.add(data);
      _sendLog(data);
    }
  }
}