A simple API service that follows a FirebaseFirestore-like definition of resource endpoints.
- Call endpoints with Put, Patch, Delete, Post and Get http methods
- Use converters for type safe interaction with endpoints.
- Allow authentication due to an auth credentials service.
To use the this API service in your Dart or Flutter, add the following to the pubspec
flutter_start:
git:
url: https://github.com/Iconica-Development/dart_api_service
ref: <Version>
TODO: Include short and useful examples for package users. Add longer examples
to /example
folder.
var authService = MockAuthService();
var apiService = HttpApiService(
baseUrl: Uri.parse("https://jsonplaceholder.typicode.com"),
authenticationService: authService,
);
var converter = ApiConverter.fromSerializable(PostComment.fromMap);
var endPoint = apiService.endpoint("/posts/:post");
var comments = endPoint
.child("/comments")
.withConverter(
converter.list(),
)
.authenticate()
.addHeaders({
"accept": "application/json",
}).withVariables({
"post": 1,
});
try {
var post = await comments.get();
print(post.result);
} on ApiException catch (e) {
print(e.statusCode);
print(e.inner.body);
}
Please file any issues, bugs or feature request as an issue on our GitHub page. Commercial support is available if you need help with integration with your app or services. You can contact us at [email protected].
If you would like to contribute to the plugin (e.g. by improving the documentation, solving a bug or adding a cool new feature), please carefully review our contribution guide and send us your pull request.
This dart_api_service for Flutter and Dart is developed by Iconica. You can contact us at [email protected]