- fixing linter warning thanks to @PatrickChrestin
- Fixes by @kuhnroyal and @ArtAhmetajCR who spotted some flaws in my latest changes. Thanks a lot
- Bugfixes and improvements for certain edge cases thanks to @KnightOfBlackLily and @kuhnroyal
- official new release with all the changes
- adding cachedFatories and better scope protection against race conditions
- testing weak references in lazySingeltons
- adding
changeTypeInstanceName
- fixing bug in
unregister
that happened if you tried to unregister a named registration by providing an instance instead of the type and the instance name
- releaseInstance will now throw if the instance isn't registered
- fixing negative reference count
getAll()
andgetAllAsync()
now have afromAllScopes
parameter.- adding safeguards according to #364 to make it impossible to call
push/popScope
while theinit()
function of another pushScope is running. - fixed an unsafe type check when using a runtime type to access an object in get_it.
- thanks to the PR by @kasefuchs #361
getAll
is now available in an async version too.
- fig for bug that was introduced in 7.6.8 #358
- merged PR by @venkata-reddy-dev #356 adding new
skipDoubleRegistration
flag for testing
- merged PR by @subzero911 #330
- Thanks to PR by @bvoq
getIt.reset, getIt.popScope, getIt.dropScope
now dispose registered objects in the reverse order in which they were registered.
- updated Discord link
- fixed the throwing of a StateError that was previously thrown as String
- push new version because pub didn't list this one
- fix linter error
- added
isFinal
scope parameter which fixes #326 - version bump of dependencies and updates readme
- merged PR by lacopiroty #297 which now allows to access objects inside GetIt by runtime type too like
getIt.registerSingleton(TestClass());
final instance1 = getIt.get(type: TestClass);
expect(instance1 is TestClass, true);
- new function
dropScope(scopeName)
which allows to remove and dispose any named scope even if it's not the top one. Great PR by @olexale #292 which fixes sort of race conditions if you create scopes just for the life time of a widget.
- PR from @dzziwny which fixed an edge case with LazySingletons #284
- Changed an assertion in case that an object is not registered to an Exception that also will throw in real time so that you get meaningful errors based on #312
registerSingleton
now returns the passed instance as a return value thanks to the PR by @Rexios80 #242- In some cases GetIt will print error messages to the debug output. Now this won't happen anymore in release mode and can be completely disabled by setting
GetIt.noDebugOutput=true
following the PR from @James1345
New features:
popScopeTil
got a new optionalinclusive
parameter so you can now decide if scope with the passed name should be popped too or only the ones above- PR by @jtdLab that adds to reset a LazySingleton by providing an existing instance
- Fix for an internal state error by @ioantsaf
- Fix for a rare edge case if you manually
signalReady
- Many PRs with improvements to spelling and grammar of readme, source documentation and even one assert message by @selcukguvel @isinghmitesh @UsamaKarim @nilsreichardt and Os-Prog @Ae-Mc
- fix for #210
- Parameters of factories are no longer needed to be casted because they are nullable
- downgraded the dependency on
async
to 2.6 again - you couldn't push two Scopes without a name
- fixed bug with manual synchronization of SingletonsWithDependencies #196
- Fix for #186
- Thanks to the clever PR #185 by @kmartins
unregister
andresetLazySingleton
now only have to be awaited if you use an async disposal function.
pushNewScope()
now got an optionalinit
parameter where you can pass a function that registers new objects inside the newly pushed Scope. Doing the registration in this function ensures that theonScopeChanged
call-back is called after the objects are registered.
- The new
Disposable
interface had a typo that now got corrected. You could call this a breaking change but as the last version change is just three days old I guess not many people will be affected by this correction.
When using scopes with objects that shadow other objects its important to give the UI a chance to rebuild and acquire references to the now active objects. For this you can register an call-back function in GetIt
The getit_mixin has a matching rebuiltOnScopeChange
method.
/// Optional call-back that will get call whenever a change in the current scope happens
/// This can be very helpful to update the UI in such a case to make sure it uses
/// the correct Objects after a scope change
void Function(bool pushed)? onScopeChanged;
This is a breaking change because there were some inconsistencies in the handling of the disposal functions that you can pass when registering an Object, pop a Scope or use unregister()
resetLazySingleton()
. Some of accepted a FutureOr
method type, others just a void
which meant you couldn't use async functions consistently. With this release you can use async functions in all disposal functions which unfortunately also required to change the signatures of the following functions:
Future<void> reset({bool dispose = true});
Future<void> resetScope({bool dispose = true});
Future<void> popScope();
Future<bool> popScopesTill(String name);
FutureOr resetLazySingleton<T extends Object>({
Object? instance,
String? instanceName,
FutureOr Function(T)? disposingFunction,
});
FutureOr unregister<T extends Object>({
Object? instance,
String? instanceName,
FutureOr Function(T)? disposingFunction,
});
Basically all functions that can possibly call a disposal functions should be awaited.
Instead of passing a disposing function on registration or when pushing a Scope from V7.0 on your objects onDispose()
method will be called
if the object that you register implements the Disposable
´interface:
abstract class Disposable {
FutureOr onDispose();
}
In some cases it might be helpful to know if an Object gets shadowed by another one e.g. if it has some Stream subscriptions that it want to cancel before the shadowing object creates a new subscription. Also the other way round so that a shadowed Object gets notified when it's "active" again meaning when a shadowing object is removed.
For this a class had to implement the ShadowChangeHandlers
interface:
abstract class ShadowChangeHandlers {
void onGetShadowed(Object shadowing);
void onLeaveShadow(Object shadowing);
}
When the Object is shadowed its onGetShadowed()
method is called with the object that is shadowing it. When this object is removed from GetIt onLeaveShadow()
will be called.
- Thanks to this PR #181 by @n3wtron you can now also make objects depend on other objects not only by type but also by type and name if you used a named registration
- small fix in getAsync with parameters
- Exceptions that occur during an async initialisation are now forwarded to the future that
allReady()
returns instead to get swallowed #148 - Added a property
currentScopeName
to query the name of the currently active scope #153 popScope
will know throw an Exception instead just an assert if you are already on thebaseScope
and you try to pop it.
- Official null safety release
- fixed #138 when calling
unRegister
the dispose function that can be passed when registering wasn't called.
- fixed formatting in readme
- experimental
- New scope support for registration
- optional dispose functions for registered objects
- Breaking change:
reset()
now is async and returns aFuture
because it will call the new optional disposal functions that can be async - Breaking change: If you use names to register your objects you now have to provide a type too or at least make sure the compiler can infer the type. With this change it is now possible to use the same name for different types.
- alpha version of V5.0
- fixed linter errors
- fixes of several typos thanks to PRs from @Bryanx, @sspatari
- fixed error #92
- removed too strong type check for passed factory parameter
- fixed error message #69
- overhauled readme
- removed unnecessary print statement
- Added abstract
WillSignalReady
class
- Breaking changes in API!!!
- Release candidate
- New Async functions
- Factories with parameters
- Improved startup synchronisation
- Bugfix when using named instances
- Bugfix with #21
- Small fix to make the analyser happy
- Overhauled the signalling API because the way it was was not optimal. Now you can either signal globally or by passing the instance of the registered object that shall signal. This way it's ensured that you have to have access to the instance to signal, typically from within the instance with a
GetIt.instance.signalReady(this)
individual signalling from other places but the instance itself is probably an error. - Unregister of singletons /lazysingletons now possible also over a registered instance.
- Most asserts have bin replaced with throwing
Error
objects. - The example now shows the ready signalling.
- Added handy ready signal to make start-up logic a bit easier
- Unregister of Objects now possible with optional disposing function
- Small fix
- Small fix
- Small fix
- Breaking Change with V2.0.0
you no longer can directly create instances of the type
GetIt
becauseGetIt
is now a singleton please see README
- added named registration
- updated logo in readme
- updated authors
- Small fix so that intellisense works now if you use the short calling form without using
.get()
- Moved package to Flutter Community
- Added
reset()
method
- Initial release