https://github.com/exoad/advices_slip_api
Dart wrapper for the Advice Slip JSON API
https://github.com/exoad/advices_slip_api
dart
Last synced: about 1 month ago
JSON representation
Dart wrapper for the Advice Slip JSON API
- Host: GitHub
- URL: https://github.com/exoad/advices_slip_api
- Owner: exoad
- License: bsd-4-clause
- Created: 2024-10-10T20:25:28.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-10T21:16:32.000Z (over 1 year ago)
- Last Synced: 2025-05-22T07:12:16.388Z (about 1 year ago)
- Topics: dart
- Language: Dart
- Homepage: https://pub.dev/packages/advices_slip_api
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
Advice Slips API Wrapper
An unofficial wrapper for the Advice Slip JSON API to embed into your Dart/Flutter apps.
**Install it [here](https://pub.dev/packages/advices_slip_api)**
## Installation
**`pubspec.yaml`:**
```yaml
dependencies:
advices_slip_api: x.x.x
```
**Command Line**
```shell
[dart/flutter] pub add advices_slip_api
```
## Usage
```
import "package:advices_slip_api/advices_slip_api.dart";
```
#### Available Functions
**`randomAdvice()`** - Get a random advice
**`findAdvice(query)`** - Find advices given a keyword to use to find
**`getAdviceById(id)`** - Find an advice by its canonical id
## Example Usage:
```dart
import "package:advices_slip_api/advices_slip_api.dart";
void main() async {
(await AdviceSlipsApi.randomAdvice())
.onSuccess((AdviceSlip advice) => print(advice))
.onFailure((Exception e) => print(e));
(await AdviceSlipsApi.findAdvice("life"))
.onSuccess((List advice) => print(advice))
.onFailure((Exception e) => print(e));
(await AdviceSlipsApi.findAdvice("life"))
.onSuccess((List advice) => print(advice))
.onFailure((Exception e) => print(e));
}
```