
# Comparisons

These pages take one task at a time, such as registering a service, notifying listeners or calling a REST API, and show it twice: the way it is usually done in Dart, and the way it is done with Spring for Dart. The examples are short, 10 to 30 lines each, and the two versions sit next to each other under the same heading.

They are not whole projects: each example is the smallest code that shows the difference.

## What to expect

- **The same task on both sides.** Each heading is one small job. The plain Dart version comes first, then the Spring version, then a sentence or two on what changed.
- **Real APIs.** The `get_it` and `dio` examples use the current APIs of those packages. The Spring examples use only what Spring for Dart has.
- **Honest costs.** Spring for Dart is not free. It needs a build step (`dart run build_runner build`, or `watch`) after you change annotations, a generated file next to `main`, and annotations that a reader has to know. The plain Dart versions need none of that. Each page says where the plain version is the better choice.

## The pages

| Page | Plain Dart | Spring for Dart |
|---|---|---|
| [get_it and dependency injection](get-it.md) | A service locator: `GetIt.instance`, `registerSingleton`, `registerLazySingleton`, scopes | `@Service`, constructor injection, `@Profile`, `@Primary`, `@Lazy`, `@Scope`, test overrides |
| [Observer](observer.md) | A hand-written listener list, or a `StreamController` | `List<PurchaseListener>` injection, `publishEvent` and `@EventListener` |
| [Logic around a method](around-a-method.md) | A decorator class per service, or a wrapper function | `@Aspect` with `@Around`, pointcuts, generated proxies |
| [HTTP clients](http-clients.md) | `platformHttpTransport()` by hand, and `dio` | A `@FeignClient` interface |

## See also

- [Inversion of control and dependency injection](../docs/inversion-of-control.md)
- [The starters](../docs/starters.md)
