.. | ||
doc | ||
example | ||
lib | ||
.gitignore | ||
analysis_options.yaml | ||
CHANGELOG.md | ||
LICENSE.md | ||
pubspec.yaml | ||
README.md |
Platform Contracts Package
The Platform Contracts package provides a set of interfaces and abstract classes that define the core contracts for various components of the Platform framework. These contracts ensure consistency and interoperability across different implementations.
Table of Contents
Installation
Add this to your package's pubspec.yaml
file:
dependencies:
platform_contracts: ^1.0.0
This package requires Dart SDK version 3.0.0 or later.
Dependencies:
- meta: ^1.9.0
- dsr_container: ^1.0.0
- dsr_simple_cache: ^1.0.0
Then run:
dart pub get
Features
The Platform Contracts package includes contracts for various components of a web application framework, including:
- Authentication and Authorization
- Broadcasting
- Caching
- Configuration
- Console Applications
- Container (Dependency Injection)
- Database and ORM
- Encryption
- Event Handling
- Filesystem
- HTTP Handling
- Mailing
- Notifications
- Pagination
- Queues
- Redis Integration
- Routing
- Session Management
- Validation
- View Rendering
Usage
Import the package in your Dart code:
import 'package:platform_contracts/contracts.dart';
Then implement the desired interfaces or extend the abstract classes to create your own implementations that adhere to the defined contracts.
Package Structure
The package is organized into several subdirectories under lib/src/
, each focusing on a specific area of functionality:
auth/
: Authentication and authorization contractsbroadcasting/
: Contracts for event broadcastingcache/
: Caching system contractsconfig/
: Configuration management contractsconsole/
: Console application contractscontainer/
: Dependency injection container contractsdatabase/
: Database and ORM contractsencryption/
: Encryption service contractsevents/
: Event dispatching contractsfilesystem/
: Filesystem interaction contractshttp/
: HTTP request and response contractsmail/
: Mailing service contractsnotifications/
: Notification system contractspagination/
: Pagination contractsqueue/
: Queue system contractsredis/
: Redis integration contractsrouting/
: Routing system contractssession/
: Session management contractsvalidation/
: Validation system contractsview/
: View rendering contracts
Each subdirectory contains interfaces and abstract classes that define the contracts for their respective areas.
Examples
Here are a few examples of how to use the contracts in this package:
Implementing an Authenticatable User
import 'package:platform_contracts/contracts.dart';
class User implements Authenticatable {
@override
String getAuthIdentifierName() => 'id';
@override
String getAuthIdentifier() => '12345';
@override
String getAuthPassword() => 'hashed_password';
// Implement other methods...
}
Creating a Custom Cache Store
import 'package:platform_contracts/contracts.dart';
class CustomCacheStore implements Store {
@override
Future<dynamic> get(String key) {
// Implementation
}
@override
Future<bool> put(String key, dynamic value, Duration? ttl) {
// Implementation
}
// Implement other methods...
}
For more examples, please refer to the example/
directory in this package.
Contributing
Contributions are welcome! Here's how you can contribute:
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Please read our Contributing Guide for more details on our code of conduct and the process for submitting pull requests.
License
This project is licensed under the MIT License.
Support
If you encounter any problems or have any questions, please open an issue in the issue tracker.