Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# See https://www.dartlang.org/guides/libraries/private-files

# Files and directories created by pub
.dart_tool/
.packages
build/
pubspec.lock
coverage/
91 changes: 26 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,78 +1,39 @@
# email_inmemory
<div align="center">
<img src="https://avatars.githubusercontent.com/u/202675624?s=400&u=dc72a2b53e8158956a3b672f8e52e39394b6b610&v=4" alt="Flutter News App Toolkit Logo" width="220">
<h1>Email In-Memory</h1>
<p><strong>An in-memory implementation of the `EmailClient` interface for the Flutter News App Toolkit.</strong></p>
</div>

![coverage: percentage](https://img.shields.io/badge/coverage-100-green)
[![style: very good analysis](https://img.shields.io/badge/style-very_good_analysis-B22C89.svg)](https://pub.dev/packages/very_good_analysis)
[![License: PolyForm Free Trial](https://img.shields.io/badge/License-PolyForm%20Free%20Trial-blue)](https://polyformproject.org/licenses/free-trial/1.0.0)
<p align="center">
<img src="https://img.shields.io/badge/coverage-100%25-green?style=for-the-badge" alt="coverage">
<a href="https://flutter-news-app-full-source-code.github.io/docs/"><img src="https://img.shields.io/badge/LIVE_DOCS-VIEW-slategray?style=for-the-badge" alt="Live Docs: View"></a>
<a href="https://github.com/flutter-news-app-full-source-code"><img src="https://img.shields.io/badge/MAIN_PROJECT-BROWSE-purple?style=for-the-badge" alt="Main Project: Browse"></a>
</p>

An in-memory implementation of the `EmailClient` interface, suitable for testing and development environments where actual email sending is not required.
This `email_inmemory` package provides an in-memory implementation of the `EmailClient` interface within the [**Flutter News App Full Source Code Toolkit**](https://github.com/flutter-news-app-full-source-code). It is specifically designed for testing and development environments where actual email sending is not required. This package simulates the email dispatch process, allowing developers to verify email-related logic without the overhead or external dependencies of a live email service. It ensures consistent behavior and robust error handling based on the `email_client` contract.

## Getting Started
## ⭐ Feature Showcase: Simplified Email Testing & Development

Add the dependency to your `pubspec.yaml`:
This package offers a comprehensive set of features for managing email sending operations in a simulated environment.

```yaml
dependencies:
email_inmemory:
git:
url: https://github.com/flutter-news-app-full-source-code/email-inmemory.git
# Use a specific ref/tag for stability in production
# ref: some-tag
```
<details>
<summary><strong>🧱 Core Functionality</strong></summary>

Then, import the package:
### 🚀 `EmailClient` Implementation
- **`EmailInMemory` Class:** A concrete in-memory implementation of the `EmailClient` interface, providing a standardized way to simulate email sending.
- **Simulated Email Dispatch:** Accurately simulates the `sendTransactionalEmail` operation without sending actual emails, making it ideal for isolated testing.

```dart
import 'package:email_inmemory/email_inmemory.dart';
```

## Features

* Provides an `EmailInMemory` class that implements the `EmailClient` interface.
* Simulates the `sendTransactionalEmail` operation without sending actual emails.
* Logs the simulated email details to the console, which is useful for debugging during development (e.g., viewing OTP codes).
* Includes basic input validation and throws standard `core` exceptions on failure.

## Usage

Instantiate the client and use it where an `EmailClient` is expected. You can optionally provide a `Logger` instance.

```dart
import 'package:email_client/email_client.dart';
import 'package:email_inmemory/email_inmemory.dart';
import 'package:core/core.dart';
import 'package:logging/logging.dart';
void main() async {
// Set up logging to see the output
Logger.root.level = Level.ALL;
Logger.root.onRecord.listen((record) {
print('${record.level.name}: ${record.time}: ${record.message}');
});
// Instantiate the in-memory client
final EmailClient emailClient = EmailInMemory();
// Example: Sending a transactional email (simulated)
try {
await emailClient.sendTransactionalEmail(
senderEmail: 'noreply@example.com',
recipientEmail: 'test@example.com',
subject: 'Your One-Time Code',
templateId: 'd-12345',
templateData: {'otp_code': '987654'},
);
print('Successfully simulated sending email.');
} on HttpException catch (e) {
print('Failed to send email: $e');
}
}
```
### 🌐 Debugging & Validation
- **Console Logging:** Logs simulated email details (sender, recipient, template ID, template data) to the console, which is highly useful for debugging and verifying email content during development.
- **Input Validation:** Includes basic input validation and throws standard `HttpException` subtypes (from `core`) on failure, ensuring consistent error handling in a simulated context.

### 💉 Interface-Driven Design
- **Decoupled Logic:** By implementing the `EmailClient` interface, this package ensures that application logic remains decoupled from specific email service providers, allowing for flexible testing strategies.

> **💡 Your Advantage:** This package provides a reliable, in-memory email client that simplifies testing and development of email-related features. It eliminates the need for external email service dependencies during development, offering immediate feedback and consistent behavior for your email logic.
</details>

## 🔑 Licensing

This package is source-available and licensed under the [PolyForm Free Trial 1.0.0](LICENSE). Please review the terms before use.

For commercial licensing options that grant the right to build and distribute unlimited applications, please visit the main [**Flutter News App - Full Source Code Toolkit**](https://github.com/flutter-news-app-full-source-code) organization.
This `email_inmemory` package is an integral part of the [**Flutter News App Full Source Code Toolkit**](https://github.com/flutter-news-app-full-source-code). For comprehensive details regarding licensing, including trial and commercial options for the entire toolkit, please refer to the main toolkit organization page.
15 changes: 0 additions & 15 deletions coverage/lcov.info

This file was deleted.

Loading
Loading