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 fluttercommunity#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 fluttercommunity#196
- Fix for fluttercommunity#186
- Thanks to the clever PR fluttercommunity#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 fluttercommunity#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 fluttercommunity#148 - Added a property
currentScopeName
to query the name of the currently active scope fluttercommunity#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 fluttercommunity#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 fluttercommunity#92
- removed too strong type check for passed factory parameter
- fixed error message fluttercommunity#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 fluttercommunity#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