在Android平台上,Flutter存在自定义字体的问题。

huangapple go评论64阅读模式
英文:

Flutter, the problem of custom fonts on the Android platform

问题

我将以下内容翻译为中文:

我在项目中添加了自定义字体
在iOS平台上应用正确,但在Android平台上没有应用

Widget build(BuildContext context) {
  return MaterialApp.router(
    title: 'Flutter Demo',
    theme: ThemeData(
      fontFamily: 'RobotoMono',
      primarySwatch: Colors.blue,
    ),
    routerConfig: _router,
  );
}
fonts:
  - family: RobotoMono
    fonts:
      - asset: fonts/RobotoMono-Regular.ttf
英文:

I added a custom font to the project
It is applied correctly on the iOS platform, but not on the Android platform

Widget build(BuildContext context) {
return MaterialApp.router(
title: 'Flutter Demo',
theme: ThemeData(
fontFamily: 'RobotoMono',
primarySwatch: Colors.blue,
),
routerConfig: _router,
);
}


fonts:
- family: RobotoMono
fonts:
- asset:fonts/RobotoMono-Regular.ttf

答案1

得分: 1

请将字体文件添加到资产文件夹中

在pubspec.yaml中添加字体文件的提及后

英文:

Please add font file in assets folder

After add font file to mentions in pubspec.yaml

huangapple
  • 本文由 发表于 2023年7月31日 18:56:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/76802938.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定