Resource Provider
A simple resource provider to get objects by type (or by both name and type). Right now it eagerly creates an object on get.
Features
Resource providers maintains collection of resources in its instance and all of them can be disposed after usage.
Getting started
-
Add dependency with
dart pub add resource_provider
orflutter pub add resource_provider
. -
Import the package
import 'package:resource_provider/resource_provider.dart';
- Create an instance of ResourceProvider.
final resource = ResourceProvider();
- Get a resource (Will always return same instance).
resource(ResourceData(onCreate: someValueCallback))}
- 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();