requestor

Last updated:

0 purchases

requestor Image
requestor Images
Add to Cart

Description:

requestor

Requestor Flutter Library #
Requestor is a library for making HTTP requests and downloading files in Flutter easily and efficiently.
Installation #
To use this library, add the following line to your pubspec.yaml file:
dependencies:
requestor: last_version
copied to clipboard
Then run the command flutter pub get to install the library.
Basic Usage #
Import the library in your Dart file:
import 'package:requestor/requestor.dart';
copied to clipboard
Create an instance of Requestor and configure it according to your needs:
Requestor requestor = Requestor();
requestor.setOrigin('https://api.example.com');

requestor.addInterceptor((headers) {
header["request-token"] = "xxxxxxx"; // example
return headers;
});
copied to clipboard
Making a GET Request
Response response = await requestor.get('/endpoint');
print(response.data);
copied to clipboard
Making a POST Request
Map<String, dynamic> data = {'key': 'value'};
Response response = await requestor.post('/endpoint', data);
print(response.data);
copied to clipboard
Downloading Files
List<DownloadItem> files = [
DownloadItem(url: 'https://example.com/file1.txt'),
DownloadItem(url: 'https://example.com/file2.txt'),
];

String outputPath = '/path/to/save/files';
await requestor.downloadFiles(files, output: outputPath);
copied to clipboard
Available Methods

get(url, [headers]): Makes a GET request.
post(url, data, [headers]): Makes a POST request.
put(url, data, [headers]): Makes a PUT request.
delete(url, [headers]): Makes a DELETE request.
options(url, data, [headers]): Makes an OPTIONS request.
patch(url, data, [headers]): Makes a PATCH request.
downloadFiles(urls, {output, headers, threads, onProgress, onDownload}): Downloads files from a list of URLs.
getApplicationPath(): Gets the application path.
getFilesByDirectory(path): Gets a list of files in a specific directory.

Additional Configuration
You can configure the number of threads for downloads and add custom headers to requests.
requestor.threads = 10;
requestor.setConfig({'token': 'your_auth_token'});
copied to clipboard
And that's it! Now you are ready to start using the Requestor library in your Flutter application.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.