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.


Resource providers maintains collection of resources in its instance and all of them can be disposed after usage.

Getting started

  1. Add dependency with dart pub add resource_provider or flutter pub add resource_provider.

  2. Import the package

import 'package:resource_provider/resource_provider.dart';
  1. Create an instance of ResourceProvider.
final resource = ResourceProvider();
  1. Get a resource (Will always return same instance).
resource(ResourceData(onCreate: someValueCallback))}
  1. You can update the returning resource's value by providing a value.
resource(ResourceData(onCreate: someValueCallback), value: someUpdatedValue)}
  1. clear resources after usage to dispose.
resource.clear(); // or resource.dispose();