此(非官方)包使用了名为 Quotable 的免费开源引言 API。

特点

获取随机引言、引言列表或按引言和作者搜索它们。您还可以使用标签按参数过滤引言并进行排序或排列。

入门

  • 引言模型

Quote({
    String id,
    String content,
    String author,
    int length,
    List<String> tags,
});
  • 作者模型

Author({
    String id,
    String bio,
    String description,
    String link,
    String name,
    String slug,
    int quoteCount,
});
  • 从 Quotable 存储库获取引言

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,
})

如果您对pagelimit或它们如何协同工作感到困惑,请阅读表格。

用法

// 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');
}

附加信息

如果您发现任何问题或想做出贡献,请随时在此处 打开问题或讨论

GitHub

查看 Github