Search packages, repositories and app categories

Package detailsv0.6.1

http_mock_adapter

A simple to use mocking package for Dio intended to be used in tests. It provides various types and methods to declaratively mock request-response communication.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
382K
Likes
185
Pub points
140

Install package

flutter pub add http_mock_adapter

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

http_mock_adapter is a testing utility for Dio, a popular HTTP client in Flutter. It enables developers to mock HTTP requests and responses declaratively, making it easier to test network interactions without actual server calls. The package supports various response types and methods, allowing precise control over mocked behavior during unit and integration tests. Ideal for isolating components that rely on HTTP communication, it enhances test reliability and speed by eliminating external dependencies. Built with simplicity in mind, it integrates seamlessly into existing test workflows.

Use cases

  • Testing API endpoints without live servers
  • Simulating different HTTP response scenarios
  • Isolating network logic in unit tests
  • Validating request parameters and headers
  • Speeding up test execution
  • Mocking error conditions like timeouts

Key features

  • Declarative mocking syntax
  • Support for multiple response types
  • Easy integration with Dio
  • Flexible request matching
  • Built-in status code and header mocking
  • Simple setup for test environments

Suitable for

  • Flutter developers writing unit and integration tests
  • Teams prioritizing fast and reliable test suites
  • Projects using Dio for HTTP requests
  • Test-driven development workflows
  • Developers needing realistic network simulation

Considerations

  • Not intended for production use
  • Requires Dio to be used in the project
  • Limited to mocking HTTP requests only
  • Does not support streaming responses
  • May require additional setup for complex request patterns

Categories

Dependencies

Dependency list 4 items

Projects using this package