Sergey Penkovsky 5de737079d doc: add README
2025-05-19 16:12:45 +03:00
2025-05-18 16:41:48 +03:00
2025-05-19 16:11:41 +03:00
2025-05-19 16:12:45 +03:00
2025-05-19 16:12:45 +03:00
2025-05-19 16:12:45 +03:00
2025-05-02 11:41:18 +03:00
2025-05-19 16:11:41 +03:00
2025-05-19 10:12:32 +03:00
2025-05-16 16:43:23 +03:00
2020-06-27 06:05:03 +03:00
2025-05-19 16:11:41 +03:00
2025-05-19 16:11:41 +03:00
2025-05-19 16:11:41 +03:00
2025-05-16 13:02:32 +03:00

CherryPick Workspace

Welcome to the CherryPick Workspace, a comprehensive suite for dependency management in Flutter applications. It consists of the cherrypick and cherrypick_flutter packages, designed to enhance modularity and testability by providing robust dependency and state management tools.

Overview

  • cherrypick: A Dart library offering core tools for dependency injection and management through modules and scopes.
  • cherrypick_flutter: A Flutter-specific library facilitating access to the root scope via the context using CherryPickProvider, simplifying state management within the widget tree.

Repository Structure

  • Packages:
    • cherrypick: Core DI functionalities.
    • cherrypick_flutter: Flutter integration for context-based root scope access.

Quick Start Guide

Installation

To add the packages to your project, include the dependencies in your pubspec.yaml:

dependencies:
  cherrypick: any
  cherrypick_flutter: any

Run flutter pub get to install the dependencies.

Usage

cherrypick

  • Binding Dependencies: Use Binding to set up dependencies.

    Binding<String>().toInstance("hello world");
    Binding<String>().toProvide(() => "hello world").singleton();
    
  • Creating Modules: Define dependencies within a module.

    class AppModule extends Module {
      @override
      void builder(Scope currentScope) {
        bind<ApiClient>().toInstance(ApiClientMock());
      }
    }
    
  • Managing Scopes: Control dependency lifecycles with scopes.

    final rootScope = Cherrypick.openRootScope();
    rootScope.installModules([AppModule()]);
    final apiClient = rootScope.resolve<ApiClient>();
    

cherrypick_flutter

  • CherryPickProvider: Wrap your widget tree to access the root scope via context.

    void main() {
      runApp(CherryPickProvider(
        rootScope: yourRootScopeInstance,
        child: MyApp(),
      ));
    }
    
  • Accessing Root Scope: Use CherryPickProvider.of(context).rootScope to interact with the root scope in your widgets.

    final rootScope = CherryPickProvider.of(context).rootScope;
    

Example Project

Check the example directory for a complete demonstration of implementing CherryPick Workspace in a Flutter app.

Features

  • Dependency Binding and Resolution
  • Custom Module Creation
  • Root and Sub-Scopes
  • Convenient Root Scope Access in Flutter

Contributing

We welcome contributions from the community. Feel free to open issues or submit pull requests with suggestions and enhancements.

License

This project is licensed under the Apache License 2.0. You may obtain a copy of the License at Apache License 2.0.

Description
CherryPick is a modular, open-source dependency injection ecosystem for Dart and Flutter
Readme Apache-2.0 2 MiB
Languages
Dart 96.2%
TypeScript 2.1%
Python 1.3%
CSS 0.4%