PackageTrack
Sign in Get early access

lite_ref

A lightweight dependency injection package with support for overriding for testing.

0.8.1 4.1K downloads/mo #4145 most downloaded on pub.dev jinyus/lite_ref

What this package is like to depend on

Last release 2 years ago

no release in 18 months

Release timing varies

gaps range from 8 days to 2 months

Nearly every release is documented

notes for 18 of 18 stable releases

Nothing withdrawn

no release was ever pulled

3 years old

18 releases · first in 2024

0 releases in the last 12 months

see the full history below

Release timeline

18 releases · Jan 2024 to Apr 2024
2025 2026
Release Pre-release

Releases

latest 18
  1. 0.8.1 20 Apr 2024
    Release notes
    • [Fix] Fixed bug with disposal of widget state.
    Open source →
  2. 0.8.0 19 Apr 2024
    Release notes
    • [Fix] Fixed bug with hot-reloading

    • [Feat] Add Ref.scopedFamily which takes a argument to create a unique instance for each key.

      • Create a ScopedFamilyRef.

        final postControllerRef = Ref.scopedFamily((ctx, String key) {
        return PostController(key)..fetch();
        });
        
      • Access the instance in the current scope:

        This can be done in a widget by using postController.of(context, key) or postController(context, key).

        class PostsPage extends StatelessWidget {
        const PostsPage({required this.keys, super.key});
        
        final List<String> keys;
        
        @override
        Widget build(BuildContext context) {
            return ListView.builder(
            itemBuilder: (context, index) {
                final post = postControllerRef.of(context, keys[index]);
                return Text(post?.title ?? 'Loading...');
            },
            );
        }
        }
        
    Open source →
  3. 0.7.0 02 Apr 2024
    Release notes

    What's Changed

    • Add ScopedRef.read(context) by @JinyuS in #19
    • Feat: Add onlyOverrides param to LiteRefScope by @JinyuS in #20
    • Refactor scoped ref and scope widget to improve performance by @JinyuS in #21
    • Fix: bug where refs were disposed when child widget was temporarily deactivated by @JinyuS in #23

    Full Changelog: v0.6.1...v0.7.0

    Open source →
    Release notes
    • [Fix] Fixed bug where refs were disposed when the child is temporarily deactivated.

    • [Breaking] The overrides property of LiteRefScope is now a Set of ScopedRefs instead of a List of ScopedRefs.

      Before

      LiteRefScope(
      overrides: [
          settingsServiceRef.overrideWith((ctx) => MockSettingsService()),
      ]
      child: MyApp(),
      )
      

      After:

      LiteRefScope(
      overrides: {
          settingsServiceRef.overrideWith((ctx) => MockSettingsService()),
      }
      child: MyApp(),
      )
      
    Open source →
  4. 0.6.3 22 Mar 2024
    Release notes
    • [Refactor] minor refactor
    Open source →
  5. 0.6.2 21 Mar 2024
    Release notes
    • [Feat] Add onlyOverrides to LiteRefScope which will only provide overridden instances to children.
    Open source →
  6. 0.6.1 14 Mar 2024
    Release notes

    What's Changed

    • Add exists() method to ScopedRef with tests by @JinyuS in #16

    Full Changelog: v0.4.0...v0.6.1

    Open source →
    Release notes
    • [Feat] Add ScopedRef.exists(context) method to check if a ScopedRef is initialized in the current LiteRefScope.
    Open source →
  7. 0.6.0 13 Mar 2024
    Release notes
    • Update flutter dependency constraint
    Open source →
  8. 0.5.2 06 Mar 2024
    Release notes
    • [Refactor] Add core package as a dependency.
    Open source →
  9. 0.5.1 04 Mar 2024
    Release notes
    • [Fix] Remove dispose function when overriding with autoDispose set to false.
    Open source →
  10. 0.5.0 04 Mar 2024
    Release notes
    • [Feat] Add autodipose for ChangeNotifiers and any class that implements Disposable. These classes will be disposed when all the widgets that have access to the instance are unmounted. If providing a existing and you don't want the instance to be disposed set autoDispose to false.

      In the example below, the CounterController will be disposed when the CounterView is unmounted.

      class CounterController extends ChangeNotifier {
      var _count = 0;
      int get count => _count;
      
      void increment() {
          _count++;
          notifyListeners();
      }
      
      void decrement() {
          _count--;
          notifyListeners();
      }
      }
      
      final countControllerRef = Ref.scoped((ctx) => CounterController());
      
      class CounterView extends StatelessWidget {
      const CounterView({super.key});
      
      @override
      Widget build(BuildContext context) {
          final contoller = countControllerRef.of(context);
          return ListenableBuilder(
          listenable: contoller,
          builder: (context, snapshot) {
              return Text('${contoller.count}');
          },
          );
      }
      }
      
    Open source →
  11. 0.4.1 01 Mar 2024
    Release notes
    • [Docs] Add documentation comments and examples
    Open source →
  12. 0.4.0 29 Feb 2024
    Release notes

    What's Changed

    • Convert to Flutter package and add Ref.scoped by @JinyuS in #6

    Full Changelog: https://github.com/jinyus/lite_ref/commits/v0.4.0

    Open source →
    Release notes
    • [Breaking] This now a flutter package

    • Add ScopedRef which is a ref that needs a context to access its instance

    • Add LiteRefScope which coupled withScopedRef is an alternative to Provider for classes that don't rebuild widgets.

      • Wrap your app or a subtree with a LiteRefScope:

        runApp(
        LiteRefScope(
            child: MyApp(),
        ),
        );
        
      • Create a ScopedRef.

        final settingsServiceRef = Ref.scoped((ctx) => SettingsService());
        
      • Access the instance in the current scope:

        This can be done in a widget by using settingsServiceRef.of(context) or settingsServiceRef(context).

        class SettingsPage extends StatelessWidget {
        const SettingsPage({super.key});
        
        @override
        Widget build(BuildContext context) {
            final settingsService = settingsServiceRef.of(context);
            return Text(settingsService.getThemeMode());
        }
        }
        
      • Override it for a subtree:

        You can override the instance for a subtree by using overrideWith. This is useful for testing. In the example below, all calls to settingsServiceRef.of(context) will return MockSettingsService.

        LiteRefScope(
            overrides: [
                settingsServiceRef.overrideWith((ctx) => MockSettingsService()),
            ]
            child: MyApp(),
            ),
        
    Open source →
  13. 0.3.0 07 Jan 2024
    Release notes
    • Make the factory function non-nullable (improves performance and maintainability)
    Open source →
  14. 0.2.1 06 Jan 2024
    Release notes
    • Internal performance improvements
    • fix minor bug where async singleton would not be replace when overridden
    Open source →
  15. 0.2.0 06 Jan 2024
    Release notes
    • separate singleton and transient instantiation use: Ref.singleton, Ref.transient, Ref.asyncSingleton and Ref.asyncTransient
    • add assertInstance getter for synchronous access to a AsyncSingletonRef
    Open source →
  16. 0.1.0 06 Jan 2024
    Release notes
    • prevent race condition when fetching async singleton
    • add assertInstance getter for synchronous access to a LiteAsyncRef
    • add .freeze() method which disables overriding
    Open source →
  17. 0.0.2 06 Jan 2024
    Release notes
    • Update readme
    Open source →
  18. 0.0.1 06 Jan 2024
    Release notes
    • Initial release
    Open source →

Every package, every release, already written down.

The archive is open and free. Watching your own project is what we are building next.

Browse the archive