api_response_debugger 0.0.4 copy "api_response_debugger: ^0.0.4" to clipboard
api_response_debugger: ^0.0.4 copied to clipboard

A Flutter package for debugging and tracking API responses with advanced visualization and analysis tools.

API Response Debugger #

A Flutter package for debugging API responses with advanced visualization and analysis tools.

Overview #

API Response Debugger is a powerful debugging tool that helps track, analyze, and debug API responses in Flutter applications. It provides local storage of API responses, comparison tools, and a visual interface for inspecting API data and parsing issues.

Features #

  • πŸ“ Local storage of API responses
  • πŸ” Response history tracking and viewing
  • πŸ”„ JSON diff visualization
  • ⚠️ Parsing error analysis
  • πŸ“Š Model-Response structure comparison
  • 🎯 Debug dashboard UI
  • πŸ“± Response details viewer
  • 🚨 Error tracking and stack trace capture

Getting started #

Add this to your pubspec.yaml:

dependencies:
  api_response_debugger: ^0.0.1

Required dependencies will be automatically included:

  • sqflite: ^2.3.0
  • path: ^1.8.3
  • dio: ^5.0.0
  • dartz: ^0.10.1

Usage #

1. Initialize the tracker #

final apiTracker = ApiResponseTracker();

2. Track API responses #

try {
  final response = await dio.get('/endpoint');
  
  await apiTracker.storeApiResponse(
    endpoint: '/endpoint',
    statusCode: response.statusCode ?? 0,
    responseData: response.data,
    parsingStatus: ParsingStatus.success,
    apiStatus: ApiStatus.success,
  );
} catch (e, stackTrace) {
  await apiTracker.storeApiResponse(
    endpoint: '/endpoint',
    statusCode: 500,
    responseData: e.toString(),
    parsingStatus: ParsingStatus.failure,
    apiStatus: ApiStatus.failure,
    parsingError: e.toString(),
    stackTrace: stackTrace.toString(),
  );
}

3. Add debug dashboard #

Navigator.push(
  context,
  MaterialPageRoute(builder: (context) => const ApiDebugDashboard()),
);

Core Features #

Response Tracking #

  • Automatic storage of API responses
  • Parsing status tracking
  • Error and stack trace capture
  • Response history per endpoint

Debug Dashboard #

The ApiDebugDashboard provides:

  • Overview of all tracked endpoints
  • Failed response highlighting
  • Response history viewing
  • JSON comparison tools

Response Analysis #

  • JSON diff visualization
  • Model structure comparison
  • Type mismatch detection
  • Parsing error analysis

API Reference #

ApiResponseTracker #

Main class for managing API responses:

// Store a response
await apiTracker.storeApiResponse(
  endpoint: endpoint,
  statusCode: statusCode,
  responseData: responseData,
  parsingStatus: parsingStatus,
);

// Get responses for endpoint
final responses = await apiTracker.getResponsesForEndpoint(endpoint);

// Get failed parsing responses
final failedResponses = await apiTracker.getFailedParsingResponses();

// Get latest response
final latest = await apiTracker.getLatestResponseForEndpoint(endpoint);

Debug UI Components #

  1. ApiDebugDashboard: Main debugging interface
const ApiDebugDashboard();
  1. ApiResponseDebugPage: Detailed response view
ApiResponseDebugPage(endpoint: 'your_endpoint');
  1. ModelComparisonView: Compare model and response structures
ModelComparisonView(
  modelStructureJson: modelJson,
  responseJson: responseJson,
);

Best Practices #

  1. Development Only Usage
if (kDebugMode) {
  // Initialize API Response Debugger
}
  1. Clean Database Regularly
// Implement periodic cleanup based on your needs
  1. Meaningful Endpoint Names Use clear, descriptive endpoint paths for better debugging:
"/users/profile" instead of "/api/v1/u/p"

Troubleshooting #

Database Issues #

  • Ensure proper database initialization
  • Check write permissions
  • Verify storage space availability

Response Tracking Issues #

  • Verify response data format
  • Check endpoint paths
  • Ensure proper error handling

UI Issues #

  • Verify BuildContext availability
  • Check navigation state
  • Ensure proper widget tree structure

Requirements #

  • Flutter β‰₯ 3.0.0
  • Dart β‰₯ 3.0.0
  • iOS 11.0 or above
  • Android 5.0 (API 21) or above

Additional Information #

License #

This project is licensed under the MIT License - see the LICENSE file for details.

2
likes
130
points
30
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package for debugging and tracking API responses with advanced visualization and analysis tools.

Repository (GitHub)
View/report issues
Contributing

Documentation

Documentation
API reference

License

unknown (license)

Dependencies

dartz, dio, flutter, path, sqflite

More

Packages that depend on api_response_debugger