Skip to main content

safe_controller 0.0.3 copy "safe_controller: ^0.0.3" to clipboard
safe_controller: ^0.0.3 copied to clipboard

A clean architecture utility for Flutter that provides result-based API execution and centralized error handling, designed to keep UI and business logic clean.

safe_controller #

A lightweight Flutter utility package that provides result-based API execution to support clean architecture and eliminate UI-level exception handling.

This package is framework-agnostic and works with any state management solution.


✨ Features #

  • Result-based API flow (ApiSuccess / ApiFailure)
  • Centralized API execution with ApiExecutor
  • No try-catch required in UI layers
  • Prevents exception leakage to controllers
  • Clean architecture friendly

📦 Installation #

dependencies:
  safe_controller: ^0.2.0

Usage #

final result = await ApiExecutor.execute(
  apiCall: () => repository.fetchData(),
);

switch (result) {
  case ApiSuccess(:final data):
    // handle success
    break;

  case ApiFailure(:final message):
    // handle failure
    break;
}

final result = await ApiExecutor.execute(
  apiCall: () => apiClient.callApi(),
  isTokenExpired: (response) => response.statusCode == 401,
);

1
likes
150
points
11
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A clean architecture utility for Flutter that provides result-based API execution and centralized error handling, designed to keep UI and business logic clean.

Homepage

License

MIT (license)

Dependencies

flutter, get

More

Packages that depend on safe_controller