| ํญ๋ชฉ | ๋ด์ฉ |
|---|---|
| Invoke | /bloc:create |
| Aliases | /state:bloc, /flutter:bloc |
| Category | kobic-development |
| Complexity | moderate |
| MCP Servers | serena, context7 |
/bloc:create โ ํ๋ฉด ์ํ ๊ด๋ฆฌ ์ฝ๋ ์๋ ์์ฑ๊ธฐ#
ํ๋ง๋๋ก#
์ฑ ํ๋ฉด์ด "๋ก๋ฉ ์ค / ์๋ฃ / ์ค๋ฅ" ๊ฐ์ ์ํ๋ฅผ ์ด๋ป๊ฒ ๋ค๋ฃฐ์ง ์ ํด์ฃผ๋ ๋ผ๋ ์ฝ๋๋ฅผ ์๋์ผ๋ก ๋ง๋ค์ด ์ค๋๋ค. ์๋ฆฌ๋ก ์น๋ฉด, ๋งค๋ฒ ์๋ก ๋ง๋ค ํ์ ์์ด ๊ฒ์ฆ๋ ๋ ์ํผ ํ์ ๊ทธ๋๋ก ๊น์์ฃผ๋ ๊ฒ๊ณผ ๊ฐ์์.
๋๊ฐยท์ธ์ ์ฐ๋์#
- ์ ํ๋ฉด(์: ํ, ๋ก๊ทธ์ธ, ์ฅ๋ฐ๊ตฌ๋)์ ๋ง๋ค๋ฉด์ ๊ทธ ํ๋ฉด์ ์ํ ์ฒ๋ฆฌ ์ฝ๋๋ฅผ ์์ํ ๋
- ๋งค๋ฒ ์์ผ๋ก ์์ฑํ๋ BLoC/Cubit ๊ตฌ์กฐ๋ฅผ ํ์ค ๊ท์น์ ๋ง์ถฐ ๋น ๋ฅด๊ฒ ๊น๊ณ ์ถ์ ๋
๋ฌด์์ ํด์ฃผ๋์#
๊ธฐ๋ฅ ํด๋ ์์ ์ํ ๊ด๋ฆฌ์ฉ ํ์ผ 3๊ฐ๋ฅผ ๋ง๋ค์ด ์ค๋๋ค.
{bloc_name}_bloc.dartโ ์ค์ ๋์์ ๋ด๋นํ๋ ๋ณธ์ฒด{bloc_name}_event.dartโ ํ๋ฉด์์ ์ผ์ด๋๋ "์ฌ๊ฑด"(๋ฒํผ ๋๋ฆ ๋ฑ)์ ์ ์{bloc_name}_state.dartโ ํ๋ฉด์ ์ํ(์ด๊ธฐ / ๋ก๋ฉ / ์๋ฃ / ์ค๋ฅ)๋ฅผ ์ ์
์์ฑ๋๋ ์ฝ๋๋ ํ์ฌ ํ์ค ๊ท์น(์ํ๋ ์ด๊ธฐยท๋ก๋ฉยท์๋ฃยท์ค๋ฅ ๋ค ๊ฐ์ง, ๋น๋๊ธฐ ์์ ํ ์์ ์ ๊ฒ ๋ฑ)์ ๊ทธ๋๋ก ๋ฐ๋ฆ ๋๋ค.
์ด๋ป๊ฒ ์ฐ๋์#
# ํ ํผ๋ ํ๋ฉด์ฉ (๋ถ๋ฌ์ค๊ธฐยท์๋ก๊ณ ์นจ ๊ธฐ๋ฅ ์ฐ๊ฒฐ)
/bloc:create home Home --usecases GetFeed,RefreshFeed
# ๋ก๊ทธ์ธ ํ๋ฉด์ฉ (Cubit ๋ฐฉ์, ๊ณตํต ์์น์ ์์ฑ)
/bloc:create auth Login --type cubit --location common
# ๊ด๋ฆฌ์ ๋์๋ณด๋ ํ๋ฉด์ฉ (์ฝ์ ์์น์ ์์ฑ)
/bloc:create 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์ flutter_bloc ๊ณต์ ๋ฌธ์)์ ๊ธฐ์กด ์ฝ๋ ํจํด(Serena ๋ถ์)์ ํ์ฉํด ์ผ๊ด๋ ํํ๋ก ์์ฑํฉ๋๋ค.
โ๏ธ ์์ธ ์ต์ ยท์คํ ๋ช ์ธ (๊ฐ๋ฐ์ / AI ์์ด์ ํธ์ฉ)
Usage#
/bloc:create {feature_name} {bloc_name} [--options]Parameters#
| Parameter | Required | Description | Example |
|---|---|---|---|
feature_name | โ | Feature Module name | home, auth, store |
bloc_name | โ | BLoC Name | Home, Login, Cart |
--type | โ | Type | bloc, cubit (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 # BLoC ๊ตฌํ
โโโ {bloc_name}_event.dart # Event ์ ์ (sealed class)
โโโ {bloc_name}_state.dart # State ์ ์ (Freezed)Core Rules#
- 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
Examples#
# Home feed BLoC
/bloc:create home Home --usecases GetFeed,RefreshFeed
# Auth login Cubit
/bloc:create auth Login --type cubit --location common
# Admin dashboard BLoC
/bloc:create dashboard Dashboard --location consoleMCP Integration#
| MCP Server | Purpose |
|---|---|
| Context7 | flutter_bloc official documentation |
| Serena | Existing BLoC Pattern Analysis |