A Flutter package (unofficial) uses a free and opensource quotation API called Quotable
This package (unofficial) uses a free and opensource quotation API called Quotable.
Features
Get a random quote, list of quotes or search them as query by quotes and authors. You can also use tags to filter quotes and sort or order them as per the parameters.
Getting started
- Quote Model
Quote({
String id,
String content,
String author,
int length,
List<String> tags,
});
- Author Model
Author({
String id,
String bio,
String description,
String link,
String name,
String slug,
int quoteCount,
});
- Get Quotes from Quotable Repository
Future<Quote> Quotable.getRandom({
List<String>? tags,
int? maxLength,
int? minLength,
});
Future<List<Quote>> Quotable.getListQuotes({
List<String>? tags,
List<String>? authors,
SortBy sortBy = SortBy.dateAdded,
Order order = Order.desc,
int page = 1,
int limit = 20,
})
Future<List<Quote>> Quotable.searchQuotes({
required String query,
int page = 1,
int limit = 20,
})
Future<List<Author>> Quotable.searchAuthor({
required String query,
int page = 1,
int limit = 20,
})
If you are confused about page
and limit
or how they work together then read this table.
Usage
// get random - Quote()
void main() async {
Quote quoteRamdon = await Quotable.getRandom();
List<Quote> listQuotes = await Quotable.getListQuotes(limit: 5);
List<Quote> queryQuote = await Quotable.searchQuotes(query: 'wisdom', limit: 5);
List<Author> queryAuthor = await Quotable.searchAuthor(query: 'einstein');
}
Additional information
If you find any issues or want to contribute then please feel free to open an issues or a discussion here