api_provider 1.0.5 copy "api_provider: ^1.0.5" to clipboard
api_provider: ^1.0.5 copied to clipboard

A Plugin for making api calls easier and quicker for flutter developers.

API Provider Flutter Plugin #

Overview #

The API Provider Flutter Plugin is a powerful and flexible Flutter plugin designed to simplify the process of integrating APIs into your Flutter applications. This plugin follows a straightforward approach to make API calls, handle responses, and manage state, allowing you to focus on building robust and efficient mobile applications.

Features #

  • Easy Integration: Quickly integrate API calls into your Flutter app with minimal setup.
  • State Management: Effortlessly manage the state of API calls and handle loading, success, and error states.
  • Customization: Customize headers, parameters, and other configurations for your API requests.
  • Error Handling: Streamlined error handling to easily identify and manage issues with API calls.
  • Concurrency Support: Support for concurrent API calls, ensuring optimal performance.
  • Scalability: Easily scale your application by managing multiple APIs seamlessly.

Getting Started #

Installation #

To use the API Provider Flutter Plugin, add the following dependency to your pubspec.yaml file:

dependencies:
  api_provider: ^1.0.5

Usage #

  1. Import the package:
import 'package:api_provider/api_provider.dart';
  1. Create an instance of ApiProvider:
ApiProvider apiProvider = ApiProvider(baseUrl: 'https://api.example.com/');
  1. Make API calls:
apiProvider.get('your api path without url')
  .then((response) {
    // Handle success
  })
  .catchError((error) {
    // Handle error
  });

Configuration #

You can provide the authentication token to every api call with it's persistToken function:

await apiProvider.persistToken(token: 'your Api token');

await apiProvider.deleteAuthToken();

await apiProvider.updateAuthToken(updatedToken: 'your refresh token');

await apiProvider.hasAuthToken();

You can also extends BaseProvider class and make api calls by passing the BaseApiClient from ApiProvider instance

class AlertProvider extends BaseProvider {
  AlertProvider({required BaseApiClient httpClient, required String name}) : super(httpClient: httpClient, name: name);

  Future<dynamic> getData() async {
    var response = await get('your api path without base url');
    return response;
  }
}

Contribution #

We welcome contributions! If you find a bug or have an enhancement in mind, please contact me on junaid.iam.khokhar@gamil.com.


4
likes
130
pub points
37%
popularity

Publisher

verified publisherperitumsolution.pk

A Plugin for making api calls easier and quicker for flutter developers.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

dio, flutter, flutter_secure_storage, flutter_web_plugins

More

Packages that depend on api_provider