Flutter/如何获取谷歌字体家族列表

标签 flutter google-font-api google-fonts

您好,我正在使用 Flutter 开发应用。

为了管理我的应用程序中的字体,我正在使用

https://pub.dev/packages/google_fonts

包。

所以我打算让用户可以选择他们想要的字体。

有什么办法可以获得谷歌字体系列的完整列表吗?

List<String> _tempFontList = [
  GoogleFonts.droidSerif().fontFamily,
  GoogleFonts.ebGaramond().fontFamily,
  GoogleFonts.fasterOne().fontFamily,
  GoogleFonts.abel().fontFamily,
];

现在我只为字体制作了临时列表,

但据我所知,该包中没有列表 getList 函数。

感谢阅读。

我会等你的帮助。

最佳答案

为了获取字体列表。

GoogleFonts.asMap();

这将返回 map 对象。

如果你只想要名字。

GoogleFonts.asMap().keys.toList();

关于Flutter/如何获取谷歌字体家族列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67111370/

相关文章:

flutter - 如何在 Flutter 中将小部件与另一个小部件对齐?

fonts - Google 字体无法正常工作,出现错误 "No ' Access-Control-Allow-Origin' header is present on the requested resource”

html - 带有 Ruby on Rails 的 AMP : Impossible to use a a Google Font

css - 如何在 Google Fonts 中使用可变字体?

flutter - 如何在Flutter Widget中删除TextField的背景颜色?

Firebase.initializeApp() 给出错误 : Null check operator used on a null value

html - 将所有 Google Material 图标字体请求合并为一个

javascript - 如何在 React 中的 window.open 中使用 Google 字体

css - 如何使用来自谷歌字体的链接使用常规、浅色和粗体字体?

flutter - 如何在没有上下文的情况下在 Flutter 中使用 GoRouter 进行路由?