Dependency Injection
Zuraffa can generate DI setup alongside the rest of your architecture.
The v5 public workflow is:
- create the entity
- run
zfa makewith--di - run
zfa build
Basic usage
1. Generate with DI
zfa make Product --preset=crud --methods=get,getList,create --di
2. Initialize in main.dart
Import the generated DI entrypoint and initialize it before runApp().
import 'package:get_it/get_it.dart';
import 'src/di/index.dart';
final getIt = GetIt.instance;
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await setupDependencies(getIt);
runApp(MyApp());
}
Development with mocks
Use --mock --use-mock when you want DI to bind the mock path by default:
zfa make Product --preset=crud --methods=get,getList --mock --di --use-mock