因此,https://flutter.dev/docs/cookbook/design/package-fonts必须在应用程序的pubspec.yaml中声明包的字体:
声明字体资产
现在,您已经导入了软件包,请告诉
在awesome_package中找到字体的位置不一。
要声明程序包字体,请在字体路径之前添加前缀
包/ awesome_package。这告诉Flutter在lib文件夹中查找
字体的包装。
即:
dependencies:
flutter:
sdk: flutter
handwriter:
path: ../handwriter
model:
path: ../model
flutter:
uses-material-design: true
fonts:
- family: FancyHandwriting
fonts:
- asset: packages/handwriter/third_party/FancyHandwriting-Regular.ttf
请注意,您声明的资产是来自软件包的-无需在应用程序的lib
中复制资产。
其背后的原因是,并非每个软件包中的所有字体都可以使用,因此可以缩小最终应用程序的大小。
,
不要忘记,您还必须将字体导入/复制到字体资产目录中。对于您的情况,请确保将它们放在lib/third_party/
中。 (请参阅步骤1-https://flutter.dev/docs/cookbook/design/fonts)。
,
无需,无需在程序包消费者应用程序中重新添加字体,您可以使用:
const urlBase = "https://....cognitiveservices.azure.com/vision/v3.0/analyze";
var params = {
"visualFeatures": "Categories,Description,Color","details": "","language": "en",};
$.ajax({
url: uriBase + "?" + $.param(params),// Request headers.
beforeSend: function(xhrObj){
xhrObj.setRequestHeader("Content-Type","application/json");
xhrObj.setRequestHeader(
"Ocp-Apim-Subscription-Key",subscriptionKey);
},type: "POST",// Request body.
data: '{"url": ' + '"' + sourceImageUrl + '"}',}) .done(function(data) {
// Show formatted JSON on webpage.
callYourFunction(data);
})
这也等同于:
final defaultStyle = TextStyle(
fontFamily: 'FancyHandwriting',package: 'handwriter',fontSize: 130,);
本文链接:https://www.f2er.com/3162936.html