usecase_forge_devtools 0.1.0-dev.5
usecase_forge_devtools: ^0.1.0-dev.5 copied to clipboard
DevTools extension and protocol models for inspecting UseCase Forge applications.
example/README.md
Inspecting a UseCase in DevTools #
Add the core package to the application dependencies and the DevTools package to its development dependencies:
dependencies:
usecase_forge: ^0.1.0-dev.5
dev_dependencies:
usecase_forge_devtools: ^0.1.0-dev.5
Resolve dependencies, then start the Dart or Flutter application in a non-product mode with a VM service connection:
dart pub get
dart run bin/app.dart
For a Flutter application, use flutter pub get and flutter run instead.
Open DevTools from the IDE or connect it to the running application's VM
service, then select the UseCase Forge extension tab.
No initialization call is required. Live UseCases appear automatically and are removed from the overview after they close. Product and release builds do not expose this diagnostic channel.
Revealing selected values #
Application State, commands, execution keys, reasons, errors, and stack traces are hidden by default. A UseCase can explicitly expose selected JSON-safe values through the secondary diagnostics library:
import 'package:usecase_forge/diagnostics.dart';
import 'package:usecase_forge/usecase_forge.dart';
final class CartState {
const CartState(this.itemCount);
final int itemCount;
}
final class CartUseCase extends UseCase<CartState>
with UseCaseDiagnosticsDataProvider {
CartUseCase() : super(initialState: const CartState(0));
@override
String get useCaseDiagnosticLabel => 'Shopping cart';
@override
Object? encodeUseCaseDiagnosticValue(
UseCaseDiagnosticValueKind kind,
Object? value,
) {
if (kind == UseCaseDiagnosticValueKind.state && value is CartState) {
return <String, Object?>{'itemCount': value.itemCount};
}
return null;
}
}
Returning null keeps a value hidden. Expose only fields that are safe to show
in a development tool. Do not return credentials, tokens, personal data,
complete network payloads, or unrestricted toString() output.
The extension is read-only. It cannot add commands, cancel executions, change State, replay work, or modify queue policies.