Skip to content

Upgrading get_it 6 to 7

Breaking6.1.1 → 7.7.0Breaking4New14Changed8Fixed12Other1

BreakingUpgrade verdict

3 breaking changes.

  • A spelling mistake in a newly added interface has been fixed. Code that used the misspelled name will need updating.
  • Cleanup functions can now be async everywhere, but several methods now return Futures and must be awaited.
  • Instead of giving a cleanup function when registering an object, the object itself must implement Disposable and define onDispose().
3 items need code or config changes

Dart SDK requirement changed in 7.6.1: >=2.12.0 <3.0.0 → >=3.0.0 <4.0.0.

Breaking3
Corrects a typo in the new Disposable interface, which may break code written against the misspelled member.
Disposable
Makes all disposal functions accept async functions, changing the signatures of reset, resetScope, popScope, popScopesTill, resetLazySingleton and unregister.
reset()resetScope()popScope()popScopesTill()resetLazySingleton()unregister()
Replaces passing a disposing function on registration or scope push with implementing the Disposable interface, whose onDispose() is called.
DisposableonDispose()

Generated by DepDelta from published Dart source. Not mixed with prose notes.

  • changed: method GetIt.call<T extends Object>({ String? instanceName, dynamic param1, dynamic param2, }): T → method GetIt.call<T extends Object>({ String? instanceName, dynamic param1, dynamic param2, Type? type, }): T
  • changed: method GetIt.get<T extends Object>({ String? instanceName, dynamic param1, dynamic param2, }): T → method GetIt.get<T extends Object>({ dynamic param1, dynamic param2, String? instanceName, Type? type, }): T
  • changed: method GetIt.getAsync<T extends Object>({ String? instanceName, dynamic param1, dynamic param2, }): Future<T> → method GetIt.getAsync<T extends Object>({ String? instanceName, dynamic param1, dynamic param2, Type? type, }): Future<T>
  • changed: method GetIt.popScopesTill(String name): Future<bool> → method GetIt.popScopesTill(String name, {bool inclusive = …}): Future<bool>
  • changed: method GetIt.pushNewScope({ String? scopeName, ScopeDisposeFunc? dispose, }): void → method GetIt.pushNewScope({ void Function(GetIt getIt)? init, String? scopeName, ScopeDisposeFunc? dispose, bool isFinal, }): void
  • changed: method GetIt.registerFactoryParam<T extends Object, P1, P2>( FactoryFuncParam<T, P1?, P2?> factoryFunc, { String? instanceName, }): void → method GetIt.registerFactoryParam<T extends Object, P1, P2>( FactoryFuncParam<T, P1, P2> factoryFunc, { String? instanceName, }): void
  • changed: method GetIt.registerSingleton<T extends Object>( T instance, { String? instanceName, bool? signalsReady, DisposingFunc<T>? dispose, }): void → method GetIt.registerSingleton<T extends Object>( T instance, { String? instanceName, bool? signalsReady, DisposingFunc<T>? dispose, }): T
  • changed: method GetIt.resetLazySingleton<T extends Object>({ Object? instance, String? instanceName, void Function(T)? disposingFunction, }): void → method GetIt.resetLazySingleton<T extends Object>({ T? instance, String? instanceName, FutureOr Function(T)? disposingFunction, }): FutureOr
  • changed: method GetIt.unregister<T extends Object>({ Object? instance, String? instanceName, void Function(T)? disposingFunction, }): void → method GetIt.unregister<T extends Object>({ Object? instance, String? instanceName, FutureOr Function(T)? disposingFunction, }): FutureOr
  • added: class Disposable: abstract mixin
  • added: class InitDependency implements Type
  • added: class ShadowChangeHandlers: abstract mixin
  • added: ctor InitDependency(this.type, {this.instanceName})
  • added: field GetIt.allowRegisterMultipleImplementationsOfoneType: bool
  • added: field GetIt.skipDoubleRegistration: bool
  • added: field InitDependency.instanceName: final String?
  • added: field InitDependency.type: final Type
  • added: method Disposable.onDispose(): FutureOr
  • added: method GetIt.Function(bool pushed): void
  • added: method GetIt.dropScope(String scopeName): Future<void>
  • added: method GetIt.enableRegisteringMultipleInstancesOfOneType(): void
  • added: method GetIt.getAll<T extends Object>({ dynamic param1, dynamic param2, Type? type, }): Iterable<T>
  • added: method GetIt.getAllAsync<T extends Object>({ dynamic param1, dynamic param2, Type? type, }): Future<Iterable<T>>
  • added: method GetIt.hasScope(String scopeName): bool
  • added: method GetIt.pushNewScopeAsync({ Future<void> Function(GetIt getIt)? init, String? scopeName, ScopeDisposeFunc? dispose, }): Future<void>
  • added: method InitDependency.toString(): String
  • added: method ShadowChangeHandlers.onGetShadowed(Object shadowing): void
  • added: method ShadowChangeHandlers.onLeaveShadow(Object shadowing): void
  • added: static field GetIt.noDebugOutput: bool