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 pages

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

See also