Есть такой bloc flutter
class MusicBloc extends Bloc<MusicEvent, MusicState> {
  final yt = YoutubeExplode();

  MusicBloc() : super(MusicInitial()) {
    on<UrlAddEvent>(_onUrlEnteredState);
    on<UrlDeleteEvent>(_onUrlDeleteState);
    on<ErrorEvent>(_onErrorState);
  }

  String? _extractVideoId(String url) {
    final RegExp regExp = RegExp(r'(?<=v=|/)([^&]*)');
    final match = regExp.firstMatch(url);
    return match != null ? match.group(0) : null;
  }

  FutureOr<void> _onUrlEnteredState(UrlAddEvent event, Emitter<MusicState> emit) async {
    emit(LoadingState());
    final yt = YoutubeExplode();
    final String url = event.url;
    final videoId = _extractVideoId(url);

    if(videoId == null) {
      emit(ErrorState('Invalid URL'));
      return;
    }

    try {
      final video = await yt.videos.get(videoId);

      final streamInfoSet = await yt.videos.streams.getManifest(videoId);

      final audioStream = streamInfoSet.audioOnly.withHighestBitrate();

      final title = video.title;
      print(title);
      emit(UrlEnteredState(title));
    }
    catch(e) {
      emit(ErrorState('Loading Error'));
    }

  }

  FutureOr<void> _onUrlDeleteState(UrlDeleteEvent event, Emitter<MusicState> emit) {
    print('delete');
  }

  FutureOr<void> _onErrorState(ErrorEvent event, Emitter<MusicState> emit) {
    print('Error');
  }
}
и такой ui
Scaffold(
      body: BlocProvider(
        create: (context) => MusicBloc(),
        child: Padding(
          padding: const EdgeInsets.all(5.0),
          child: Column(
            children: [
              TextField(
                controller: _controller,
                decoration: InputDecoration(labelText:'Enter URL'),
              ),
              const SizedBox(height: 5.0),
              ElevatedButton(
                onPressed: () {
                  final url = _controller.text;
                  context.read<MusicBloc>().add(UrlAddEvent(url));
                  _controller.clear();
                },
                child: const Text('Add'),
              ),
              const SizedBox(height: 5.0),
              BlocBuilder<MusicBloc, MusicState>(
                builder: (context, state) {
                  if (state is LoadingState) {
                    return const CircularProgressIndicator();
                  } else if(state is UrlEnteredState) {
                    return Container(
                      width: 200,
                      height: 200,
                      padding: const EdgeInsets.all(5.0),
                      color: Colors.greenAccent,
                      child: Text(
                        state.title,
                        style: const TextStyle(fontSize:20),
                      ),
                    );
                  } else if (state is ErrorState){
                    return Text(
                      state.error,
                      style: const TextStyle(color: Colors.red),
                    );
                  }
                  return Container(
                    height: 20,
                    width: 20,
                    decoration: BoxDecoration(color: Colors.red,),
                  );
                }
              ),
            ],
          ),
        ),
      ),
    );
После нажатия кнопки должен появляется Контейнер с текстом из поля, а появляется последний контейнер с красным фоном