/cc-flutter:bloc — 화면 상태 관리 코드 자동 생성기#
| 항목 | 내용 |
|---|---|
| 실행 명령 | /cc-flutter:bloc |
| 분류 | 개발 |
| 난이도 | ●●○ 보통 |
| MCP 서버 | serena, context7 |
한마디로#
앱 화면이 "로딩 중 / 완료 / 오류" 같은 상태를 어떻게 다룰지 정해주는 뼈대 코드를 자동으로 만들어 줍니다. 요리로 치면, 매번 새로 만들 필요 없이 검증된 레시피 틀을 그대로 깔아주는 것과 같아요.
누가·언제 쓰나요#
- 새 화면(예: 홈, 로그인, 장바구니)을 만들면서 그 화면의 상태 처리 코드를 시작할 때
- 매번 손으로 작성하던 BlocSignal/CubitSignal 구조를 표준 규칙에 맞춰 빠르게 깔고 싶을 때
무엇을 해주나요#
기능 폴더 안에 상태 관리용 파일 3개를 만들어 줍니다.
{bloc_name}_bloc.dart— 실제 동작을 담당하는 본체{bloc_name}_event.dart— 화면에서 일어나는 "사건"(버튼 누름 등)을 정의{bloc_name}_state.dart— 화면의 상태(초기 / 로딩 / 완료 / 오류)를 정의
생성되는 코드는 회사 표준 규칙(상태는 초기·로딩·완료·오류 네 가지, 비동기 작업 후 안전 점검 등)을 그대로 따릅니다.
어떻게 쓰나요#
# 홈 피드 화면용 (불러오기·새로고침 기능 연결)
/cc-flutter:bloc home Home --usecases GetFeed,RefreshFeed
# 로그인 화면용 (Cubit 방식, 공통 위치에 생성)
/cc-flutter:bloc auth Login --type cubit --location common
# 관리자 대시보드 화면용 (콘솔 위치에 생성)
/cc-flutter:bloc dashboard Dashboard --location console
feature_name(필수): 기능 이름 (예:home,auth,store)-
bloc_name(필수): 만들 상태 관리 이름 (예:Home,Login,Cart) --type:bloc또는cubit선택 (기본값bloc)--location: 생성 위치 (application,common,console)--usecases: 연결할 기능 단위 (예:GetUser,UpdateUser)
안에서 무슨 일이 벌어지나요#
- 입력한 기능 이름·상태 이름·옵션을 바탕으로 어디에 무엇을 만들지 정합니다.
- 표준 규칙에 맞는 파일 3개(본체·사건·상태)를 해당 기능 폴더에 생성합니다.
- 참고 자료(Context7의 bloc_signals 공식 문서)와 기존 코드 패턴(Serena 분석)을 활용해 일관된 형태로 작성합니다.
⚙️ 상세 옵션·실행 명세 (개발자 / AI 에이전트용)
Usage#
/cc-flutter:bloc {feature_name} {bloc_name} [--options]Parameters#
| Parameter | Required | Description | Example |
|---|---|---|---|
feature_name | ✅ | Feature Module name | home, auth, store |
bloc_name | ✅ | Container Name | Home, Login, Cart |
--type | ❌ | Type | bloc (BlocSignal), cubit (CubitSignal) — default: bloc |
--location | ❌ | Location | application, common, console |
--usecases | ❌ | UseCases to connect | GetUser,UpdateUser |
Generated Files#
feature/{location}/{feature_name}/lib/src/presentation/bloc/
├── {bloc_name}_bloc.dart # BlocSignal 구현
├── {bloc_name}_event.dart # Event 정의 (sealed class)
└── {bloc_name}_state.dart # State 정의 (Freezed)Core Rules#
- Base class:
BlocSignal<E, S>/CubitSignal<S>frompackage:bloc_signals - Initial state: named
super(initialState: ...)— positionalsuper(...)does not compile - State read:
stateValue(stateis aReadonlySignal<S>) - Handler emit param:
void Function(S)— there is noEmitter<S>type - Event:
sealed class+ private_prefix Class - State: Freezed union type (
initial,loading,loaded,error) - UseCase:
const UseCase()Direct creation (DI not used) - Safety:
awaitAfter mustif (isClosed) return;Check - De-dup: equal states are not re-emitted — override
equalswhen every emit must notify
Examples#
# Home feed BLoC
/cc-flutter:bloc home Home --usecases GetFeed,RefreshFeed
# Auth login Cubit
/cc-flutter:bloc auth Login --type cubit --location common
# Admin dashboard BLoC
/cc-flutter:bloc dashboard Dashboard --location consoleMCP Integration#
| MCP Server | Purpose |
|---|---|
| Context7 | bloc_signals / bloc_signals_flutter official documentation |
| Serena | Existing BlocSignal Pattern Analysis |