2025-05-23 12:21:23 +03:00
|
|
|
//
|
|
|
|
|
// Copyright 2021 Sergey Penkovsky (sergey.penkovsky@gmail.com)
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
|
// You may obtain a copy of the License at
|
2025-08-08 23:24:05 +03:00
|
|
|
// https://www.apache.org/licenses/LICENSE-2.0
|
2025-05-23 12:21:23 +03:00
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
|
// limitations under the License.
|
|
|
|
|
//
|
|
|
|
|
|
2025-05-23 15:26:09 +03:00
|
|
|
import 'package:meta/meta.dart';
|
|
|
|
|
|
docs(annotations): unify and improve English DartDoc for all DI annotations
- Updated all annotation files with complete English DartDoc, field/class/method usage, practical code samples
- Unified documentation style for @inject, @injectable, @instance, @singleton, @named, @scope, @params, @provide, @module
- Removed Russian comments for clarity and consistency
- Improved discoverability and IDE/autocomplete experience for CherryPick DI users
- No functional or API changes; documentation/dev experience only
2025-08-12 16:18:53 +03:00
|
|
|
/// Marks a field for dependency injection by CherryPick's code generator.
|
2025-05-23 17:13:57 +03:00
|
|
|
///
|
docs(annotations): unify and improve English DartDoc for all DI annotations
- Updated all annotation files with complete English DartDoc, field/class/method usage, practical code samples
- Unified documentation style for @inject, @injectable, @instance, @singleton, @named, @scope, @params, @provide, @module
- Removed Russian comments for clarity and consistency
- Improved discoverability and IDE/autocomplete experience for CherryPick DI users
- No functional or API changes; documentation/dev experience only
2025-08-12 16:18:53 +03:00
|
|
|
/// Use `@inject()` on fields within a class marked with `@injectable()`.
|
|
|
|
|
/// Such fields will be automatically injected from the DI [Scope]
|
|
|
|
|
/// when using the generated mixin or calling `.injectFields()`.
|
2025-05-23 17:13:57 +03:00
|
|
|
///
|
docs(annotations): unify and improve English DartDoc for all DI annotations
- Updated all annotation files with complete English DartDoc, field/class/method usage, practical code samples
- Unified documentation style for @inject, @injectable, @instance, @singleton, @named, @scope, @params, @provide, @module
- Removed Russian comments for clarity and consistency
- Improved discoverability and IDE/autocomplete experience for CherryPick DI users
- No functional or API changes; documentation/dev experience only
2025-08-12 16:18:53 +03:00
|
|
|
/// Example:
|
2025-05-23 17:13:57 +03:00
|
|
|
/// ```dart
|
docs(annotations): unify and improve English DartDoc for all DI annotations
- Updated all annotation files with complete English DartDoc, field/class/method usage, practical code samples
- Unified documentation style for @inject, @injectable, @instance, @singleton, @named, @scope, @params, @provide, @module
- Removed Russian comments for clarity and consistency
- Improved discoverability and IDE/autocomplete experience for CherryPick DI users
- No functional or API changes; documentation/dev experience only
2025-08-12 16:18:53 +03:00
|
|
|
/// import 'package:cherrypick_annotations/cherrypick_annotations.dart';
|
|
|
|
|
///
|
|
|
|
|
/// @injectable()
|
|
|
|
|
/// class LoginScreen with _\$LoginScreen {
|
|
|
|
|
/// @inject()
|
|
|
|
|
/// late final AuthService authService;
|
|
|
|
|
///
|
|
|
|
|
/// @inject()
|
|
|
|
|
/// @named('main')
|
|
|
|
|
/// late final ApiClient api;
|
|
|
|
|
/// }
|
|
|
|
|
///
|
|
|
|
|
/// // After running build_runner, call:
|
|
|
|
|
/// // LoginScreen().injectFields();
|
2025-05-23 17:13:57 +03:00
|
|
|
/// ```
|
2025-05-23 15:26:09 +03:00
|
|
|
@experimental
|
2025-05-23 12:21:23 +03:00
|
|
|
final class inject {
|
2025-08-22 09:39:25 +03:00
|
|
|
/// Creates an [inject] annotation for field injection.
|
2025-05-23 12:21:23 +03:00
|
|
|
const inject();
|
|
|
|
|
}
|