A simple resource provider to get objects by type (or by both name and type). Right now it eagerly creates an object on get.
Resource providers maintains collection of resources in its instance and all of them can be disposed after usage.
Add dependency with
dart pub add resource_provideror
flutter pub add resource_provider.
Import the package
- Create an instance of ResourceProvider.
final resource = ResourceProvider();
- Get a resource (Will always return same instance).
- You can update the returning resource's value by providing a value.
resource(ResourceData(onCreate: someValueCallback), value: someUpdatedValue)}
- clear resources after usage to dispose.
resource.clear(); // or resource.dispose();