← ClaudeAtlas

create-use-caselisted

Build a *_use_case.dart — what a use case may inject (services, never stores or other use cases), the four types, where to put it by consumer and when to promote it, return and error patterns, anti-patterns, and the extract-or-inline decision. Use when extracting an operation out of a store or state, or when deciding whether logic deserves its own class.
NarekManukyan/flutter-mobx-kit · ★ 0 · Data & Documents · score 70
Install: claude install-skill NarekManukyan/flutter-mobx-kit
# Create a use case Governed by [ADR-0001](../../../docs/adr/0001-layered-architecture.md) (access matrix), [ADR-0003](../../../docs/adr/0003-no-use-case-to-use-case-dependencies.md) (no UC → UC), [ADR-0004](../../../docs/adr/0004-use-case-taxonomy-and-colocation.md) (taxonomy + colocation), [ADR-0020](../../../docs/adr/0020-error-handling-and-issue-tracking.md) (errors). A use case encapsulates **one** business operation: an `@injectable` class with one public method, `call()`, invoked with call syntax. It is short-lived and stateless — it performs the operation and is done. ```dart @injectable class CreateTodoUseCase { final DioService _dioService; final IssueTrackingService _issueTrackingService; CreateTodoUseCase(this._dioService, this._issueTrackingService); Future<TodoDto?> call(String title) async { try { return await _dioService.todosProvider.createTodo( todoCreateDto: TodoCreateRequestDto(title: title), ); } on DioException catch (e, stackTrace) { _issueTrackingService.trackHandledError( e, stackTrace: stackTrace, handlingContext: 'create_todo', ); return null; } } } // call site — no .call() final todo = await _createTodoUseCase(title); ``` - Named as a verb phrase: `CreateTodoUseCase`, `FetchTodosUseCase`, `ShowAddTodoModalUseCase`. - **Always `@injectable`, never `@singleton`.** It holds no state worth sharing. - Constructor injection only — never `getIt<>()` inside. ## Wha