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

Centralized API execution, loading & lifecycle guards for GetX controllers.

safe_controller #

A lightweight GetX-first Flutter package to centralize:

  • API execution
  • Loading handling
  • Screen lifecycle safety

Features #

  • Prevent UI updates after screen dispose
  • Unified API execution
  • Built-in loading state

Usage #

class LeadController extends SafeGetxController {
  Future<void> loadLeads() async {
    await withLoading(() async {
      final data = await ApiExecutor.execute(
        apiCall: repository.callApi,
        isTokenExpired: (response) {
          return response.statusCode == 401;
        },
        onTokenExpired: () {
            // navigate to login screen or Get new token using ur refresh token
        },
      );
      if (!isAlive || data == null) return;
    });
  }
}

Additional information #

Tell users more about the package: where to find more information, how to contribute to the package, how to file issues, what response they can expect from the package authors, and more.

1
likes
0
points
68
downloads

Publisher

unverified uploader

Weekly Downloads

Centralized API execution, loading & lifecycle guards for GetX controllers.

Homepage

License

unknown (license)

Dependencies

flutter, get

More

Packages that depend on safe_controller