我如何检索flutter应用程序的当前字体系列名称,默认名称是什么?我试过了
Theme.of(context).textTheme.
以及
Theme.of(context).
但是没有字体族的属性。
a0x5cqrl1#
中介绍了MaterialApp的默认字体/flutter/packages/flutter/lib/src/material/typography.dart在iOS上,默认文本主题为
/flutter/packages/flutter/lib/src/material/typography.dart
static const TextTheme whiteCupertino = TextTheme( display4 : TextStyle(debugLabel: 'whiteCupertino display4', fontFamily: '.SF UI Display', inherit: true, color: Colors.white70, decoration: TextDecoration.none), display3 : TextStyle(debugLabel: 'whiteCupertino display3', fontFamily: '.SF UI Display', inherit: true, color: Colors.white70, decoration: TextDecoration.none), display2 : TextStyle(debugLabel: 'whiteCupertino display2', fontFamily: '.SF UI Display', inherit: true, color: Colors.white70, decoration: TextDecoration.none), display1 : TextStyle(debugLabel: 'whiteCupertino display1', fontFamily: '.SF UI Display', inherit: true, color: Colors.white70, decoration: TextDecoration.none), headline : TextStyle(debugLabel: 'whiteCupertino headline', fontFamily: '.SF UI Display', inherit: true, color: Colors.white, decoration: TextDecoration.none), title : TextStyle(debugLabel: 'whiteCupertino title', fontFamily: '.SF UI Display', inherit: true, color: Colors.white, decoration: TextDecoration.none), subhead : TextStyle(debugLabel: 'whiteCupertino subhead', fontFamily: '.SF UI Text', inherit: true, color: Colors.white, decoration: TextDecoration.none), body2 : TextStyle(debugLabel: 'whiteCupertino body2', fontFamily: '.SF UI Text', inherit: true, color: Colors.white, decoration: TextDecoration.none), body1 : TextStyle(debugLabel: 'whiteCupertino body1', fontFamily: '.SF UI Text', inherit: true, color: Colors.white, decoration: TextDecoration.none), caption : TextStyle(debugLabel: 'whiteCupertino caption', fontFamily: '.SF UI Text', inherit: true, color: Colors.white70, decoration: TextDecoration.none), button : TextStyle(debugLabel: 'whiteCupertino button', fontFamily: '.SF UI Text', inherit: true, color: Colors.white, decoration: TextDecoration.none), subtitle : TextStyle(debugLabel: 'whiteCupertino subtitle', fontFamily: '.SF UI Text', inherit: true, color: Colors.white, decoration: TextDecoration.none), overline : TextStyle(debugLabel: 'whiteCupertino overline', fontFamily: '.SF UI Text', inherit: true, color: Colors.white, decoration: TextDecoration.none), );
在Android上,默认文本主题为
static const TextTheme whiteMountainView = TextTheme( display4 : TextStyle(debugLabel: 'whiteMountainView display4', fontFamily: 'Roboto', inherit: true, color: Colors.white70, decoration: TextDecoration.none), display3 : TextStyle(debugLabel: 'whiteMountainView display3', fontFamily: 'Roboto', inherit: true, color: Colors.white70, decoration: TextDecoration.none), display2 : TextStyle(debugLabel: 'whiteMountainView display2', fontFamily: 'Roboto', inherit: true, color: Colors.white70, decoration: TextDecoration.none), display1 : TextStyle(debugLabel: 'whiteMountainView display1', fontFamily: 'Roboto', inherit: true, color: Colors.white70, decoration: TextDecoration.none), headline : TextStyle(debugLabel: 'whiteMountainView headline', fontFamily: 'Roboto', inherit: true, color: Colors.white, decoration: TextDecoration.none), title : TextStyle(debugLabel: 'whiteMountainView title', fontFamily: 'Roboto', inherit: true, color: Colors.white, decoration: TextDecoration.none), subhead : TextStyle(debugLabel: 'whiteMountainView subhead', fontFamily: 'Roboto', inherit: true, color: Colors.white, decoration: TextDecoration.none), body2 : TextStyle(debugLabel: 'whiteMountainView body2', fontFamily: 'Roboto', inherit: true, color: Colors.white, decoration: TextDecoration.none), body1 : TextStyle(debugLabel: 'whiteMountainView body1', fontFamily: 'Roboto', inherit: true, color: Colors.white, decoration: TextDecoration.none), caption : TextStyle(debugLabel: 'whiteMountainView caption', fontFamily: 'Roboto', inherit: true, color: Colors.white70, decoration: TextDecoration.none), button : TextStyle(debugLabel: 'whiteMountainView button', fontFamily: 'Roboto', inherit: true, color: Colors.white, decoration: TextDecoration.none), subtitle : TextStyle(debugLabel: 'whiteMountainView subtitle', fontFamily: 'Roboto', inherit: true, color: Colors.white, decoration: TextDecoration.none), overline : TextStyle(debugLabel: 'whiteMountainView overline', fontFamily: 'Roboto', inherit: true, color: Colors.white, decoration: TextDecoration.none), );
并且可以通过以下代码检索字体系列
DefaultTextStyle.of(context).style.fontFamily
hmmo2u0o2#
MaterialApp的默认字体为roboto,这是一种Google字体。https://fonts.google.com/specimen/Roboto
roboto
ulmd4ohb3#
默认字体取决于操作系统:
*Android使用Roboto字体。*iOS使用弗朗西斯科字体(特别是SF Pro Display)。
gopyfrb34#
Flutter应用项目的默认字体系列为Roboto -获取它在这里:https://fonts.google.com/specimen/Roboto#standard-styles默认情况下显示在Andriod OS上。对于iOS设备,弗朗西斯科字体-在这里获取:https://developer.apple.com/fonts/要在flutter项目中默认使用其中任何一个(也取决于您的主题设置),您可以导入其中一个或两个:安德里欧-import package:flutter/material.dart。适用于iOS -import package:flutter/cupertino.dart。你也可以使用其它字体(添加它的文件夹到根文件夹或创建资源文件夹)并在pubspec.yaml中包含字体定义
import package:flutter/material.dart
import package:flutter/cupertino.dart
wlsrxk515#
要获取当前字体系列:DefaultTextStyle.of(context).style.fontFamily默认字体系列将基于设备:https://api.flutter.dev/flutter/material/Typography/Typography.material2021.html
机器人适用于安卓系统. https://api.flutter.dev/flutter/material/Typography/blackMountainView-constant.html弗朗西斯科适用于iOS. https://api.flutter.dev/flutter/material/Typography/blackCupertino-constant.html
5条答案
按热度按时间a0x5cqrl1#
中介绍了MaterialApp的默认字体
/flutter/packages/flutter/lib/src/material/typography.dart
在iOS上,默认文本主题为
在Android上,默认文本主题为
并且可以通过以下代码检索字体系列
hmmo2u0o2#
MaterialApp的默认字体为
roboto
,这是一种Google字体。https://fonts.google.com/specimen/Roboto
ulmd4ohb3#
默认字体取决于操作系统:
*Android使用Roboto字体。
*iOS使用弗朗西斯科字体(特别是SF Pro Display)。
gopyfrb34#
Flutter应用项目的默认字体系列为
Roboto -获取它在这里:https://fonts.google.com/specimen/Roboto#standard-styles
默认情况下显示在Andriod OS上。
对于iOS设备,
弗朗西斯科字体-在这里获取:https://developer.apple.com/fonts/
要在flutter项目中默认使用其中任何一个(也取决于您的主题设置),您可以导入其中一个或两个:
安德里欧-
import package:flutter/material.dart
。适用于iOS -
import package:flutter/cupertino.dart
。你也可以使用其它字体(添加它的文件夹到根文件夹或创建资源文件夹)并在pubspec.yaml中包含字体定义
wlsrxk515#
要获取当前字体系列:
DefaultTextStyle.of(context).style.fontFamily
默认字体系列将基于设备:https://api.flutter.dev/flutter/material/Typography/Typography.material2021.html
机器人适用于安卓系统. https://api.flutter.dev/flutter/material/Typography/blackMountainView-constant.html
弗朗西斯科适用于iOS. https://api.flutter.dev/flutter/material/Typography/blackCupertino-constant.html